Methods that are declared to return j.u.Collection/j.u.List, but is
documented to return "... an immutable list/collection ..." would
benefit from communicating that fact using a @Immutable annotation.
> How many methods do we have that return immutable values without specifying
> an immutable return type? I can't think of any, off the top of my head.
One example: Collections2.permutations() - see
http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/Collections2.html#permutations(java.util.Collection)
Excerpt from JavaDoc:
Returns:
an immutable Collection containing all the different permutations
of the original collection.
On Apr 23, 10:04 pm, Louis Wasserman <
wasserman.lo...@gmail.com>
wrote:
> How many methods do we have that return immutable values without specifying
> an immutable return type? I can't think of any, off the top of my head.
>
> Louis Wasserman
> wasserman.lo...@gmail.comhttp://
profiles.google.com/wasserman.louis
>
>
>
>
>
>
>
> On Mon, Apr 23, 2012 at 3:03 PM, Colin Decker <
cgdec...@gmail.com> wrote:
> > That would be for methods with return types that are not @Immutable.
>
> > --
> > Colin
>
> > On Mon, Apr 23, 2012 at 3:58 PM, Raymond Rishty <
raymond.ris...@gmail.com>wrote:
>
> >> Have to be honest, I don't quite see the point of annotating methods
> >> @Immutable. If the return type is already @Immutable, why does the
> >> method need to reiterate it? The guarantee is already communicated.
>
> >> On Sun, Apr 22, 2012 at 3:54 PM, Kevin Bourrillion <
kev...@google.com>
> >> wrote:
> >> > For me, the notion of annotating immutability will only become useful
> >> once
> >> > we can also signify that a method returns an immutable object.
>
> >> > (And, I think shallow immutability should be enough.)
>
> >> > On Sun, Apr 22, 2012 at 3:37 PM, Tim Peierls <
t...@peierls.net> wrote:
>
> >> >> On Sun, Apr 22, 2012 at 9:35 AM, Tim Peierls <
t...@peierls.net> wrote:
>
> >> >>> and at no point has the fact that they do not capture the stronger
> >> claim
> >> >>> of @Immutable
>
> >> >> ... are not captured by the stronger claim ...
>
> >> >> --tim
>
> >> >> --
> >> >>
guava-...@googlegroups.com
> >> >> Project site:
http://guava-libraries.googlecode.com
> >> >> This group:
http://groups.google.com/group/guava-discuss
>
> >> >> This list is for general discussion.
> >> >> To report an issue:
> >>
http://code.google.com/p/guava-libraries/issues/entry
> >> >> To get help:
http://stackoverflow.com/questions/ask(use the tag
> >> > To get help:
http://stackoverflow.com/questions/ask(use the tag