brian.goetz at oracle.com
Thu Apr 18 12:16:04 PDT 2013
> Predicate<String> isNull = Objects::isNull;
> On performance: I'm sure Guava is optimized so that its methods
> always return a singleton. In principle, the semantics of lambdas
> and method references are abstract enough that you shouldn't have to
> worry about that. In practice, I wouldn't expect clever
> optimizations like that (e.g., turning every "x -> true" into the
> same object) in the near future.
TO be clear: with our implementation, every invocation of the *statement*
Predicate<String> p = () -> true;
always does return the same object. What Dan is talking about is
something different; if two places in the code have "equivalent"
lambdas, whether they would be "interned".
More information about the lambda-dev