[JSR308] Creating new annotated types.

Artemus Harper subanark at gmail.com
Wed Nov 12 08:59:21 EST 2008


I think the reason the return type and parameter types are 'linked' is due
to a bug in the framework with respect to generics. You will probably find
that the return type and parameter types are not linked if you do not use
generics. There is some ambiguity when using generics e.g.:

<T> void method(@A1 T param1, @A2 T param2, T param2) { ... }

what is the expected resolution when the method is invoked like:
this.<@A3 String>method("param1","param2","param3");

it could be:
void method(@A1 @A3 String param1, @A1 @A3 String param2, @A3 String param3)
or
void method(@A3 String param1, @A3 String param2, @A3 String param3)
or
void method(@A1 String param1, @A2 param2, @A3 String param3)
or even something else depending on the qualifier hierarchy.

On Wed, Nov 12, 2008 at 2:19 AM, Niko Matsakis <niko at alum.mit.edu> wrote:

> Hello,
>
> I am having some trouble finding the best way to introduce a
> particular feature into my checker.  I would like to have a special
> static method that is recognized by my type checker (essentially
> emulating a keyword).  This method is called "free()" and is declared
> as a static method.  When this method is invoked, the
> AnnotatedTypeFactory needs to make special changes to the type.
>
> Unfortunately, I find it very hard to manipulate
> AnnotatedTypeMirrors.  It's relatively easy to add or remove
> annotations, but to make other sorts of changes seems to be next to
> impossible.  Most of the required methods are either only available
> within the package or simply not available.  In my case, the method is
> declared as:
>
>        public static <X> X free(X ptr) { return ptr; }
>
> What I want to do is to change the annotations on the return type.
> Because the return type and the argument type are linked, however, any
> changes I make there are also reflected on the parameter type, which
> is no good.  Ideally, what I'd like to do is simply to create a brand
> new executable type with the required values, but I can't do that
> without modifying the framework.  The constructor, after all, is
> package protected, as is setReturnType().
>
> I like the idea of immutable AnnotatedTypeMirrors, so rather than make
> the mutators public, I am currently adding a deep cloning visitor to
> the framework that should solve my problem.  It does a deep clone of a
> type with appropriate overloadable methods at each point.  However, I
> thought I'd fire off an e-mail in case I'm missing some obvious way of
> doing things.
>
>
> Niko
>
> _______________________________________________
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/jsr308
>



-- 
Artemus Harper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/pipermail/jsr308/attachments/20081112/377dd3be/attachment.htm 


More information about the JSR308 mailing list