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

Rafael Winterhalter winterhalter at openjdk.java.net
Sat Apr 10 20:23:01 UTC 2021


On Fri, 9 Apr 2021 21:27:24 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> Rafael Winterhalter has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.
>
> src/java.base/share/classes/java/lang/reflect/Constructor.java line 612:
> 
>> 610:         Class<?> declaringClass = getDeclaringClass();
>> 611:         if (
>> 612:             declaringClass.isEnum()
> 
> Please format as
> if (declaringClass.isEnum()) {
> ...

Changed the formatting.

> test/jdk/java/lang/annotation/EnumConstructorAnnotation.java line 39:
> 
>> 37:     public static void main(String[] args) {
>> 38:         Constructor<?> c = SampleEnum.class.getDeclaredConstructors()[0];
>> 39:         Annotation[] a = c.getParameters()[2].getAnnotations();
> 
> The value of c.getParameters().getAnnotations() can be checked for consistency against c.getParameterAnnotations(). (The type java.lang.reflect.Parameter was added several releases after annotations were added.)

I added a test for both approaches.

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

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


More information about the core-libs-dev mailing list