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

Bad IllegalArgumentException message for out of range rank from ClassDesc.arrayType(int)

XMLWordPrintable

    • b14
    • generic
    • generic
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      The message computation for the `IllegalArgumentException` that’s thrown when calling `ClassDesc.arrayType(int)` in a way that results in the array type having more than 255 dimensions is incorrect.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached Java program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The message of the thrown `IllegalArgumentException` should be: “rank: 300”
      ACTUAL -
      The `IllegalArgumentException` has the message:
      ```
      Exception in thread "main" java.lang.IllegalArgumentException: rank: 100200
      at java.base/java.lang.constant.ClassDesc.arrayType(ClassDesc.java:177)
      at Test.main(Test.java:7)
      ```

      ---------- BEGIN SOURCE ----------
      import static java.lang.constant.ConstantDescs.*;

      public class Test {
      public static void main(final String... args) {
      CD_Object
      .arrayType(100)
      .arrayType(200);
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: