-
Bug
-
Resolution: Won't Fix
-
P3
-
15, 17, 20, 21
-
generic
-
generic
Prior to [JDK-8239384](https://bugs.openjdk.org/browse/JDK-8239384)/[JDK-8238358](https://bugs.openjdk.org/browse/JDK-8238358) LambdaMetaFactory has created VM-anonymous classes which could easily be unloaded once they were not referenced any more. Starting with JDK 15 and the new "hidden class" based implementation, this is not the case any more, because the hidden classes will be strongly tied to their defining class loader. If this is the default application class loader, these hidden classes can never be unloaded which can easily lead to Metaspace exhaustion (see attached test case contributed by Oli Gillespie / Amazon Corretto). This is a regression compared to previous JDK versions which some of our applications have been affected from when migrating to JDK 17.
The reason why the newly created hidden classes are strongly linked to their defining class loader is not clear to me.JDK-8239384 mentions it as an "implementation detail":
4. the lambda proxy class has the strong relationship with the class loader (that will share the VM metaspace for its defining loader - implementation details)
From my current understanding the strong link between a hidden class created by `LambdaMetaFactory` and its defining class loader is not strictly required. In order to prevent potential OOMs and fix the regression compared the JDK 14 and earlier I propose to create these hidden classes without the `STRONG` option.
This issue has been reported by Zoe Wang / Amazon.
The reason why the newly created hidden classes are strongly linked to their defining class loader is not clear to me.
4. the lambda proxy class has the strong relationship with the class loader (that will share the VM metaspace for its defining loader - implementation details)
From my current understanding the strong link between a hidden class created by `LambdaMetaFactory` and its defining class loader is not strictly required. In order to prevent potential OOMs and fix the regression compared the JDK 14 and earlier I propose to create these hidden classes without the `STRONG` option.
This issue has been reported by Zoe Wang / Amazon.
- relates to
-
JDK-8239384 Convert LambdaMetaFactory to create hidden classes
- Resolved
- links to
-
Review openjdk/jdk/12493