paulk-asert opened a new pull request, #2679:
URL: https://github.com/apache/groovy/pull/2679

   A statically compiled lambda targeting a functional interface currently 
generates a per-lambda class extending groovy.lang.Closure, even though its 
runtime value is a LambdaMetafactory-produced functional-interface instance and 
(when non-capturing) a zero-allocation singleton. The generated class only 
holds a static doCall.
   
   Like the JVM does for Java lambdas, hoist the body of a non-capturing, 
non-serializable SAM lambda into a private static method on the enclosing class 
and bootstrap LambdaMetafactory directly against it, so no per-lambda class is 
generated. Capturing, instance-accessing, serializable and nested cases are 
unchanged (they keep the generated lambda class).
   
   Behaviour is preserved (verified: Predicate/BiFunction, lambdas in static 
methods, qualified outer static calls, serializable round-trips, singleton 
identity); stack traces now name a $lambda$ method on the enclosing class 
(Java-like).
   
   Gated by an opt-in system property, groovy.target.lambda.hoist (default 
off), read per lambda so it can be toggled without a JVM restart, while 
IDE/tooling compatibility with the changed generated-class shape is verified. 
Default off keeps existing behaviour and tests unchanged.
   
   See GEP-27 (Compact Closure and Lambda Compilation) for the broader design.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to