RFR: 8339190: Parameter arrays that are capped during annotation processing report incorrect length [v2]
Jan Lahoda
jlahoda at openjdk.org
Tue Oct 29 12:34:07 UTC 2024
On Thu, 24 Oct 2024 13:00:19 GMT, Chen Liang <liach at openjdk.org> wrote:
>> I was trying to chose between this and `tree.size & ~0xFFFF`, I think `javac` will sometimes check if an int is larger than `0xFFFF`
>
> If you use `& ~0xFFFF` you must use `!= 0` as the mask includes the sign bit.
I think the other checks are implemented as simple `value > limit => error` checks:
https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java#L114
https://github.com/openjdk/jdk/blob/d8430efb5e159b8e08d2cac66b46cb4ff1112927/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java#L938
True, it may overflow, but if it would overflow once, it might overflow twice (back to positive numbers), so if/when that becomes a problem, we'd probably need something more complex. And it will be easier to find if the pattern is as close to the existing patterns as possible. So, I guess I would suggest to use a simple ` > ClassFile.MAX_ANNOTATIONS`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21663#discussion_r1820699731
More information about the compiler-dev
mailing list