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

Werner Dietl wdietl at gmail.com
Sun Mar 3 10:57:59 PST 2013


Hi Eric,

> Thanks for the fix. Actually my email was wrong, I wanted to say "catch
> clauses" instead of "throws clauses". They are also using u1 in the RI and
> u2 in the specification. I hadn't noticed that throws and extends clauses
> were wrong too!

I pushed a fix:

http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/897d7844b645


> With the fix in the jvm.ClassWriter class, I can correctly read a class
> produced by javac with ASM, regenerate it via a null ASM transform, read it
> again with ASM and obtain the same output. I checked almost all kind of type

Great!


> annotations, except
> - RESOURCE_VARIABLE
> - CONSTRUCTOR_REFERENCE_RECEIVER
> - METHOD_REFERENCE_RECEIVER
> - CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
> - CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
> - METHOD_REFERENCE_TYPE_ARGUMENT
> I don't know if can generate them with langtools, if it's based on 1.7. I'm
> currently using the following test program:

The type-annotations/langtools compiler is a 1.8 compiler and you can
generate all these target types.
type-annotations/langtools and jdk8/tl/langtools both for some reason
still use 1.7 as version number.

For exampes of these target types, see:

test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java
test/tools/javac/annotations/typeAnnotations/newlocations/ResourceVariables.java

In your example I also didn't see any nested types and not very
complicated generic types.
You might want to look at this test for examples:

test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java

Thanks,
cu, WMD.

> import java.util.*;
>
>
> public class InterningExample<@Interned T extends ArrayList<@Interned ?>>
> extends @Interned ArrayList implements @Interned Cloneable {
>
>   @Interned String s;
>
>
>   public void example(@Interned String @Interned [] @Interned [] f) {
>     @Interned String foo = "foo";
>     @Interned String bar = "bar";
>     if (foo instanceof @Interned String) return;
>     if (foo == (@Interned String) bar)
>
>       System.out.println("foo == bar");
>   }
>
>   public @Interned int m(@Interned InterningExample<T> this, @Interned T e)
> {
>     return 0;
>   }
>
>   public void n() throws @Interned Exception {
>     InterningExample.<@Interned T>mm(0);
>     new @Interned ArrayList<@Interned T>();
>   }
>
>   public static <@Interned T extends ArrayList<@Interned ?>> T mm(int t) {
>     try {
>       return null;
>     } catch (@Interned Exception e) {
>     }
>     return null;
>   }
> }
>
> with
>
> import java.lang.annotation.*;
> @Documented
> @Inherited
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
> public @interface Interned {}
>
> Eric



-- 
http://www.google.com/profiles/wdietl


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