sad because java reflection is more protected :C
This commit is contained in:
parent
0a558c6b83
commit
c45b501ed8
@ -140,7 +140,10 @@ public class ReflectClass<T> {
|
|||||||
* @param name the name of the field.
|
* @param name the name of the field.
|
||||||
* @return a {@link ReflectField} wrapping the requested {@link Field}.
|
* @return a {@link ReflectField} wrapping the requested {@link Field}.
|
||||||
* @throws NoSuchFieldException if the requested field doesn’t exists in the wrapped class.
|
* @throws NoSuchFieldException if the requested field doesn’t exists in the wrapped class.
|
||||||
|
* @deprecated on Java 17, does not work due to module encapsulation, it is impossible to bypass the Java reflection
|
||||||
|
* API internal filtering.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since = "Java 17")
|
||||||
public ReflectField<T> filteredField(String name) throws NoSuchFieldException {
|
public ReflectField<T> filteredField(String name) throws NoSuchFieldException {
|
||||||
return field0(name, true);
|
return field0(name, true);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,11 @@ public final class ReflectField<T> extends ReflectMember<T, String, Field, NoSuc
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
modifiersFieldInFieldClass = Reflect.ofClass(Field.class).filteredField("modifiers").get();
|
@SuppressWarnings("deprecation")
|
||||||
|
Field f = Runtime.version().feature() < 16
|
||||||
|
? Reflect.ofClass(Field.class).filteredField("modifiers").get()
|
||||||
|
: null;
|
||||||
|
modifiersFieldInFieldClass = f;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
RuntimeException newEx = new RuntimeException("Cannot access " + Field.class + ".modifiers field.", e);
|
RuntimeException newEx = new RuntimeException("Cannot access " + Field.class + ".modifiers field.", e);
|
||||||
if (ex != null)
|
if (ex != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user