Skip to content

Commit d09681d

Browse files
qwangseumike.wq
andauthored
feat(#lambda): support jdk21 (#9)
Co-authored-by: mike.wq <[email protected]>
1 parent ad4ec91 commit d09681d

File tree

13 files changed

+43
-18
lines changed

13 files changed

+43
-18
lines changed

app-stream-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>open-app-stream-client</artifactId>
77
<groupId>com.dingtalk.open</groupId>
8-
<version>1.3.0</version>
8+
<version>1.3.1</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

app-stream-api/src/main/java/com/dingtalk/open/app/api/common/LambdaUtils.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.dingtalk.open.app.api.DingTalkAppError;
44
import com.dingtalk.open.app.api.OpenDingTalkAppException;
5+
import com.dingtalk.open.app.api.util.JavaVersionUtil;
56

67
import java.lang.invoke.SerializedLambda;
78
import java.lang.reflect.Method;
@@ -18,7 +19,9 @@
1819
* @date 2023/3/19
1920
*/
2021
public class LambdaUtils {
21-
private static final Pattern LAMBDA_PATTERN = Pattern.compile(".*\\$\\$Lambda\\$[0-9]+/.*");
22+
private static final Pattern LAMBDA_PATTERN_JDK8_20 = Pattern.compile(".*\\$\\$Lambda\\$[0-9]+/.*");
23+
24+
private static final Pattern LAMBDA_PATTERN_JDK_21 = Pattern.compile(".*\\$\\$Lambda/.*");
2225

2326
private static final Pattern PARAMETER_TYPE_PATTERN = Pattern.compile("\\((.*)\\).*");
2427

@@ -28,9 +31,12 @@ public static boolean isLambda(Object obj) {
2831
if (obj == null) {
2932
return false;
3033
}
31-
32-
if (obj.getClass().isSynthetic() && LAMBDA_PATTERN.matcher(obj.getClass().getSimpleName()).matches()) {
33-
return true;
34+
if (obj.getClass().isSynthetic()) {
35+
if (JavaVersionUtil.getMainVersion() < 21) {
36+
return LAMBDA_PATTERN_JDK8_20.matcher(obj.getClass().getSimpleName()).matches();
37+
} else {
38+
return LAMBDA_PATTERN_JDK_21.matcher(obj.getClass().getSimpleName()).matches();
39+
}
3440
}
3541
return false;
3642
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.dingtalk.open.app.api.util;
2+
3+
/**
4+
* @author feiyin
5+
* @date 2024/3/15
6+
*/
7+
public class JavaVersionUtil {
8+
9+
10+
public static Integer getMainVersion() {
11+
String getVersion = System.getProperty("java.version");
12+
String[] version = getVersion.split("\\.");
13+
if (version[0].equalsIgnoreCase("1")) {
14+
return Integer.parseInt(version[1]);
15+
} else {
16+
return Integer.parseInt(version[0]);
17+
}
18+
}
19+
}

app-stream-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>open-app-stream-client</artifactId>
7-
<version>1.3.0</version>
7+
<version>1.3.1</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

1111
<artifactId>app-stream-client</artifactId>
1212
<packaging>jar</packaging>
13-
<version>1.3.0</version>
13+
<version>1.3.1</version>
1414
<name>app-stream-client</name>
1515

1616
<dependencies>

app-stream-network/app-stream-network-api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.0</version>
7+
<version>1.3.1</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

1111
<artifactId>app-stream-network-api</artifactId>
12-
<version>1.3.0</version>
12+
<version>1.3.1</version>
1313
<packaging>jar</packaging>
1414

1515
<name>app-stream-network-api</name>

app-stream-network/app-stream-network-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.0</version>
7+
<version>1.3.1</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

app-stream-network/app-stream-network-rsocket/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.0</version>
7+
<version>1.3.1</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

app-stream-network/app-stream-network-ws/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.0</version>
7+
<version>1.3.1</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

app-stream-network/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>open-app-stream-client</artifactId>
77
<groupId>com.dingtalk.open</groupId>
8-
<version>1.3.0</version>
8+
<version>1.3.1</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<packaging>pom</packaging>

app-stream-protocol/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.dingtalk.open</groupId>
88
<artifactId>open-app-stream-client</artifactId>
9-
<version>1.3.0</version>
9+
<version>1.3.1</version>
1010
</parent>
1111

1212
<artifactId>app-stream-protocol</artifactId>

0 commit comments

Comments
 (0)