mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-27 01:11:53 +08:00
Call setAccessible only once
In the getField method, due to recursion, the field.setAccessible was called a number of times equal to the number of level to go up the hierarchy to find the field
This commit is contained in:
@@ -7,10 +7,10 @@ public class Reflections {
|
|||||||
|
|
||||||
public static Field getField(final Class<?> clazz, final String fieldName) throws Exception {
|
public static Field getField(final Class<?> clazz, final String fieldName) throws Exception {
|
||||||
Field field = clazz.getDeclaredField(fieldName);
|
Field field = clazz.getDeclaredField(fieldName);
|
||||||
if (field == null && clazz.getSuperclass() != null) {
|
if (field != null)
|
||||||
field = getField(clazz.getSuperclass(), fieldName);
|
|
||||||
}
|
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
else if (clazz.getSuperclass() != null)
|
||||||
|
field = getField(clazz.getSuperclass(), fieldName);
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user