-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b16
-
Verified
Test file javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java use s ClassfileTestHelper.java to catch an RuntimeInvisibleTypeAnnotationsAttribute and count annotations number like this (within pattern match in switch):
```
case RuntimeInvisibleTypeAnnotationsAttribute invtAttr -> {
List <TypeAnnotation> tAnnots = invtAttr.annotations();
tinvisibles += tAnnots.size();
allt += tAnnots.size();
}
```
When calling (RuntimeInvisibleTypeAnnotationsAttribute) invtAttr.annotations() API, there is an Index out of Bound error in the CodeImpl.getLabel.
I attached the error screenshot. Test 25 was successfully compiled but fall into error.
This is the source code snippet in CodeImpl.getLabel method (line 102).
```
@Override
public int labelToBci(Label label) {
LabelImpl lab = (LabelImpl) label;
if (lab.labelContext() != this)
throw new IllegalArgumentException(String.format("Illegal label reuse; context=%s, label=%s",
this, lab.labelContext()));
return lab.getBCI();
}
```
I checked the original test with old sun.tools.classfile API, and found the bci (which is 45) is correct. The size of LabelImpl[] (which is 37 according to the error message) generates the error.
```
case RuntimeInvisibleTypeAnnotationsAttribute invtAttr -> {
List <TypeAnnotation> tAnnots = invtAttr.annotations();
tinvisibles += tAnnots.size();
allt += tAnnots.size();
}
```
When calling (RuntimeInvisibleTypeAnnotationsAttribute) invtAttr.annotations() API, there is an Index out of Bound error in the CodeImpl.getLabel.
I attached the error screenshot. Test 25 was successfully compiled but fall into error.
This is the source code snippet in CodeImpl.getLabel method (line 102).
```
@Override
public int labelToBci(Label label) {
LabelImpl lab = (LabelImpl) label;
if (lab.labelContext() != this)
throw new IllegalArgumentException(String.format("Illegal label reuse; context=%s, label=%s",
this, lab.labelContext()));
return lab.getBCI();
}
```
I checked the original test with old sun.tools.classfile API, and found the bci (which is 45) is correct. The size of LabelImpl[] (which is 37 according to the error message) generates the error.
- relates to
-
JDK-8295058 test/langtools/tools/javac 116 test classes uses com.sun.tools.classfile library
- Resolved
-
JDK-8315447 Invalid TypeAnnotation attached to a method body
- Open