mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8343064: ClassFormatError: Illegal class name from InnerClassLambdaMetafactory
Reviewed-by: jvernee
This commit is contained in:
parent
4d4951a442
commit
681a57f960
3 changed files with 116 additions and 3 deletions
|
@ -185,13 +185,17 @@ import sun.invoke.util.Wrapper;
|
|||
return i < ARG_NAME_CACHE.length ? ARG_NAME_CACHE[i] : "arg$" + (i + 1);
|
||||
}
|
||||
|
||||
private static String lambdaClassName(Class<?> targetClass) {
|
||||
private static String sanitizedTargetClassName(Class<?> targetClass) {
|
||||
String name = targetClass.getName();
|
||||
if (targetClass.isHidden()) {
|
||||
// use the original class name
|
||||
name = name.replace('/', '_');
|
||||
}
|
||||
return name.replace('.', '/').concat("$$Lambda");
|
||||
return name.replace('.', '/');
|
||||
}
|
||||
|
||||
private static String lambdaClassName(Class<?> targetClass) {
|
||||
return sanitizedTargetClassName(targetClass).concat("$$Lambda");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,7 +434,7 @@ import sun.invoke.util.Wrapper;
|
|||
public void accept(CodeBuilder cob) {
|
||||
cob.new_(SerializationSupport.CD_SerializedLambda)
|
||||
.dup()
|
||||
.ldc(classDesc(targetClass))
|
||||
.ldc(ClassDesc.ofInternalName(sanitizedTargetClassName(targetClass)))
|
||||
.ldc(factoryType.returnType().getName().replace('.', '/'))
|
||||
.ldc(interfaceMethodName)
|
||||
.ldc(interfaceMethodType.toMethodDescriptorString())
|
||||
|
|
|
@ -229,6 +229,22 @@ import java.util.Objects;
|
|||
* used, but this is not compatible with some implementation techniques and
|
||||
* would complicate the work implementations must do.
|
||||
*
|
||||
* <p>Uses besides evaluation of lambda expressions and method references are
|
||||
* unintended. These linkage methods may change their unspecified behaviors at
|
||||
* any time to better suit the Java language features they were designed to
|
||||
* support, and such changes may impact unintended uses. Unintended uses of
|
||||
* these linkage methods may lead to resource leaks, or other unspecified
|
||||
* negative effects.
|
||||
*
|
||||
* @implNote In the reference implementation, the classes implementing the created
|
||||
* function objects are strongly reachable from the defining class loader of the
|
||||
* caller, like classes and interfaces in Java source code. This technique
|
||||
* reduces heap memory use, but as a consequence, the implementation classes can
|
||||
* be unloaded only if the caller class can be unloaded. In particular, if the
|
||||
* caller is a {@linkplain MethodHandles.Lookup.ClassOption#STRONG weak hidden
|
||||
* class}, the implementation class, a strong hidden class, may not be unloaded
|
||||
* even if the caller may be unloaded.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public final class LambdaMetafactory {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue