-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
None
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.
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.
- blocks
-
JDK-8155673 Remove constant pool merging for class redefinition
- Closed