RFR: JDK-8267936: PreserveAllAnnotations option isn't tested

Peter Levart plevart at openjdk.java.net
Wed Jun 2 12:36:27 UTC 2021


On Tue, 1 Jun 2021 09:30:40 GMT, Jaroslav Tulach <github.com+26887752+JaroslavTulach at openjdk.org> wrote:

> There doesn't seem to be much support for the complete changes in #4245. To get at least something useful from that endeavor I have extracted the test for existing behavior of `-XX:+PreserveAllAnnotations` and I am offering it in this pull request without any changes to the JVM behavior.

I suggest the following patch for the bug in AnnotationParser:


Index: src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java b/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java
--- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java	(revision b4371e9bcaa1c8aa394b5eca409c5afc669cc146)
+++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java	(date 1622636986705)
@@ -116,6 +116,7 @@
         Map<Class<? extends Annotation>, Annotation> result =
             new LinkedHashMap<Class<? extends Annotation>, Annotation>();
         ByteBuffer buf = ByteBuffer.wrap(rawAnnotations);
+        for (int round = 0; round < 2 && buf.hasRemaining(); round++) {
         int numAnnotations = buf.getShort() & 0xFFFF;
         for (int i = 0; i < numAnnotations; i++) {
             Annotation a = parseAnnotation2(buf, constPool, container, false, selectAnnotationClasses);
@@ -128,6 +129,7 @@
             }
         }
         }
+        }
         return result;
     }

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

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


More information about the core-libs-dev mailing list