Wolfgang Seifert (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=635f717...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzU3NmE2ZmZm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15710?atlOrigin=eyJpIjoiNzU3Nm...
) HHH-15710 (
https://hibernate.atlassian.net/browse/HHH-15710?atlOrigin=eyJpIjoiNzU3Nm...
) ReflectHelper and RegistryHelper do not handle generic types correctly (
https://hibernate.atlassian.net/browse/HHH-15710?atlOrigin=eyJpIjoiNzU3Nm...
)
Issue Type: Bug Affects Versions: 6.1.5 Assignee: Unassigned Components: hibernate-core
Created: 11/Nov/2022 23:26 PM Environment: hibernate 6.1.5 orm, jdk 17 Priority: Major
Reporter: Wolfgang Seifert (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=635f717...
)
This issue is a result of further investigating
https://hibernate.atlassian.net/browse/HHH-15646 (
https://hibernate.atlassian.net/browse/HHH-15646 ). The Exceptions are thrown from
ReflectHelper and RegistryHelper.
Changing ReflectHelper to
public static <T> Class<T> getClass(java.lang.reflect.Type type) {
if ( type == null ) {
return null;
}
else if ( type instanceof Class<?> ) {
return (Class<T>) type;
}
else if ( type instanceof TypeVariable<?>) {
return getClass( ( (TypeVariable) type ).getBounds()[0]);
}
else if ( type instanceof ParameterizedType ) {
return (Class<T>) ( (ParameterizedType) type ).getRawType();
}
throw new UnsupportedOperationException( "Can't get java type class from type:
" + type );
}
and RegistryHelper to
private <J> Class<J> determineJavaTypeClass(Type javaType) {
final Class<J> javaTypeClass;
if ( javaType instanceof Class<?> ) {
javaTypeClass = (Class<J>) javaType;
}
else if ( javaType instanceof TypeVariable<?>){
final TypeVariable typeVariable = (TypeVariable) javaType;
javaTypeClass = determineJavaTypeClass(typeVariable.getBounds()[0]);
}
else {
final ParameterizedType parameterizedType = (ParameterizedType) javaType;
javaTypeClass = (Class<J>) parameterizedType.getRawType();
}
return javaTypeClass;
}
resolves the issue, but getBounds() [0] is certainly not a safe solution.
An expert is needed here.
(
https://hibernate.atlassian.net/browse/HHH-15710#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15710#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100210- sha1:583150f )