Type annotations and this-reference (receiver) in methods
Alex Buckley
alex.buckley at oracle.com
Mon Feb 17 09:52:02 PST 2014
On 2/16/2014 12:13 PM, André Pankraz wrote:
> 2 more possible issues I found:
Thanks for continuing to report them!
> 1)
> If you compile code without debug-info, then you don't have local
> variable info with variable signatures, but you have the type
> annotations for local variables in the bytecode.
> The type pathes cannot really be applied without this info, especially
> for type arguments etc., don't know how much sense it does make to
> include them in this case?
Fair point but there is no real link between debug attributes and
reflection attributes (which is what the six Runtime*Annotations
attributes are). As we've discussed before, the
Runtime[In]VisibleTypeAnnotations attributes are rich enough to
represent annotated source constructs that are very difficult to
recreate solely from the code array; and yet, this has been good enough
for the Checker Framework.
> 2)
> If you look into the following code, then I think the Method Reference
> Type Annotations are missing the INNER path.
> Focus onto first line testInnerGenericHandles().
>
>
> public class DecTestMethodHandles {
>
> static class Test<S> extends DecTestMethodHandles {
>
> public static <T> void testStatic() {
> System.out.println("test");
> }
>
> public <T> Test() {
> System.out.println("new...");
> }
>
> public <T> void test() {
> System.out.println("test");
> }
>
> void testInnerGenericHandles() {
> Runnable r = @Nonnull Test<@Nonnull String>::<@Nonnull
> Integer> new;
> r = @Nonnull Test::<@Nonnull Integer> testStatic;
> r = new @Nonnull Test<@Nonnull String>()::<@Nonnull
> Integer> test;
> r = super::<@Nonnull String> testSimpleHandles;
> }
> ...
> }
>
>
> You get this attribute in testInnerGenericHandles():
>
> RuntimeVisibleTypeAnnotations:
> #34 @org.decojer.cavaj.test.jdk8.Nonnull(
> target type = 0x45 CONSTRUCTOR_REFERENCE
> offset = 0
> )
>
> There is no INNER path in this. According to the order how this is
> encoded in bytecode, this bytecode presents "@Nonnull
> DecTestMethodHandle.Test::new" and not "DecTestMethodHandle. at Nonnull
> Test::new" (or shorter "@Nonnull Test::new")
> Haven't tested it the type argument has same issues.
>
> May be I understood the spec wrong here and here isn't a inner type path
> necessary. It's the same topic like previous thread about INNER pathes.
This feels pretty close to the known bug in attribute generation for
annotations on nested types.
Alex
More information about the type-annotations-dev
mailing list