-
Bug
-
Resolution: Fixed
-
P3
-
16
-
b07
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8260386 | 16.0.1 | Harold Seigel | P3 | Resolved | Fixed | b03 |
From: MRasmussen@perforce.com:
Retransforming or redefining a sealed class can lead to a JVMTI_ERROR_FAILS_VERIFICATION, with Exception <a 'java/lang/IncompatibleClassChangeError'{0x00000000feb820a0}: class autotest.TransparentRectangle cannot inherit from sealed class autotest.Rectangle> (0x00000000feb820a0), even though the class actually does that.
I've tried to investigate the reason, and from what I can tell, it boils down to the check in InstanceKlass::has_as_permitted_subclass.
In jdk-16+27, this method always seems to take the Symbol branch (_constants->tag_at(cp_index).is_klass() is false).
But for jdk-16+28, it takes the Klass branch after the classes are loaded, and from what I can tell the (k2 == k) comparison can then fail during the redefinition since the Klass stored in the _permitted_subclasses is not the same as the one being verified, as a new InstanceKlass is allocated for the stream parser.
Unfortunately, I haven't been able to produce a small self-contained test example, but I can reliably reproduce it while developing JRebel (which utilizes class retransformation), but hopefully the above is at least helpful in finding the issue and fixing it.
/Michael
Retransforming or redefining a sealed class can lead to a JVMTI_ERROR_FAILS_VERIFICATION, with Exception <a 'java/lang/IncompatibleClassChangeError'{0x00000000feb820a0}: class autotest.TransparentRectangle cannot inherit from sealed class autotest.Rectangle> (0x00000000feb820a0), even though the class actually does that.
I've tried to investigate the reason, and from what I can tell, it boils down to the check in InstanceKlass::has_as_permitted_subclass.
In jdk-16+27, this method always seems to take the Symbol branch (_constants->tag_at(cp_index).is_klass() is false).
But for jdk-16+28, it takes the Klass branch after the classes are loaded, and from what I can tell the (k2 == k) comparison can then fail during the redefinition since the Klass stored in the _permitted_subclasses is not the same as the one being verified, as a new InstanceKlass is allocated for the stream parser.
Unfortunately, I haven't been able to produce a small self-contained test example, but I can reliably reproduce it while developing JRebel (which utilizes class retransformation), but hopefully the above is at least helpful in finding the issue and fixing it.
/Michael
- backported by
-
JDK-8260386 InstanceKlass::has_as_permitted_subclass() fails if subclass was redefined
- Resolved