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

Synthetic constructor parameters of enum are not considered for annotation indices

XMLWordPrintable

      javac places annotations for an enum on the wrong index. Considering:

      enum SampleEnum {
        INSTANCE("foo");
        SampleEnum(@SampleAnnotation String value) { }
      }

      @Retention(RetentionPolicy.RUNTIME)
      @interface SampleAnnotation { }

      the following code yields an exception:

      Constructor<?> c = SampleAnnotation.class.getDeclaredConstructors()[0];
      c.getParameters()[2].getAnnotations(); // throws IndexOutOfBoundsException

            winterhalter Rafael Winterhalter
            winterhalter Rafael Winterhalter
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: