Meta-annotations are dropped from annotation types parsed from bytecode
ExtendJ 8.0.1-260-g88bcade Java SE 8
When an annotation type is loaded from bytecode, meta-annotations like RuntimeRetention
are dropped. This results in incorrect runtime retention of any occurrences of the annotation.
This happens for example when using the Parameters
annotation from JUnit4.11.
Comments (3)
-
reporter -
reporter The error is caused by modifiers (including annotations) being replaced for inner types when parsing inner class information.
The problematic line is at
java5/frontend/BytecodeAttributes.jrag:361
:if (inner_class_info.name().equals(p.classInfo.name())) { if (AbstractClassfileParser.VERBOSE) { p.println(" Class " + inner_class_name + " is inner (" + inner_name + ")"); } typeDecl.setID(inner_name); /* ----> */ typeDecl.setModifiers( AbstractClassfileParser.modifiers(inner_class_access_flags & 0x041f));
-
reporter - changed status to resolved
Fix inner types annotation bytecode parsing issue
Annotations could be dropped when parsing bytecode for inner types. This occurred because the modifiers for the inner type were replaced by the modifiers from the InnerClasses attribute.
This was an order-dependent issue: if the InnerClasses attribute was before the RuntimeVisibleAnnotations attribute or RuntimeInvisibleAnnotations attribute, then the annotations would be appended to the updated modifiers.
fixes
#256(bitbucket)→ <<cset 1c6e3bd9aeda>>
- Log in to comment
The test framework had to be updated to be able to write a regression test for this issue. The runtime classes are now compiled before running the tests, and must be linked explicitly via the classpath setting.
Added test
annotation/method_02p
for this issue: