[JSR308] target_type and reference_info

Mahmood Ali mahmood at MIT.EDU
Mon Sep 22 17:09:33 EDT 2008

Hi Eugene,

Please consulate com.sun.tools.javac.jvm.writeTypeAnnotation() method  
in the langtools source code.  Each case expression corresponds almost  
identically to target_type value and the comment for each block of  
case statements signifies the category of reference_info.

The compiler differs from the specification in some minor ways:
__ Use of 'method return type' target_type
This is a compiler bug that I did not come around to fix.  Only in the  
case of annotations written on method return type after type parameter  
declarations in generic method declaration, like in the case of @B  
(and not @A):
   @A <T> @B T methodName(T t) { return t; }

In this case, @B is parsed as a type annotation to T rather than a  
regular annotation to method element, like @A.

Also, the current JSR 308 specifications omits specifying some  
reference_info.  Here is the format supported by the compiler:

::method parameter generic type - 0x0D:
   // not specified:
   u1 parameter_index;

   // specified through generic type arguments or arrays
   u2 location_length;
   u1 location[location_length];
} reference_info;

::method type arguments raw and generic type
   // not specified:
   u2 offset;
   u1 type_index;

   // And for generic or array targets:
   u2 location_length;
   u1 location[location_length];
} reference_info;

The specification has some limitations too:  It does not specify how  
to specify @A and @B uniquely: OuterClass<@A String>.InnerClass<@B  

The specification should be updated to reflect these limitations.

Unfortunately, we do not have a test suite for this functionality.

Please email us if you need more guidance or have any comments.


More information about the JSR308 mailing list