Can't access modifiers field in java 12

What was this used for anyway???
This commit is contained in:
Magnus Ulf 2019-03-22 16:10:40 +01:00
parent af6afa13b7
commit 0d034609f1

View File

@ -13,7 +13,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,14 +27,14 @@ public class ReflectionUtil
// CONSTANTS // CONSTANTS
// -------------------------------------------- // // -------------------------------------------- //
private static Field FIELD_DOT_MODIFIERS; //private static Field FIELD_DOT_MODIFIERS;
static static
{ {
try try
{ {
FIELD_DOT_MODIFIERS = Field.class.getDeclaredField("modifiers"); //FIELD_DOT_MODIFIERS = Field.class.getDeclaredField("modifiers");
FIELD_DOT_MODIFIERS.setAccessible(true); //FIELD_DOT_MODIFIERS.setAccessible(true);
} }
catch (Exception e) catch (Exception e)
{ {
@ -59,7 +58,7 @@ public class ReflectionUtil
// Remove the final modifier from the field. // Remove the final modifier from the field.
// http://stackoverflow.com/questions/2474017/using-reflection-to-change-static-final-file-separatorchar-for-unit-testing // http://stackoverflow.com/questions/2474017/using-reflection-to-change-static-final-file-separatorchar-for-unit-testing
FIELD_DOT_MODIFIERS.setInt(field, field.getModifiers() & ~Modifier.FINAL); //FIELD_DOT_MODIFIERS.setInt(field, field.getModifiers() & ~Modifier.FINAL);
} }
catch (Exception e) catch (Exception e)
{ {