OpenJDK / amber / amber
changeset 57894:2a8a54468aae amber-demo-II
Automatic merge with records-and-sealed
author | mcimadamore |
---|---|
date | Wed, 09 Oct 2019 04:05:58 +0000 |
parents | fd9176455f5e 2e54665b87b7 |
children | d5e639d4a145 |
files | |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/reflect/RecordComponent.java Tue Oct 08 21:05:54 2019 +0000 +++ b/src/java.base/share/classes/java/lang/reflect/RecordComponent.java Wed Oct 09 04:05:58 2019 +0000 @@ -144,7 +144,7 @@ this, getDeclaringClass(), getGenericType(), - TypeAnnotation.TypeAnnotationTarget.RECORD_COMPONENT); + TypeAnnotation.TypeAnnotationTarget.FIELD); } /**
--- a/test/langtools/tools/javac/records/RecordReflectionTest.java Tue Oct 08 21:05:54 2019 +0000 +++ b/test/langtools/tools/javac/records/RecordReflectionTest.java Wed Oct 09 04:05:58 2019 +0000 @@ -103,6 +103,15 @@ record TypeAnnotatedRec(@TYPE_USE int i) {} public void testTypeAnnotationsInRecordComp() throws Throwable { - // there is a bug in type annotations, not getting to the record component + Class<?> recordClass = TypeAnnotatedRec.class; + RecordComponent rc = recordClass.getRecordComponents()[0]; + AnnotatedType at = rc.getAnnotatedType(); + Annotation[] annos = at.getAnnotations(); + assertEquals(annos.length, 1); + assertEquals(annos[0].toString(), "@RecordReflectionTest$TYPE_USE()"); + + Field f = recordClass.getDeclaredField("i"); + assertEquals(f.getAnnotatedType().getAnnotations().length, 1); + assertEquals(f.getAnnotatedType().getAnnotations()[0].toString(), annos[0].toString()); } }