Skip to content

Commit d08de8b

Browse files
committed
[GR-45426] Adopt lambda class name pattern introduced in the jdk21 for lambda serialization tests
PullRequest: graal/14377
2 parents fb3c14d + 0229649 commit d08de8b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/java/LambdaUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public final class LambdaUtils {
5555
private static final char[] HEX = "0123456789abcdef".toCharArray();
5656
public static final String LAMBDA_SPLIT_PATTERN;
5757
public static final String LAMBDA_CLASS_NAME_SUBSTRING;
58+
public static final String SERIALIZATION_TEST_LAMBDA_CLASS_SUBSTRING = "$$Lambda";
59+
public static final String SERIALIZATION_TEST_LAMBDA_CLASS_SPLIT_PATTERN = "\\$\\$Lambda";
5860

5961
static {
6062
if (Runtime.version().feature() < 21) {

docs/reference-manual/native-image/ReachabilityMetadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ Using this pattern has a positive side effect of improving security on the JVM a
349349

350350
Wildcard patterns do the serialization registration only for lambda-proxy classes of an enclosing class. For example, to register lambda serialization in an enclosing class `pkg.LambdaHolder` use:
351351
```java
352-
ObjectInputFilter.Config.createFilter("pkg.LambdaHolder$$Lambda$*;")
352+
ObjectInputFilter.Config.createFilter("pkg.LambdaHolder$$Lambda*;")
353353
```
354354

355355
Patterns like `"pkg.**"` and `"pkg.Prefix*"` will not perform serialization registration as they are too general and would increase image size significantly.

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/SubstrateGraphBuilderPlugins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ private static void parsePatternAndRegister(String pattern) {
324324
// Pattern is a classname (possibly empty) with a trailing wildcard
325325
final String className = p.substring(poffset, nameLen - 1);
326326
if (!negate) {
327-
if (className.endsWith(LambdaUtils.LAMBDA_CLASS_NAME_SUBSTRING)) {
327+
if (className.endsWith(LambdaUtils.SERIALIZATION_TEST_LAMBDA_CLASS_SUBSTRING)) {
328328
try {
329-
String lambdaHolderName = className.split(LambdaUtils.LAMBDA_SPLIT_PATTERN)[0];
329+
String lambdaHolderName = className.split(LambdaUtils.SERIALIZATION_TEST_LAMBDA_CLASS_SPLIT_PATTERN)[0];
330330
RuntimeSerialization.registerLambdaCapturingClass(Class.forName(lambdaHolderName, false, Thread.currentThread().getContextClassLoader()));
331331
} catch (ClassNotFoundException e) {
332332
// no class, no registration

0 commit comments

Comments
 (0)