RFR: 8263763: Synthetic constructor parameters of enum are not considered for annotation indices

Rafael Winterhalter winterhalter at openjdk.java.net
Mon Mar 22 21:35:38 UTC 2021


On Mon, 22 Mar 2021 07:52:45 GMT, Tagir F. Valeev <tvaleev at openjdk.org> wrote:

>> *ejc* issues the same constructor that prefixes a `String` and an `int` parameter. I agree that the solution is not perfect, but I would prefer it over the reflection API throwing an `IndexOutOfBoundsException` upon calling `getAnnotations()`, which nobody really expects upon a getter invocation.
>> 
>> I added a check to see if the enum constructor in question starts with a `String` and `int` parameter after checking if there are two excess parameters. I believe that that's at least an improvement over today's state where it's very unlikely that an enum constructor  yields an incorrect result in the reflection API whereas the result it is always incorrect today, given the implementation of both *ejc* and *javac*.
>> 
>> Ideally, this would of course also be fixed by javac (and ejc) such that the annotations are placed on the correct indices, but I still argue that the fix is an improvement for being able to properly process enum constructors for older class files also.
>
> @raphw a duplicate? https://bugs.openjdk.java.net/browse/JDK-8246586

Yes, indeed a duplicate. I linked the issue up against the original.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3082


More information about the core-libs-dev mailing list