[JSR308] Receiver on field initializers

Artemus Harper subanark at gmail.com
Sun May 11 15:49:48 EDT 2008


On Sun, May 11, 2008 at 10:03 AM, Mahmood Ali <mahmood at mit.edu> wrote:

>
> No subtype rules are specified for constructors invocation (unlike other
> method invocations).


Is there any reason that constructors are treated differently than method
invocations? In my particular case the constructors need to be treated just
like method calls.


> We would appreciate it, if you explain what your goals/type system rules
> are, to see if the framework should provide a better interface!
>


My first goal is to implement a checker for a @NoEscape annotation. A
reference annotated as such cannot escape the current scope. The reference
cannot be copied to fields, inside arrays, or returned. To ensure this I
require that references annotated with @NoEscape can only invoke methods
whose receiver is @NoEscape, and can only be passed as parameters if the
parameter for the method is also @NoEscape.

Although for the first step it is not necessary that the sub typing rules be
applied via constructor invocation (since a reference without @NoEscape can
be copied to a @NoEscape reference), I plan to add an @Owner annotation that
ensures that it is the only reference to a particular value.

I assume that this kind of analysis is necessary to transition an object
from being mutable (when it's being constructed) to immutable.

-- 
Artemus Harper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/pipermail/jsr308/attachments/20080511/32a6c09e/attachment.htm 


More information about the JSR308 mailing list