HHH-15624 java.lang.ClassCastException: class sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to class java.lang.reflect.ParameterizedType when using generics and Wildcard
This commit is contained in:
parent
8f2c3cc615
commit
385926e61b
|
@ -14,6 +14,7 @@ import java.lang.reflect.Member;
|
|||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.WildcardType;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
import jakarta.persistence.Transient;
|
||||
|
@ -23,7 +24,6 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.PropertyNotFoundException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl;
|
||||
import org.hibernate.property.access.spi.Getter;
|
||||
|
@ -867,6 +867,9 @@ public final class ReflectHelper {
|
|||
else if ( type instanceof ParameterizedType ) {
|
||||
return (Class<T>) ( (ParameterizedType) type ).getRawType();
|
||||
}
|
||||
else if ( type instanceof WildcardType ) {
|
||||
return getClass( ( (WildcardType) type ).getUpperBounds()[0] );
|
||||
}
|
||||
throw new UnsupportedOperationException( "Can't get java type class from type: " + type );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
package org.hibernate.type.descriptor.java.spi;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.annotations.Immutable;
|
||||
import org.hibernate.annotations.Mutability;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.type.descriptor.java.EnumJavaType;
|
||||
|
@ -106,14 +106,6 @@ public class RegistryHelper {
|
|||
}
|
||||
|
||||
private <J> Class<J> determineJavaTypeClass(Type javaType) {
|
||||
final Class<J> javaTypeClass;
|
||||
if ( javaType instanceof Class<?> ) {
|
||||
javaTypeClass = (Class<J>) javaType;
|
||||
}
|
||||
else {
|
||||
final ParameterizedType parameterizedType = (ParameterizedType) javaType;
|
||||
javaTypeClass = (Class<J>) parameterizedType.getRawType();
|
||||
}
|
||||
return javaTypeClass;
|
||||
return ReflectHelper.getClass( javaType );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue