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

Class.arrayType should not throw IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 14, 15
    • core-libs
    • None

      The following code will throw an IllegalArgumentException:

          Class<?> c = Object.class;
          while (true) {
              c = c.arrayType();
          }

      With the following stack trace:

          Exception java.lang.IllegalArgumentException
              at Array.newArray (Native Method)
              at Array.newInstance (Array.java:78)
              at Class.arrayType (Class.java:4358)
              at (#2:1)

      Class.arrayType does not specify to throw an IllegalArgumentException.
      It's specification should be changed to allow it to throw an IllegalStateException, similar to ClassDesc.arrayType().

            jkuhn Johannes Kuhn
            jkuhn Johannes Kuhn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: