[JSR308] Wrapper types
Artemus Harper
subanark at gmail.com
Sun Mar 2 13:39:30 EST 2008
> However, I don't understand your assertion that retrofitting "may not be
> possible". Can you please explain why?
>
> In the specific case of @ReadOnly, an inference tool (named Javarifier)
> exists. It works on source or byte codes, and it can insert the resulting
> annotations in the source code, in .class files, or in a separate file that
> can be read by a type-checker.
>
> -Mike
>
1. This would force the use Javarifier on every library that is
included. I give my library to another user, who they then have to run
Javarifier on their code and potentially any library they use as well,
even if my library is a small part of their project.
2. For other types that are defined by other users, they would
potentially need to create their own automatic annotator.
3. Does Javarifier really trace where a passed in value ends up?
Lets say you have HashSet<Object> values;
This set does not declare its elements as @ReadOnly, so you cannot put
readonly values in it. Nor should you be expected to since you could
take a value out (by iterating over it), cast it and potentially
modify it. But this set normally allows any value to be placed in it.
So, the only safe way to place a value that you have a @ReadOnly
reference to is to wrap it in a wrapper class, and unwrap it when you
take it out.
--
Artemus Harper
More information about the JSR308
mailing list