New

Mark Thornton mthornton at optrak.co.uk
Mon Mar 29 02:53:15 PDT 2010


Howard Lovatt wrote:
> 3. The main argument for not using new is that the compiler can 'lift' the
> lambda to be static if it doesn't access any instance fields or local
> variables. However this type of optimization has a poor history in Java,
> think String interning and copying of static fields. In Java a JVM
> optimization has proven much more successful than a compiler optimization.
> Hence using new, which would allow a JVM optimization but prevent a compiler
> optimization, is the best choice.
>   
On the other hand the JVM optimisations (escape analysis) to reduce heap 
allocation have been "coming soon" for more years than I care to remember.

Mark



More information about the lambda-dev mailing list