--- old/test/jdk/java/lang/reflect/callerCache/AccessTest.java 2018-09-14 10:44:29.000000000 +0100 +++ new/test/jdk/java/lang/reflect/callerCache/AccessTest.java 2018-09-14 10:44:28.000000000 +0100 @@ -113,25 +113,17 @@ if (!Modifier.isFinal(f.getModifiers())) { throw new RuntimeException("not a final field"); } - makeFinalNonFinal(f); } public Void call() throws Exception { Members obj = isStatic ? null : new Members(); try { f.set(obj, 20); - checkValue(obj, 20); + throw new RuntimeException("IllegalAccessException expected"); } catch (IllegalAccessException e) { - throw e; + // expected } return null; } - - void checkValue(Object obj, int expected) throws Exception { - int value = (int) f.get(obj); - if (value != expected) { - throw new RuntimeException("unexpectd value: " + value); - } - } } public static class PublicFinalField extends FinalField { @@ -157,15 +149,4 @@ super("privateStaticFinalField"); } } - - private static void makeFinalNonFinal(Field f) throws ReflectiveOperationException { - Field modifiers = Field.class.getDeclaredField("modifiers"); - modifiers.setAccessible(true); - modifiers.set(f, modifiers.getInt(f) & ~Modifier.FINAL); - f.setAccessible(true); - - if (Modifier.isFinal(f.getModifiers())) { - throw new RuntimeException("should be a non-final field"); - } - } }