RFR: 8339190: Parameter arrays that are capped during annotation processing report incorrect length [v2]

Chen Liang liach at openjdk.org
Thu Oct 24 04:26:06 UTC 2024


On Wed, 23 Oct 2024 14:31:49 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> Can I please get a review for this change.
>> Passes tier1, currently running tier 2-3.
>> 
>> The regression test creates temporary files in `tmpdir` to check that the warning is emitted correctly.
>> I've also added the new warning to `example.not-yet.txt` as the example would require a very large file.
>> 
>> Here is the result of running `javap -c -p -v` on `ClassAnnotationWithLength_65536.class`  and `ClassAnnotationWithLength_65537.class` respectively. Results are the same before/after the change.
>> 
>> 
>> static int x;
>>     descriptor: I
>>     flags: (0x0008) ACC_STATIC
>>     RuntimeVisibleAnnotations:
>>       0: #14(#15=s#16,#17=I#18,#19=[J#20])
>>         CustomAnno(
>>           value="custom"
>>           count=42
>>           arr=[-1l]
>>         )
>> 
>> 
>> 
>>   static int x;
>>     descriptor: I
>>     flags: (0x0008) ACC_STATIC
>>     RuntimeVisibleAnnotations:
>>       0: #14(#15=s#16,#17=I#18,#19=[J#20,J#20])
>>         CustomAnno(
>>           value="custom"
>>           count=42
>>           arr=[-1l,-1l]
>>         )
>> 
>> 
>> TIA
>
> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision:
> 
>   - remove unused import
>   - realized I need to change the condition in my for loop

src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java line 1430:

> 1428:         private void checkArraySize(List<JCExpression> tree) {
> 1429:             //check if attribute length exceeds maximum unsigned 16-bit value
> 1430:             if (!sigOnly && tree != null && (tree.size() >>> 16) > 0) {

Should we use `(tree.size & ~0xFFFF) != 0`? This is how classfile API checks the value compatibility, and I wonder how other places in javac does so.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21663#discussion_r1814224310


More information about the compiler-dev mailing list