Skip to content

Commit

Permalink
Fix support of lambda objects for Java 21 and above. Closes #349.
Browse files Browse the repository at this point in the history
  • Loading branch information
toby1984 authored and joehni committed Oct 18, 2024
1 parent 482159b commit 30c0bdb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions xstream-distribution/src/content/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h2>Minor changes</h2>
<li>GHPR:#331, GHI:#326: Fix handling of empty java.util.concurrent.atomic.AtomicReference (by Alex Blekhman of Atlassian).</li>
<li>GHPR:#334: Fix remaining buffer size calculation in QuickWriter (by Higuchi Yuta).</li>
<li>GHI:#342: Optimize internal handling of children in DomReader avoiding O(n²) access times for siblings (by Shiang-Yun Yang).</li>
<li>GHPR:#349: Fix support of lambda objects for Java 21 and above (Tobias Gierke).</li>
<li>GHI:#359: Add KEYS file with public keys to verify signed artifacts.</li>
<li>Detect input manipulation in c.t.x.io.binary.BinaryStreamReader.</li>
</ul>
Expand Down
11 changes: 7 additions & 4 deletions xstream/src/java/com/thoughtworks/xstream/core/util/Types.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 XStream Committers.
* Copyright (C) 2015, 2024 XStream Committers.
* All rights reserved.
*
* Created on 17. January 2015 by Joerg Schaible
Expand All @@ -16,10 +16,13 @@
* @since 1.4.8
*/
public class Types {
private static final Pattern lambdaPattern = Pattern.compile(".*\\$\\$Lambda\\$[0-9]+/.*");
private static final Pattern lambdaPattern = Pattern.compile(".*\\$\\$Lambda(?:\\$[0-9]+|)/.*");

public static final boolean isLambdaType(final Class<?> type) {
return type != null && type.isSynthetic() && lambdaPattern.matcher(type.getSimpleName()).matches();
if (type != null && type.isSynthetic()) {
final String typeName = type.getSimpleName();
return lambdaPattern.matcher(typeName).matches();
}
return false;
}

}

0 comments on commit 30c0bdb

Please sign in to comment.