|
@@ -20,8 +20,6 @@ import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.SerializationUtils;
|
|
|
|
|
|
import java.io.*;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 这个类是从 {@link java.lang.invoke.SerializedLambda} 里面 copy 过来的,
|
|
@@ -76,7 +74,7 @@ public class SerializedLambda implements Serializable {
|
|
|
* @return 返回 class 名称
|
|
|
*/
|
|
|
public String getFunctionalInterfaceClassName() {
|
|
|
- return normalName(functionalInterfaceClass);
|
|
|
+ return normalizedName(functionalInterfaceClass);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -94,7 +92,7 @@ public class SerializedLambda implements Serializable {
|
|
|
* @return 类名
|
|
|
*/
|
|
|
public String getImplClassName() {
|
|
|
- return normalName(implClass);
|
|
|
+ return normalizedName(implClass);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -112,18 +110,16 @@ public class SerializedLambda implements Serializable {
|
|
|
* @param name 名称
|
|
|
* @return 正常的类名
|
|
|
*/
|
|
|
- private String normalName(String name) {
|
|
|
+ private String normalizedName(String name) {
|
|
|
return name.replace('/', '.');
|
|
|
}
|
|
|
|
|
|
- private static final Pattern INSTANTIATED_METHOD_TYPE = Pattern.compile("\\(L(?<instantiatedMethodType>[\\S&&[^;)]]+);\\)L[\\S]+;");
|
|
|
-
|
|
|
- public Class getInstantiatedMethodType() {
|
|
|
- Matcher matcher = INSTANTIATED_METHOD_TYPE.matcher(instantiatedMethodType);
|
|
|
- if (matcher.find()) {
|
|
|
- return ClassUtils.toClassConfident(normalName(matcher.group("instantiatedMethodType")));
|
|
|
- }
|
|
|
- throw ExceptionUtils.mpe("无法从 %s 解析调用实例。。。", instantiatedMethodType);
|
|
|
+ /**
|
|
|
+ * @return 获取实例化方法的类型
|
|
|
+ */
|
|
|
+ public Class getInstantiatedType() {
|
|
|
+ String instantiatedTypeName = normalizedName(instantiatedMethodType.substring(2, instantiatedMethodType.indexOf(';')));
|
|
|
+ return ClassUtils.toClassConfident(instantiatedTypeName);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -131,8 +127,12 @@ public class SerializedLambda implements Serializable {
|
|
|
*/
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
- return String.format("%s -> %s::%s", getFunctionalInterfaceClassName(), getImplClass().getSimpleName(),
|
|
|
- implMethodName);
|
|
|
+ String interfaceName = getFunctionalInterfaceClassName();
|
|
|
+ String implName = getImplClassName();
|
|
|
+ return String.format("%s -> %s::%s",
|
|
|
+ interfaceName.substring(interfaceName.lastIndexOf('.') + 1),
|
|
|
+ implName.substring(implName.lastIndexOf('.') + 1),
|
|
|
+ implMethodName);
|
|
|
}
|
|
|
|
|
|
}
|