Possible wrong class type parameter type annotation index
My test case class is
public class TestTypeAnnotationOnClassTypeparamWildcard1<
@TypeAnno00 T_EXT_INTERSECTION extends
@TypeAnno01 java.util.List<
@TypeAnno02 String > &
@TypeAnno03 Iterable<
@TypeAnno04 String > &
@TypeAnno05 Serializable
>
{
}
I parse the class file of the java file above with ASM 5.1 AsmDomClassVisitor.
Here a part of my overriding visitTypeAnnotation method:
@Override
public AnnotationVisitor visitTypeAnnotation(
final int typeRef ,
final TypePath typePath ,
final String desc ,
final boolean visibleAtRuntime )
{
System.out.println( ( "typeRef: " + typeRef + " typePath: " + typePath + "
desc: " + desc + " visibleAtRuntime: " + visibleAtRuntime );
System.out.println( DebugUtil.intToBinaryStringWithGroup6( typeRef ) );
System.out.println( Integer.toBinaryString( ( typeRef >>> 24 ) ) );
System.out.println( "typeRef CLASS_TYPE_PARAMETER " + ( ( typeRef >>>
24 ) == TypeReference.CLASS_TYPE_PARAMETER ) );
System.out.println( "typeRef CLASS_EXTENDS " + ( ( typeRef >>>
24 ) == TypeReference.CLASS_EXTENDS ) );
System.out.println( "typeRef CLASS_TYPE_PARAMETER_BOUND " + ( ( typeRef >>>
24 ) == TypeReference.CLASS_TYPE_PARAMETER_BOUND ) );
if ( ( typeRef >>> 24 ) == TypeReference.CLASS_TYPE_PARAMETER )
{
final int typeParameterIndex = new TypeReference( typeRef
).getTypeParameterIndex();
System.out.println( "typeParameterIndex " + typeParameterIndex );
}
if ( ( typeRef >>> 24 ) == TypeReference.CLASS_TYPE_PARAMETER_BOUND )
{
final int typeParameterIndex = new TypeReference( typeRef
).getTypeParameterIndex();
System.out.println( "typeParameterIndex " + typeParameterIndex );
final int typeParameterBoundIndex = new TypeReference( typeRef
).getTypeParameterBoundIndex();
System.out.println( "typeParameterBoundIndex " + typeParameterBoundIndex );
}
Following output occurs:
typeRef: 0 typePath: null desc: LTypeAnno00; visibleAtRuntime: true
00000000 00000000 00000000 00000000
0
typeRef CLASS_TYPE_PARAMETER true
typeRef CLASS_EXTENDS false
typeRef CLASS_TYPE_PARAMETER_BOUND false
typeParameterIndex 0
typeRef: 285212928 typePath: null desc: LTypeAnno01; visibleAtRuntime: true
00010001 00000000 00000001 00000000
10001
typeRef CLASS_TYPE_PARAMETER false
typeRef CLASS_EXTENDS false
typeRef CLASS_TYPE_PARAMETER_BOUND true
typeParameterIndex 0
typeParameterBoundIndex 1
typeRef: 285212928 typePath: 0; desc: LTypeAnno02; visibleAtRuntime: true
00010001 00000000 00000001 00000000
10001
typeRef CLASS_TYPE_PARAMETER false
typeRef CLASS_EXTENDS false
typeRef CLASS_TYPE_PARAMETER_BOUND true
typeParameterIndex 0
typeParameterBoundIndex 1
typeRef: 285213184 typePath: null desc: LTypeAnno03; visibleAtRuntime: true
00010001 00000000 00000010 00000000
10001
typeRef CLASS_TYPE_PARAMETER false
typeRef CLASS_EXTENDS false
typeRef CLASS_TYPE_PARAMETER_BOUND true
typeParameterIndex 0
typeParameterBoundIndex 2
typeRef: 285213184 typePath: null desc: LTypeAnno04; visibleAtRuntime: true
00010001 00000000 00000010 00000000
10001
typeRef CLASS_TYPE_PARAMETER false
typeRef CLASS_EXTENDS false
typeRef CLASS_TYPE_PARAMETER_BOUND true
typeParameterIndex 0
typeParameterBoundIndex 2
typeRef: 285213440 typePath: null desc: LTypeAnno05; visibleAtRuntime: true
00010001 00000000 00000011 00000000
10001
typeRef CLASS_TYPE_PARAMETER false
typeRef CLASS_EXTENDS false
typeRef CLASS_TYPE_PARAMETER_BOUND true
typeParameterIndex 0
typeParameterBoundIndex 3
The typeParameterBoundIndex for TypeAnno01 starts with 1, not with 0.
Is this correct?
Thanks
Heiner