mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-17 08:25:48 +00:00
fix[storage]: Fix method referencing the same class name
This commit is contained in:
@@ -122,6 +122,11 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.1.2-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-messaging</artifactId>
|
||||
<version>5.3.20</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -34,9 +34,10 @@ public final class LambdaUtils {
|
||||
}
|
||||
// 2. 反射读取
|
||||
try {
|
||||
Method method = func.getClass().getDeclaredMethod("writeReplace");
|
||||
Class<? extends Serializable> clazz = func.getClass();
|
||||
Method method = clazz.getDeclaredMethod("writeReplace");
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
return new ReflectLambdaMeta((SerializedLambda) method.invoke(func), func.getClass().getClassLoader());
|
||||
return new ReflectLambdaMeta((java.lang.invoke.SerializedLambda) method.invoke(func), clazz.getClassLoader());
|
||||
} catch (Throwable e) {
|
||||
// 3. 反射失败使用序列化的方式读取
|
||||
return new ShadowLambdaMeta(SerializedLambda.extract(func));
|
||||
|
||||
@@ -7,11 +7,11 @@ import com.zfoo.protocol.util.StringUtils;
|
||||
* Created by hcl at 2021/5/14
|
||||
*/
|
||||
public class ReflectLambdaMeta implements LambdaMeta {
|
||||
private final SerializedLambda lambda;
|
||||
private final java.lang.invoke.SerializedLambda lambda;
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public ReflectLambdaMeta(SerializedLambda lambda, ClassLoader classLoader) {
|
||||
public ReflectLambdaMeta(java.lang.invoke.SerializedLambda lambda, ClassLoader classLoader) {
|
||||
this.lambda = lambda;
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"types": [
|
||||
{
|
||||
"name": "com.zfoo.storage.util.support.SerializedLambda"
|
||||
},
|
||||
{
|
||||
"name": "java.lang.invoke.SerializedLambda"
|
||||
},
|
||||
{
|
||||
"name": "com.zfoo.storage.util.function.Func"
|
||||
},
|
||||
{
|
||||
"name": "com.zfoo.storage.util.function.Func0"
|
||||
},
|
||||
{
|
||||
"name": "com.zfoo.storage.util.function.Func1"
|
||||
}
|
||||
],
|
||||
"lambdaCapturingTypes": [
|
||||
{
|
||||
"name": "com.zfoo.storage.util.LambdaUtils"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user