Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8339190

Parameter arrays that are capped during annotation processing report incorrect length

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • 24
    • None
    • tools

      As reported by [~mschoene]

      When the annotation methods are invoked any parameter arrays are capped to their size mod 65536, even if the source array was much longer:

      I have a PoC that demonstrates that, it first generates a class
      MyClass_nn.java with 'nn' parameters:

      public class MyClass_2 {
        @MyCustomAnno(value = "custom", count = 42, bla={-1,-1 })

      When later querying the annotations long array "bla" via reflection the length is as in the source, but all over u2 size is capped to size % 65536.
      sh test_annotation_array_length.sh
      #annos in src ===> 2
      length: 2
      #annos in src ===> 4
      length: 4
      #annos in src ===> 6
      length: 6
      #annos in src ===> 128
      length: 128
      #annos in src ===> 32768
      length: 32768
      #annos in src ===> 65535
      length: 65535
      #annos in src ===> 65536
      length: 0
      #annos in src ===> 65537
      length: 1
      #annos in src ===> 512000
      length: 53248
      This is likely functional and an edge case , but still an interesting example for a number wrap. (edited)

      % unzip -l runtime_anno_capped_testcase.zip
      Archive: runtime_anno_capped_testcase.zip
       Length Date Time Name
      --------- ---------- ----- ----
          0 08-21-2024 17:43 runtime_anno_capped_testcase/
         247 08-21-2024 17:11 runtime_anno_capped_testcase/test_annotation_array_length.sh
         2147 08-21-2024 17:17 runtime_anno_capped_testcase/AnnoPeek.java
         662 08-21-2024 17:07 runtime_anno_capped_testcase/MyClassGen.java
         243 08-21-2024 17:08 runtime_anno_capped_testcase/MyCustomAnno.java
      --------- -------
         3299 5 files

            vromero Vicente Arturo Romero Zaldivar
            lfoltan Lois Foltan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: