[type-annos-observers] specification example: receiver in inner constructor
Michael Ernst
mernst at cs.washington.edu
Thu Mar 14 15:50:56 PDT 2013
Roman-
Thanks for your query, and I'm sorry for overlooking it until now.
The example is correct. Your confusion perhaps stems from the definition
of "receiver". In a method, the receiver is named "this". A constructor
has no receiver, unless the constructor is in an inner class. Within an
inner class constructor, the receiver has a name such as "Outer.this" (and
"this" refers to the result).
The fact that the reference implementation fails to parse this is an error.
Sorry about that, and thanks for pointing it out! I've submitted a bug
report at https://code.google.com/p/jsr308-langtools/issues/detail?id=49
-Mike
> Subject: specification example: receiver in inner constructor
> From: "Roman Shevchenko" <roman.shevchenko at jetbrains.com>
> To: type-annotations-spec-comments at openjdk.java.net
> Date: Thu, 14 Feb 2013 14:05:55 +0100
>
> Hi!
>
> I wonder if this example of a receiver annotation is correct:
>
> class Outer {
> class Inner {
> @Result Inner(@Receiver Outer Outer.this, boolean b) { }
> }
> }
>
> It has receiver have a type Outer instead of Inner, and a syntax
> 'Outer.this' isn't understood by
> 1.8.0-ea-jsr308-nightly-h2410-20121221-b69-b00 compiler.
>
> (I'm referring to the spec from January 30, 2013 at
> http://types.cs.washington.edu/jsr308/specification/java-annotation-design.html)
>
> Thanks.
More information about the type-annotations-spec-observers
mailing list