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

   …packed closures work in native images
   
   Two layered changes to the GROOVY-12151 packed-closure machinery (GEP-27):
   
   1. ClosureWriter now passes the three dispatch tables as constant bootstrap 
arguments (CONSTANT_MethodHandle), resolved by the VM's constant pool rather 
than a runtime Lookup.findStatic -- which under GraalVM native image demanded 
per-class reflection metadata. Verified: the tracing agent records zero 
packedDispatch entries for the new bytecode.
   
   2. GeneratedDispatcher.bootstrap keeps the LambdaMetafactory hidden-class 
adapters on a regular JVM (the JIT-inlining rationale in the class javadoc), 
but where classes cannot be defined at run time -- native image, detected per 
link so build-time class init cannot bake in the wrong answer -- it adapts the 
tables with method-handle-invoking wrappers instead: ordinary bytecode of this 
class, AOT-compiled into the image. A catch-based fallback covers AOT runtimes 
the property probe misses. -Dgroovy.packed.dispatch.handles=true forces the 
wrapper path on a JVM, for parity testing.
   
   Permanent behaviour, no user-facing flag: JVM semantics are unchanged and 
the fallback engages only where the hidden-class path cannot work. The old 
3-arg bootstrap remains for class files from earlier 6.0 snapshots.
   
   Before/after on GraalVM 25.2.4 (native-image 25.0.4): the packed repro 
previously failed with 'Classes cannot be defined at runtime ... M$$Lambda...'; 
it now runs correctly (single emitted class, 30MB image, ~12ms total run time). 
Parity + undeclared-checked-exception propagation covered by 
PackedDispatcherHandleBundleTest; all existing packed-closure suites green.


-- 
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