mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8247666: Support Lambda proxy classes in static CDS archive
Reviewed-by: iklam, mchung
This commit is contained in:
parent
e2e11d3449
commit
74ac77e2b1
38 changed files with 1960 additions and 130 deletions
|
@ -25,6 +25,7 @@
|
|||
|
||||
package java.lang.invoke;
|
||||
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.org.objectweb.asm.*;
|
||||
import sun.invoke.util.BytecodeDescriptor;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
@ -263,7 +264,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
|||
*/
|
||||
private Class<?> spinInnerClass() throws LambdaConversionException {
|
||||
// include lambda proxy class in CDS archive at dump time
|
||||
if (LambdaProxyClassArchive.isDumpArchive()) {
|
||||
if (CDS.isDumpingArchive()) {
|
||||
Class<?> innerClass = generateInnerClass();
|
||||
LambdaProxyClassArchive.register(targetClass,
|
||||
samMethodName,
|
||||
|
|
|
@ -29,28 +29,6 @@ import jdk.internal.loader.BuiltinClassLoader;
|
|||
import jdk.internal.misc.CDS;
|
||||
|
||||
final class LambdaProxyClassArchive {
|
||||
private static final boolean dumpArchive;
|
||||
private static final boolean sharingEnabled;
|
||||
|
||||
static {
|
||||
dumpArchive = CDS.isDynamicDumpingEnabled();
|
||||
sharingEnabled = CDS.isSharingEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if CDS dynamic dump is enabled.
|
||||
*/
|
||||
static boolean isDumpArchive() {
|
||||
return dumpArchive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if CDS sharing is enabled.
|
||||
*/
|
||||
static boolean isSharingEnabled() {
|
||||
return sharingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the class is loaded by a built-in class loader.
|
||||
*/
|
||||
|
@ -94,7 +72,7 @@ final class LambdaProxyClassArchive {
|
|||
Class<?>[] markerInterfaces,
|
||||
MethodType[] additionalBridges,
|
||||
Class<?> lambdaProxyClass) {
|
||||
if (!isDumpArchive())
|
||||
if (!CDS.isDumpingArchive())
|
||||
throw new IllegalStateException("should only register lambda proxy class at dump time");
|
||||
|
||||
if (loadedByBuiltinLoader(caller) &&
|
||||
|
@ -125,11 +103,11 @@ final class LambdaProxyClassArchive {
|
|||
Class<?>[] markerInterfaces,
|
||||
MethodType[] additionalBridges,
|
||||
boolean initialize) {
|
||||
if (isDumpArchive())
|
||||
if (CDS.isDumpingArchive())
|
||||
throw new IllegalStateException("cannot load class from CDS archive at dump time");
|
||||
|
||||
if (!loadedByBuiltinLoader(caller) ||
|
||||
!isSharingEnabled() || isSerializable || markerInterfaces.length > 0 || additionalBridges.length > 0)
|
||||
if (!loadedByBuiltinLoader(caller) || !initialize ||
|
||||
!CDS.isSharingEnabled() || isSerializable || markerInterfaces.length > 0 || additionalBridges.length > 0)
|
||||
return null;
|
||||
|
||||
return findFromArchive(caller, invokedName, invokedType, samMethodType,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue