[type-annos-observers] some errors in the specification (january 30 version)

Eric Bruneton ebruneton at free.fr
Sun Feb 24 08:18:45 PST 2013


18/02/2013 05:56, Werner Dietl wrote:
> Hi Eric,
>
> thanks for the update!
>
> On Sun, Feb 17, 2013 at 2:22 AM, Eric Bruneton <ebruneton at free.fr> wrote:
>> FYI, I updated the type annotation implementation in the ASM branch
>> ASM_5_FUTURE, to match the latest version of the JSR. I hope it is correct,
>> but I have no reference implementation against which to test it (is there
>> one)?
>
> The reference implementation for JSR 308 is available here:
>
> http://openjdk.java.net/projects/type-annotations/
>
> It has also been recently integrated into the main TL branch and
> should be included in JDK 8 binary builds.
>
> You could compile a source program with this javac and then see
> whether ASM presents the results correctly.
> You could insert type annotations using ASM and then see whether this
> javap presents the results correctly.
>
> Please do let me know if you see any problem with the reference implementation.
> cu, WMD.

Thanks for the instructions. I downloaded the checkers framework v1.6.0, 
compiled the InterningExample.java example, and tried to read the 
resulting .class (attached) with ASM. I got an error and it seems this 
is because the annotations on the local variables are stored in a 
RuntimeVisibleTypeAnnotations attribute of the method, instead of being 
stored in a RuntimeVisibleTypeAnnotations attribute of the method's Code 
attribute (cf "Changes in JSR 308" in 
http://types.cs.washington.edu/jsr308/specification/java-annotation-design.html#class-file: 
"A type annotation is stored in a Runtime[In]visibleTypeAnnotations 
attribute on the smallest enclosing class, field, method, or Code 
structure."). Maybe I'm not using the correct version of the reference 
implementation?

Otherwise, if I remove these code annotations, and just use annotations 
on classes and methods, like

public class InterningExample<@Interned T extends ArrayList<@Interned 
?>> extends @Interned ArrayList implements @Interned Cloneable {
   public void example(@Interned String @Interned [] @Interned [] f) {
     String foo = "foo";
     String bar = "bar";
     if (foo == bar)
         System.out.println("foo == bar");

   }
   public @Interned int m(@Interned T e) {
	  return 0;
   }
}

Then I am able to read the corresponding class file with ASM (but I 
haven't tried to do read/write round trip test yet).

Eric



More information about the type-annotations-spec-comments mailing list