Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #327: remove JDK8's internal API: ParameterizedTypeImpl #333

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/main/java/org/nebula/contrib/ngbatis/utils/ReflectUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.Arrays;
Expand All @@ -31,7 +32,6 @@
import org.nebula.contrib.ngbatis.exception.ParseException;
import org.nebula.contrib.ngbatis.models.MethodModel;
import org.springframework.util.Assert;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;

/**
* <p>反射工具类。</p>
Expand Down Expand Up @@ -559,9 +559,9 @@ public static Class<?> typeArg(Object o, Class<?> parent, int i) {
if (parent.isInterface()) {
Type[] interfaces = insClass.getGenericInterfaces();
for (Type anInterface : interfaces) {
boolean isType = anInterface instanceof ParameterizedTypeImpl;
boolean isType = anInterface instanceof ParameterizedType;
if (isType) {
ParameterizedTypeImpl paramTypeInterface = (ParameterizedTypeImpl) anInterface;
ParameterizedType paramTypeInterface = (ParameterizedType) anInterface;
boolean found = paramTypeInterface.getRawType() == parent;
if (found) {
Type[] actualTypeArguments = paramTypeInterface.getActualTypeArguments();
Expand All @@ -583,10 +583,11 @@ public static Class<?> typeArg(Object o, Class<?> parent, int i) {
* when type is not ParameterizedTypeImpl and the type name can not get class object in jvm.
*/
public static Class<?> typeToClass(Type type) throws ClassNotFoundException {
if (type instanceof ParameterizedTypeImpl) {
return ((ParameterizedTypeImpl) type).getRawType();
String typeName = type.getTypeName();
if (type instanceof ParameterizedType) {
typeName = ((ParameterizedType) type).getRawType().getTypeName();
}
return Class.forName(type.getTypeName());
return Class.forName(typeName);
}

/**
Expand Down
Loading