JDK-8294960 : Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-10-07
  • Updated: 2024-10-22
  • Resolved: 2024-06-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b03Fixed
Related Reports
Blocks :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
classes using ASM library in java.lang.invoke package are:
- ClassSpecializer
- GenerateJLIClassesHelper
- InnerClassLambdaMetafactory
- InvokerBytecodeGenerator
- MethodHandleImpl
- MethodHandles
- TypeConvertingMethodAdapter
Comments
We are seeing a new ClassCastException after this change. Not sure if the behavioral change is intentional, but I have filed JDK-8335060 with a simple reproducer.
25-06-2024

Hi Adam, since this change we get a bunch of test failures on big endian platforms (see JDK-8334872) because of StackOverflowError. Are there parts that need to be adapted for big endian platforms? Thanks, Richard.
24-06-2024

I'm not familiar with `redefineagent.jar`, however from the stack trace I see `InvokerBytecodeGenerator`, which was redesigned by this change.
21-06-2024

Does this change influence the redefineagent.jar used in test serviceability/jvmti/RedefineClasses/RedefineLeakThrowable.java#id0 ? Today we start to see Metaspace OOMs in this test on AIX (the test uses a -XX:MetaspaceSize=23m and is known to be close to this setting so a small increase in consumption could trigger the MetaSpace OOM). Example OOM : Caused by: java.lang.OutOfMemoryError: Metaspace at java.base/java.lang.ClassLoader.defineClass0(Native Method) at java.base/java.lang.System$2.defineClass(System.java:2476) at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2480) at java.base/java.lang.invoke.InvokerBytecodeGenerator.loadMethod(InvokerBytecodeGenerator.java:255) at java.base/java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(InvokerBytecodeGenerator.java:533) at java.base/java.lang.invoke.LambdaForm.compileToBytecode(LambdaForm.java:855) at java.base/java.lang.invoke.LambdaForm.customize(LambdaForm.java:474) at java.base/java.lang.invoke.MethodHandle$1.apply(MethodHandle.java:1858) at java.base/java.lang.invoke.MethodHandle$1.apply(MethodHandle.java:1856) at java.base/java.lang.invoke.MethodHandle.updateForm(MethodHandle.java:1878) at java.base/java.lang.invoke.MethodHandle.customize(MethodHandle.java:1856) at java.base/java.lang.invoke.MethodHandle.maybeCustomize(MethodHandle.java:1846) at java.base/java.lang.invoke.Invokers.maybeCustomize(Invokers.java:632) at java.base/java.lang.invoke.Invokers.checkCustomized(Invokers.java:626) at java.base/java.lang.invoke.LambdaForm$MH/0x0000000680082800.invokeExact_MT(LambdaForm$MH) at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.invokeImpl(DirectConstructorHandleAccessor.java:86) at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:501) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:485) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:785) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:725) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1397) at java.compiler@24-internal/javax.tools.ToolProvider.getSystemTool(ToolProvider.java:120) at java.compiler@24-internal/javax.tools.ToolProvider.getSystemJavaCompiler(ToolProvider.java:62) at jdk.test.lib.compiler.InMemoryJavaCompiler.getCompiler(InMemoryJavaCompiler.java:199) at jdk.test.lib.compiler.InMemoryJavaCompiler.compile(InMemoryJavaCompiler.java:187) at RedefineClassHelper.redefineClass(RedefineClassHelper.java:50) at RedefineLeakThrowable.main(RedefineLeakThrowable.java:80) at java.base/java.lang.invoke.LambdaForm$DMH/0x000000068008e800.invokeStatic(LambdaForm$DMH) at java.base/java.lang.invoke.LambdaForm$MH/0x000000068008fc00.invoke(LambdaForm$MH) at java.base/java.lang.invoke.LambdaForm$MH/0x0000000680090000.invokeExact_MT(LambdaForm$MH) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invokeImpl(DirectMethodHandleAccessor.java:154)
21-06-2024

Changeset: 01ee4241 Author: Adam Sotona <asotona@openjdk.org> Date: 2024-06-19 15:15:30 +0000 URL: https://git.openjdk.org/jdk/commit/01ee4241b76e78ca67803c4b083fcedecef1c96c
19-06-2024

Draft of prototype pull request: https://github.com/openjdk/jdk/pull/17108
15-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17108 Date: 2023-12-14 12:39:52 +0000
15-12-2023

This use case has been included in the Classfile API development, see: https://github.com/openjdk/jdk-sandbox/tree/classfile-api-dev-branch#use-cases
07-10-2022