JDK-8263763 : Synthetic constructor parameters of enum are not considered for annotation indices
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2021-03-17
  • Updated: 2021-04-19
  • Resolved: 2021-04-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b18Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
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
Comments
Changeset: 9dd96257 Author: Rafael Winterhalter <winterhalter@openjdk.org> Committer: Joe Darcy <darcy@openjdk.org> Date: 2021-04-12 21:01:08 +0000 URL: https://git.openjdk.java.net/jdk/commit/9dd96257
12-04-2021

Reopening to support active code review; will close out the other bug.
09-04-2021