HHH-12199 - Ignore static fields when resolving property types via reflection.

(cherry picked from commit 1d94549)
This commit is contained in:
Chris Cranford 2018-04-27 16:08:36 -04:00
parent ceb45b109e
commit dd450145c0
1 changed files with 9 additions and 1 deletions

View File

@ -386,13 +386,21 @@ public final class ReflectHelper {
} }
try { try {
return clazz.getDeclaredField( propertyName ); Field field = clazz.getDeclaredField( propertyName );
if ( !isStaticField( field ) ) {
return field;
}
return locateField( clazz.getSuperclass(), propertyName );
} }
catch ( NoSuchFieldException nsfe ) { catch ( NoSuchFieldException nsfe ) {
return locateField( clazz.getSuperclass(), propertyName ); return locateField( clazz.getSuperclass(), propertyName );
} }
} }
private static boolean isStaticField(Field field) {
return field != null && ( field.getModifiers() & Modifier.STATIC ) == Modifier.STATIC;
}
public static Method findGetterMethod(Class containerClass, String propertyName) { public static Method findGetterMethod(Class containerClass, String propertyName) {
Class checkClass = containerClass; Class checkClass = containerClass;
Method getter = null; Method getter = null;