Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8207198

Parsing annotations depends on internal VM constant pool


    • Type: Enhancement
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:


      Annotation processing depends on a version of the constant pool that can change due to redefinition. It works now because the implementation in the JVM extends the original constant pool so that the indices loaded before redefinition will still be present in the redefined class. If it weren't for this detail, it would fail.

          private AnnotationData createAnnotationData(int classRedefinedCount) {
              Map<Class<? extends Annotation>, Annotation> declaredAnnotations =
                  AnnotationParser.parseAnnotations(getRawAnnotations(), getConstantPool(), this);

      If there is a redefinition between getRawAnnotations() and getConstantPool() above, the annotation array would not match up to the original indices in the constant pool if constant pool merging is ever removed, which I wanted to do.

      The jdk.internal.reflect.ConstantPool instance points to the newest ConstantPool now. With some work, it could point to the original constant pool. But then, I don't know how to solve this problem. The Java code shouldn't point directly to any JVM internals. Maybe it should call the JVM with the index into the annotation array rather than an index into the constant pool, and throw/catch an exception if the class has been redefined, or move the parsing code into the JVM where it can tell if the class is redefined.


          Issue Links



              • Assignee:
                coleenp Coleen Phillimore
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: