He-Pin opened a new pull request, #3300: URL: https://github.com/apache/pekko/pull/3300
### Motivation `java.lang.reflect` `Method.invoke`, `Constructor.newInstance`, and `Field.get`/`set` bypass JIT inlining, adding overhead in critical paths like actor instantiation, protobuf serialization, and virtual thread management. ### Modification - **ReflectiveDynamicAccess**: Replace `Constructor.newInstance` with `MethodHandle.invokeWithArguments`; replace `Field.get(null)` for `MODULE$` with `VarHandle.get` - **Reflect**: Replace `Constructor.newInstance` with `MethodHandle.invoke` for both no-arg and parameterized constructors - **VirtualThreadSupport**: Replace `Field.set`/`get` with `VarHandle.set`/`get` for scheduler and `DEFAULT_SCHEDULER` fields; replace `Constructor.newInstance` with cached `MethodHandle` for `CarrierThread` - **ProtobufSerializer**: Replace `Method`-based `parseFrom`/`toByteArray` caches with `MethodHandle` caches for serialization hot path - **LineNumbers**: Replace `Method.invoke` with `MethodHandle.invoke` for `writeReplace` lambda introspection - **ByteBufferCleaner**: Replace `Field.get(null)` with `VarHandle.get` for `theUnsafe` static field access - **ExtensionsImpl**: Replace `Method.invoke(null)` with `MethodHandle.invoke` for Java singleton `getInstance` accessor ### Result `VarHandle` and `MethodHandle` enable JIT inlining of field access, method invocation, and constructor calls across all core reflection utilities, improving performance in actor creation, serialization, and virtual thread operations. ### Tests - `sbt "actor / compile"` - success - `sbt "actor-typed / compile"` - success - `sbt "remote / compile"` - success ### References None - internal refactoring -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
