diff options
author | 2022-11-14 12:50:22 +0000 | |
---|---|---|
committer | 2022-11-14 15:16:19 +0000 | |
commit | 31ad1d85cf9b512737092807626c9e904957759b (patch) | |
tree | d52ae1ef8af5f7090227cd44d36c3f582d90c904 | |
parent | f07e4aac9583cb95d7b34a121aa8146be7c040ed (diff) |
ART: Change indentation to 4 spaces in run-test shard 16.
Created with
for testName in \
`git grep -E '^ public static void main\(String\[\]' \
-- test/*16-*/src/Main.java | \
sed '-es/\/src\/Main.java:.*//'`; \
do \
find $testName/ -type f -name *.java | \
xargs sed -E '-es/^(( )+)/\1\1/' --in-place ; \
done
Manually edited long lines found with
git log -n1 -p | grep -E '^\+.{101}'
in test/916-obsolete-jit/src/Main.java .
Test: buildbot-build.sh --target
Change-Id: I096e06729554bfa010efdcc7c510690269cd3a53
-rw-r--r-- | test/116-nodex2oat/src/Main.java | 10 | ||||
-rw-r--r-- | test/1916-get-set-current-frame/src/Main.java | 6 | ||||
-rw-r--r-- | test/1916-get-set-current-frame/src/art/Test1916.java | 202 | ||||
-rw-r--r-- | test/416-optimizing-arith-not/src/Main.java | 98 | ||||
-rw-r--r-- | test/516-dead-move-result/src/Main.java | 12 | ||||
-rw-r--r-- | test/616-cha-abstract/src/Main.java | 218 | ||||
-rw-r--r-- | test/616-cha-interface-default/src-multidex/Base.java | 40 | ||||
-rw-r--r-- | test/616-cha-interface-default/src/Main.java | 258 | ||||
-rw-r--r-- | test/616-cha-interface/src/Main.java | 248 | ||||
-rw-r--r-- | test/616-cha-miranda/src/Main.java | 208 | ||||
-rw-r--r-- | test/616-cha-native/src/Main.java | 12 | ||||
-rw-r--r-- | test/616-cha-proxy-method-inline/src-multidex/Foo.java | 2 | ||||
-rw-r--r-- | test/616-cha-proxy-method-inline/src/Main.java | 78 | ||||
-rw-r--r-- | test/616-cha-regression-proxy-method/src/Main.java | 168 | ||||
-rw-r--r-- | test/616-cha/src/Main.java | 434 | ||||
-rw-r--r-- | test/816-illegal-new-array/src/Main.java | 58 | ||||
-rw-r--r-- | test/916-obsolete-jit/src/Main.java | 270 | ||||
-rw-r--r-- | test/916-obsolete-jit/src/Transform.java | 30 |
18 files changed, 1176 insertions, 1176 deletions
diff --git a/test/116-nodex2oat/src/Main.java b/test/116-nodex2oat/src/Main.java index 5491c492a9..0e675c8b44 100644 --- a/test/116-nodex2oat/src/Main.java +++ b/test/116-nodex2oat/src/Main.java @@ -15,10 +15,10 @@ */ public class Main { - public static void main(String[] args) { - System.loadLibrary(args[0]); - System.out.println("Has oat is " + hasOatFile() + "."); - } + public static void main(String[] args) { + System.loadLibrary(args[0]); + System.out.println("Has oat is " + hasOatFile() + "."); + } - private native static boolean hasOatFile(); + private native static boolean hasOatFile(); } diff --git a/test/1916-get-set-current-frame/src/Main.java b/test/1916-get-set-current-frame/src/Main.java index 7d0cd21772..2ecf0caded 100644 --- a/test/1916-get-set-current-frame/src/Main.java +++ b/test/1916-get-set-current-frame/src/Main.java @@ -15,7 +15,7 @@ */ public class Main { - public static void main(String[] args) throws Exception { - art.Test1916.run(); - } + public static void main(String[] args) throws Exception { + art.Test1916.run(); + } } diff --git a/test/1916-get-set-current-frame/src/art/Test1916.java b/test/1916-get-set-current-frame/src/art/Test1916.java index 3e5bce2619..6fe4ba2a86 100644 --- a/test/1916-get-set-current-frame/src/art/Test1916.java +++ b/test/1916-get-set-current-frame/src/art/Test1916.java @@ -31,118 +31,118 @@ import java.util.function.Supplier; import java.util.function.Consumer; public class Test1916 { - public static final int SET_VALUE = 1337; - public static final String TARGET_VAR = "TARGET"; + public static final int SET_VALUE = 1337; + public static final String TARGET_VAR = "TARGET"; - public static void reportValue(Object val) { - System.out.println("\tValue is '" + val + "'"); - } - - public static class IntRunner implements Runnable { - private volatile boolean continueBusyLoop; - private volatile boolean inBusyLoop; - public IntRunner() { - this.continueBusyLoop = true; - this.inBusyLoop = false; - } - public void run() { - int TARGET = 42; - // We will suspend the thread during this loop. - while (continueBusyLoop) { - inBusyLoop = true; - } - reportValue(TARGET); + public static void reportValue(Object val) { + System.out.println("\tValue is '" + val + "'"); } - public void waitForBusyLoopStart() { while (!inBusyLoop) {} } - public void finish() { continueBusyLoop = false; } - } - - public static void run() throws Exception { - Locals.EnableLocalVariableAccess(); - runGet(); - runSet(); - } - public static void runGet() throws Exception { - Method target = IntRunner.class.getDeclaredMethod("run"); - // Get Int - IntRunner int_runner = new IntRunner(); - Thread target_get = new Thread(int_runner, "GetLocalInt - Target"); - target_get.start(); - int_runner.waitForBusyLoopStart(); - try { - Suspension.suspend(target_get); - } catch (Exception e) { - System.out.println("FAIL: got " + e); - e.printStackTrace(); - int_runner.finish(); - target_get.join(); - return; + public static class IntRunner implements Runnable { + private volatile boolean continueBusyLoop; + private volatile boolean inBusyLoop; + public IntRunner() { + this.continueBusyLoop = true; + this.inBusyLoop = false; + } + public void run() { + int TARGET = 42; + // We will suspend the thread during this loop. + while (continueBusyLoop) { + inBusyLoop = true; + } + reportValue(TARGET); + } + public void waitForBusyLoopStart() { while (!inBusyLoop) {} } + public void finish() { continueBusyLoop = false; } } - try { - StackTrace.StackFrameData frame = FindStackFrame(target_get, target); - int depth = frame.depth; - if (depth != 0) { throw new Error("Expected depth 0 but got " + depth); } - int slot = FindSlot(frame); - int value = Locals.GetLocalVariableInt(target_get, depth, slot); - System.out.println("From GetLocalInt(), value is " + value); - } finally { - Suspension.resume(target_get); - int_runner.finish(); - target_get.join(); + + public static void run() throws Exception { + Locals.EnableLocalVariableAccess(); + runGet(); + runSet(); } - } - public static void runSet() throws Exception { - Method target = IntRunner.class.getDeclaredMethod("run"); - // Set Int - IntRunner int_runner = new IntRunner(); - Thread target_set = new Thread(int_runner, "SetLocalInt - Target"); - target_set.start(); - int_runner.waitForBusyLoopStart(); - try { - Suspension.suspend(target_set); - } catch (Exception e) { - System.out.println("FAIL: got " + e); - e.printStackTrace(); - int_runner.finish(); - target_set.join(); - return; + public static void runGet() throws Exception { + Method target = IntRunner.class.getDeclaredMethod("run"); + // Get Int + IntRunner int_runner = new IntRunner(); + Thread target_get = new Thread(int_runner, "GetLocalInt - Target"); + target_get.start(); + int_runner.waitForBusyLoopStart(); + try { + Suspension.suspend(target_get); + } catch (Exception e) { + System.out.println("FAIL: got " + e); + e.printStackTrace(); + int_runner.finish(); + target_get.join(); + return; + } + try { + StackTrace.StackFrameData frame = FindStackFrame(target_get, target); + int depth = frame.depth; + if (depth != 0) { throw new Error("Expected depth 0 but got " + depth); } + int slot = FindSlot(frame); + int value = Locals.GetLocalVariableInt(target_get, depth, slot); + System.out.println("From GetLocalInt(), value is " + value); + } finally { + Suspension.resume(target_get); + int_runner.finish(); + target_get.join(); + } } - try { - StackTrace.StackFrameData frame = FindStackFrame(target_set, target); - int depth = frame.depth; - if (depth != 0) { throw new Error("Expected depth 0 but got " + depth); } - int slot = FindSlot(frame); - System.out.println("Setting TARGET to " + SET_VALUE); - Locals.SetLocalVariableInt(target_set, depth, slot, SET_VALUE); - } finally { - Suspension.resume(target_set); - int_runner.finish(); - target_set.join(); + + public static void runSet() throws Exception { + Method target = IntRunner.class.getDeclaredMethod("run"); + // Set Int + IntRunner int_runner = new IntRunner(); + Thread target_set = new Thread(int_runner, "SetLocalInt - Target"); + target_set.start(); + int_runner.waitForBusyLoopStart(); + try { + Suspension.suspend(target_set); + } catch (Exception e) { + System.out.println("FAIL: got " + e); + e.printStackTrace(); + int_runner.finish(); + target_set.join(); + return; + } + try { + StackTrace.StackFrameData frame = FindStackFrame(target_set, target); + int depth = frame.depth; + if (depth != 0) { throw new Error("Expected depth 0 but got " + depth); } + int slot = FindSlot(frame); + System.out.println("Setting TARGET to " + SET_VALUE); + Locals.SetLocalVariableInt(target_set, depth, slot, SET_VALUE); + } finally { + Suspension.resume(target_set); + int_runner.finish(); + target_set.join(); + } } - } - public static int FindSlot(StackTrace.StackFrameData frame) throws Exception { - long loc = frame.current_location; - for (Locals.VariableDescription var : Locals.GetLocalVariableTable(frame.method)) { - if (var.start_location <= loc && - var.length + var.start_location > loc && - var.name.equals(TARGET_VAR)) { - return var.slot; - } + public static int FindSlot(StackTrace.StackFrameData frame) throws Exception { + long loc = frame.current_location; + for (Locals.VariableDescription var : Locals.GetLocalVariableTable(frame.method)) { + if (var.start_location <= loc && + var.length + var.start_location > loc && + var.name.equals(TARGET_VAR)) { + return var.slot; + } + } + throw new Error( + "Unable to find variable " + TARGET_VAR + " in " + frame.method + " at loc " + loc); } - throw new Error( - "Unable to find variable " + TARGET_VAR + " in " + frame.method + " at loc " + loc); - } - private static StackTrace.StackFrameData FindStackFrame(Thread thr, Method target) { - for (StackTrace.StackFrameData frame : StackTrace.GetStackTrace(thr)) { - if (frame.method.equals(target)) { - return frame; - } + private static StackTrace.StackFrameData FindStackFrame(Thread thr, Method target) { + for (StackTrace.StackFrameData frame : StackTrace.GetStackTrace(thr)) { + if (frame.method.equals(target)) { + return frame; + } + } + throw new Error("Unable to find stack frame in method " + target + " on thread " + thr); } - throw new Error("Unable to find stack frame in method " + target + " on thread " + thr); - } } diff --git a/test/416-optimizing-arith-not/src/Main.java b/test/416-optimizing-arith-not/src/Main.java index 44c7d3cfb0..6bded7be8f 100644 --- a/test/416-optimizing-arith-not/src/Main.java +++ b/test/416-optimizing-arith-not/src/Main.java @@ -18,62 +18,62 @@ import java.lang.reflect.Method; public class Main { - public static void expectEquals(int expected, int result) { - if (expected != result) { - throw new Error("Expected: " + expected + ", found: " + result); + public static void expectEquals(int expected, int result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } } - } - public static void expectEquals(long expected, long result) { - if (expected != result) { - throw new Error("Expected: " + expected + ", found: " + result); + public static void expectEquals(long expected, long result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } } - } - public static void main(String[] args) throws Exception { - notInt(); - notLong(); - } + public static void main(String[] args) throws Exception { + notInt(); + notLong(); + } - private static void notInt() throws Exception { - expectEquals(1, smaliNotInt(-2)); - expectEquals(0, smaliNotInt(-1)); - expectEquals(-1, smaliNotInt(0)); - expectEquals(-2, smaliNotInt(1)); - expectEquals(2147483647, smaliNotInt(-2147483648)); // -(2^31) - expectEquals(2147483646, smaliNotInt(-2147483647)); // -(2^31 - 1) - expectEquals(-2147483647, smaliNotInt(2147483646)); // 2^31 - 2 - expectEquals(-2147483648, smaliNotInt(2147483647)); // 2^31 - 1 - } + private static void notInt() throws Exception { + expectEquals(1, smaliNotInt(-2)); + expectEquals(0, smaliNotInt(-1)); + expectEquals(-1, smaliNotInt(0)); + expectEquals(-2, smaliNotInt(1)); + expectEquals(2147483647, smaliNotInt(-2147483648)); // -(2^31) + expectEquals(2147483646, smaliNotInt(-2147483647)); // -(2^31 - 1) + expectEquals(-2147483647, smaliNotInt(2147483646)); // 2^31 - 2 + expectEquals(-2147483648, smaliNotInt(2147483647)); // 2^31 - 1 + } - private static void notLong() throws Exception { - expectEquals(1L, smaliNotLong(-2L)); - expectEquals(0L, smaliNotLong(-1L)); - expectEquals(-1L, smaliNotLong(0L)); - expectEquals(-2L, smaliNotLong(1L)); - expectEquals(2147483647L, smaliNotLong(-2147483648L)); // -(2^31) - expectEquals(2147483646L, smaliNotLong(-2147483647L)); // -(2^31 - 1) - expectEquals(-2147483647L, smaliNotLong(2147483646L)); // 2^31 - 2 - expectEquals(-2147483648L, smaliNotLong(2147483647L)); // 2^31 - 1 - expectEquals(9223372036854775807L, smaliNotLong(-9223372036854775808L)); // -(2^63) - expectEquals(9223372036854775806L, smaliNotLong(-9223372036854775807L)); // -(2^63 - 1) - expectEquals(-9223372036854775807L, smaliNotLong(9223372036854775806L)); // 2^63 - 2 - expectEquals(-9223372036854775808L, smaliNotLong(9223372036854775807L)); // 2^63 - 1 - } + private static void notLong() throws Exception { + expectEquals(1L, smaliNotLong(-2L)); + expectEquals(0L, smaliNotLong(-1L)); + expectEquals(-1L, smaliNotLong(0L)); + expectEquals(-2L, smaliNotLong(1L)); + expectEquals(2147483647L, smaliNotLong(-2147483648L)); // -(2^31) + expectEquals(2147483646L, smaliNotLong(-2147483647L)); // -(2^31 - 1) + expectEquals(-2147483647L, smaliNotLong(2147483646L)); // 2^31 - 2 + expectEquals(-2147483648L, smaliNotLong(2147483647L)); // 2^31 - 1 + expectEquals(9223372036854775807L, smaliNotLong(-9223372036854775808L)); // -(2^63) + expectEquals(9223372036854775806L, smaliNotLong(-9223372036854775807L)); // -(2^63 - 1) + expectEquals(-9223372036854775807L, smaliNotLong(9223372036854775806L)); // 2^63 - 2 + expectEquals(-9223372036854775808L, smaliNotLong(9223372036854775807L)); // 2^63 - 1 + } - // Wrappers around methods located in file not.smali. + // Wrappers around methods located in file not.smali. - private static int smaliNotInt(int a) throws Exception { - Class<?> c = Class.forName("TestNot"); - Method m = c.getMethod("$opt$NotInt", int.class); - int result = (Integer)m.invoke(null, a); - return result; - } + private static int smaliNotInt(int a) throws Exception { + Class<?> c = Class.forName("TestNot"); + Method m = c.getMethod("$opt$NotInt", int.class); + int result = (Integer)m.invoke(null, a); + return result; + } - private static long smaliNotLong(long a) throws Exception { - Class<?> c = Class.forName("TestNot"); - Method m = c.getMethod("$opt$NotLong", long.class); - long result = (Long)m.invoke(null, a); - return result; - } + private static long smaliNotLong(long a) throws Exception { + Class<?> c = Class.forName("TestNot"); + Method m = c.getMethod("$opt$NotLong", long.class); + long result = (Long)m.invoke(null, a); + return result; + } } diff --git a/test/516-dead-move-result/src/Main.java b/test/516-dead-move-result/src/Main.java index 8f0891adae..c2f34c7567 100644 --- a/test/516-dead-move-result/src/Main.java +++ b/test/516-dead-move-result/src/Main.java @@ -17,10 +17,10 @@ import java.lang.reflect.Method; public class Main { - public static void main(String[] args) throws Exception { - Class<?> c = Class.forName("MoveResult"); - Method m = c.getMethod("method"); - Object[] arguments = { }; - m.invoke(null, arguments); - } + public static void main(String[] args) throws Exception { + Class<?> c = Class.forName("MoveResult"); + Method m = c.getMethod("method"); + Object[] arguments = { }; + m.invoke(null, arguments); + } } diff --git a/test/616-cha-abstract/src/Main.java b/test/616-cha-abstract/src/Main.java index c8093e6124..1a06337a4d 100644 --- a/test/616-cha-abstract/src/Main.java +++ b/test/616-cha-abstract/src/Main.java @@ -15,145 +15,145 @@ */ abstract class Base { - abstract void foo(int i); + abstract void foo(int i); - void printError(String msg) { - System.out.println(msg); - } + void printError(String msg) { + System.out.println(msg); + } } class Main1 extends Base { - void foo(int i) { - if (i != 1) { - printError("error1"); + void foo(int i) { + if (i != 1) { + printError("error1"); + } } - } } class Main2 extends Main1 { - void foo(int i) { - if (i != 2) { - printError("error2"); + void foo(int i) { + if (i != 2) { + printError("error2"); + } } - } } public class Main { - static Base sMain1; - static Base sMain2; + static Base sMain1; + static Base sMain2; - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; + static boolean sIsOptimizing = true; + static boolean sHasJIT = true; + static volatile boolean sOtherThreadStarted; - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Helper.createMain2() which links in Main2, live testOverride() on stack - // should be deoptimized. - static void testOverride(boolean createMain2, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; + private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { + if (hasSingleImplementation(clazz, method_name) != b) { + System.out.println(clazz + "." + method_name + + " doesn't have single implementation value of " + b); + } } - if (createMain2 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } + // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. + // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. + // After Helper.createMain2() which links in Main2, live testOverride() on stack + // should be deoptimized. + static void testOverride(boolean createMain2, boolean wait, boolean setHasJIT) { + if (setHasJIT) { + if (isInterpreted()) { + sHasJIT = false; + } + return; + } - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - - if (createMain2) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Helper.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { + if (createMain2 && (sIsOptimizing || sHasJIT)) { + assertIsManaged(); } - } - } - // There should be a deoptimization here right after Main2 is linked by - // calling Helper.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main2 is created. - assertIsInterpreted(); - } + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + + if (createMain2) { + // Wait for the other thread to start. + while (!sOtherThreadStarted); + // Create an Main2 instance and assign it to sMain2. + // sMain1 is kept the same. + sMain2 = Helper.createMain2(); + // Wake up the other thread. + synchronized(Main.class) { + Main.class.notify(); + } + } else if (wait) { + // This is the other thread. + synchronized(Main.class) { + sOtherThreadStarted = true; + // Wait for Main2 to be linked and deoptimization is triggered. + try { + Main.class.wait(); + } catch (Exception e) { + } + } + } + + // There should be a deoptimization here right after Main2 is linked by + // calling Helper.createMain2(), even though sMain1 didn't change. + // The behavior here would be different if inline-cache is used, which + // doesn't deoptimize since sMain1 still hits the type cache. + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { + // This method should be deoptimized right after Main2 is created. + assertIsInterpreted(); + } - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + if (sMain2 != null) { + sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + } } - } - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); + // Test scenarios under which CHA-based devirtualization happens, + // and class loading that overrides a method can invalidate compiled code. + public static void main(String[] args) { + System.loadLibrary(args[0]); - if (isInterpreted()) { - sIsOptimizing = false; - } + if (isInterpreted()) { + sIsOptimizing = false; + } + + // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. + sMain1 = new Main1(); - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); + ensureJitCompiled(Main.class, "testOverride"); + testOverride(false, false, true); - ensureJitCompiled(Main.class, "testOverride"); - testOverride(false, false, true); + if (sHasJIT && !sIsOptimizing) { + assertSingleImplementation(Base.class, "foo", true); + assertSingleImplementation(Main1.class, "foo", true); + } else { + // Main2 is verified ahead-of-time so it's linked in already. + } - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main2 is verified ahead-of-time so it's linked in already. + // Create another thread that also calls sMain1.foo(). + // Try to test suspend and deopt another thread. + new Thread() { + public void run() { + testOverride(false, true, false); + } + }.start(); + + // This will create Main2 instance in the middle of testOverride(). + testOverride(true, false, false); + assertSingleImplementation(Base.class, "foo", false); + assertSingleImplementation(Main1.class, "foo", false); } - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testOverride(false, true, false); - } - }.start(); - - // This will create Main2 instance in the middle of testOverride(). - testOverride(true, false, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", false); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); + private static native void ensureJitCompiled(Class<?> itf, String method_name); + private static native void assertIsInterpreted(); + private static native void assertIsManaged(); + private static native boolean isInterpreted(); + private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); } // Put createMain2() in another class to avoid class loading due to verifier. class Helper { - static Main1 createMain2() { - return new Main2(); - } + static Main1 createMain2() { + return new Main2(); + } } diff --git a/test/616-cha-interface-default/src-multidex/Base.java b/test/616-cha-interface-default/src-multidex/Base.java index 2cbcb500c4..e3222a1ab3 100644 --- a/test/616-cha-interface-default/src-multidex/Base.java +++ b/test/616-cha-interface-default/src-multidex/Base.java @@ -15,27 +15,27 @@ */ interface Base { - default public int foo(int i) { - if (i != 1) { - return -2; + default public int foo(int i) { + if (i != 1) { + return -2; + } + return i + 10; } - return i + 10; - } - // Test default method that's not inlined. - default public int $noinline$bar() { - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - return -1; - } + // Test default method that's not inlined. + default public int $noinline$bar() { + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + return -1; + } - default void printError(String msg) { - System.out.println(msg); - } + default void printError(String msg) { + System.out.println(msg); + } } diff --git a/test/616-cha-interface-default/src/Main.java b/test/616-cha-interface-default/src/Main.java index ce02cf0271..40b815ad74 100644 --- a/test/616-cha-interface-default/src/Main.java +++ b/test/616-cha-interface-default/src/Main.java @@ -18,159 +18,159 @@ class Main1 implements Base { } class Main2 extends Main1 { - public void foobar() {} + public void foobar() {} } class Main3 implements Base { - public int foo(int i) { - if (i != 3) { - printError("error3"); + public int foo(int i) { + if (i != 3) { + printError("error3"); + } + return -(i + 10); } - return -(i + 10); - } } public class Main { - static Base sMain1; - static Base sMain2; - static Base sMain3; - - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; - - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); + static Base sMain1; + static Base sMain2; + static Base sMain3; + + static boolean sIsOptimizing = true; + static boolean sHasJIT = true; + static volatile boolean sOtherThreadStarted; + + private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { + if (hasSingleImplementation(clazz, method_name) != b) { + System.out.println(clazz + "." + method_name + + " doesn't have single implementation value of " + b); + } } - } - static int getValue(Class<?> cls) { - if (cls == Main1.class || cls == Main2.class) { - return 1; - } - return 3; - } - - // sMain1.foo()/sMain2.foo() will be always be Base.foo() before Main3 is loaded/linked. - // So sMain1.foo() can be devirtualized to Base.foo() and be inlined. - // After Helper.createMain3() which links in Main3, live testImplement() on stack - // should be deoptimized. - static void testImplement(boolean createMain3, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; + static int getValue(Class<?> cls) { + if (cls == Main1.class || cls == Main2.class) { + return 1; + } + return 3; } - if (createMain3 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } + // sMain1.foo()/sMain2.foo() will be always be Base.foo() before Main3 is loaded/linked. + // So sMain1.foo() can be devirtualized to Base.foo() and be inlined. + // After Helper.createMain3() which links in Main3, live testImplement() on stack + // should be deoptimized. + static void testImplement(boolean createMain3, boolean wait, boolean setHasJIT) { + if (setHasJIT) { + if (isInterpreted()) { + sHasJIT = false; + } + return; + } - if (sMain1.foo(getValue(sMain1.getClass())) != 11) { - System.out.println("11 expected."); - } - if (sMain1.$noinline$bar() != -1) { - System.out.println("-1 expected."); - } - if (sMain2.foo(getValue(sMain2.getClass())) != 11) { - System.out.println("11 expected."); - } + if (createMain3 && (sIsOptimizing || sHasJIT)) { + assertIsManaged(); + } - if (createMain3) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain3 = Helper.createMain3(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { + if (sMain1.foo(getValue(sMain1.getClass())) != 11) { + System.out.println("11 expected."); + } + if (sMain1.$noinline$bar() != -1) { + System.out.println("-1 expected."); + } + if (sMain2.foo(getValue(sMain2.getClass())) != 11) { + System.out.println("11 expected."); } - } - } - // There should be a deoptimization here right after Main3 is linked by - // calling Helper.createMain3(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - if (sMain1.foo(getValue(sMain1.getClass())) != 11) { - System.out.println("11 expected."); - } - if ((createMain3 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main3 is created. - assertIsInterpreted(); - } + if (createMain3) { + // Wait for the other thread to start. + while (!sOtherThreadStarted); + // Create an Main2 instance and assign it to sMain2. + // sMain1 is kept the same. + sMain3 = Helper.createMain3(); + // Wake up the other thread. + synchronized(Main.class) { + Main.class.notify(); + } + } else if (wait) { + // This is the other thread. + synchronized(Main.class) { + sOtherThreadStarted = true; + // Wait for Main2 to be linked and deoptimization is triggered. + try { + Main.class.wait(); + } catch (Exception e) { + } + } + } + + // There should be a deoptimization here right after Main3 is linked by + // calling Helper.createMain3(), even though sMain1 didn't change. + // The behavior here would be different if inline-cache is used, which + // doesn't deoptimize since sMain1 still hits the type cache. + if (sMain1.foo(getValue(sMain1.getClass())) != 11) { + System.out.println("11 expected."); + } + if ((createMain3 || wait) && sHasJIT && !sIsOptimizing) { + // This method should be deoptimized right after Main3 is created. + assertIsInterpreted(); + } - if (sMain3 != null) { - if (sMain3.foo(getValue(sMain3.getClass())) != -13) { - System.out.println("-13 expected."); - } + if (sMain3 != null) { + if (sMain3.foo(getValue(sMain3.getClass())) != -13) { + System.out.println("-13 expected."); + } + } } - } - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that implements a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); + // Test scenarios under which CHA-based devirtualization happens, + // and class loading that implements a method can invalidate compiled code. + public static void main(String[] args) { + System.loadLibrary(args[0]); - if (isInterpreted()) { - sIsOptimizing = false; - } + if (isInterpreted()) { + sIsOptimizing = false; + } - // sMain1 is an instance of Main1. - // sMain2 is an instance of Main2. - // Neither Main1 nor Main2 override default method Base.foo(). - // Main3 hasn't bee loaded yet. - sMain1 = new Main1(); - sMain2 = new Main2(); - - ensureJitCompiled(Main.class, "testImplement"); - testImplement(false, false, true); - - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main3 is verified ahead-of-time so it's linked in already. + // sMain1 is an instance of Main1. + // sMain2 is an instance of Main2. + // Neither Main1 nor Main2 override default method Base.foo(). + // Main3 hasn't bee loaded yet. + sMain1 = new Main1(); + sMain2 = new Main2(); + + ensureJitCompiled(Main.class, "testImplement"); + testImplement(false, false, true); + + if (sHasJIT && !sIsOptimizing) { + assertSingleImplementation(Base.class, "foo", true); + assertSingleImplementation(Main1.class, "foo", true); + } else { + // Main3 is verified ahead-of-time so it's linked in already. + } + + // Create another thread that also calls sMain1.foo(). + // Try to test suspend and deopt another thread. + new Thread() { + public void run() { + testImplement(false, true, false); + } + }.start(); + + // This will create Main3 instance in the middle of testImplement(). + testImplement(true, false, false); + assertSingleImplementation(Base.class, "foo", false); + assertSingleImplementation(Main1.class, "foo", true); + assertSingleImplementation(sMain3.getClass(), "foo", true); } - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testImplement(false, true, false); - } - }.start(); - - // This will create Main3 instance in the middle of testImplement(). - testImplement(true, false, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", true); - assertSingleImplementation(sMain3.getClass(), "foo", true); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); + private static native void ensureJitCompiled(Class<?> itf, String method_name); + private static native void assertIsInterpreted(); + private static native void assertIsManaged(); + private static native boolean isInterpreted(); + private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); } // Put createMain3() in another class to avoid class loading due to verifier. class Helper { - static Base createMain3() { - return new Main3(); - } + static Base createMain3() { + return new Main3(); + } } diff --git a/test/616-cha-interface/src/Main.java b/test/616-cha-interface/src/Main.java index c55ed6eeef..0c21ea06af 100644 --- a/test/616-cha-interface/src/Main.java +++ b/test/616-cha-interface/src/Main.java @@ -15,159 +15,159 @@ */ interface Base { - void foo(int i); - void $noinline$bar(); + void foo(int i); + void $noinline$bar(); } class Main1 implements Base { - public void foo(int i) { - if (i != 1) { - printError("error1"); + public void foo(int i) { + if (i != 1) { + printError("error1"); + } + } + + // Test rewriting invoke-interface into invoke-virtual when inlining fails. + public void $noinline$bar() { + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + } + + void printError(String msg) { + System.out.println(msg); } - } - - // Test rewriting invoke-interface into invoke-virtual when inlining fails. - public void $noinline$bar() { - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - } - - void printError(String msg) { - System.out.println(msg); - } } class Main2 extends Main1 { - public void foo(int i) { - if (i != 2) { - printError("error2"); + public void foo(int i) { + if (i != 2) { + printError("error2"); + } } - } } public class Main { - static Base sMain1; - static Base sMain2; + static Base sMain1; + static Base sMain2; - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; + static boolean sIsOptimizing = true; + static boolean sHasJIT = true; + static volatile boolean sOtherThreadStarted; - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Helper.createMain2() which links in Main2, live testImplement() on stack - // should be deoptimized. - static void testImplement(boolean createMain2, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; + private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { + if (hasSingleImplementation(clazz, method_name) != b) { + System.out.println(clazz + "." + method_name + + " doesn't have single implementation value of " + b); + } } - if (createMain2 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } + // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. + // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. + // After Helper.createMain2() which links in Main2, live testImplement() on stack + // should be deoptimized. + static void testImplement(boolean createMain2, boolean wait, boolean setHasJIT) { + if (setHasJIT) { + if (isInterpreted()) { + sHasJIT = false; + } + return; + } - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - sMain1.$noinline$bar(); - - if (createMain2) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Helper.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { + if (createMain2 && (sIsOptimizing || sHasJIT)) { + assertIsManaged(); } - } - } - // There should be a deoptimization here right after Main2 is linked by - // calling Helper.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main2 is created. - assertIsInterpreted(); - } + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + sMain1.$noinline$bar(); + + if (createMain2) { + // Wait for the other thread to start. + while (!sOtherThreadStarted); + // Create an Main2 instance and assign it to sMain2. + // sMain1 is kept the same. + sMain2 = Helper.createMain2(); + // Wake up the other thread. + synchronized(Main.class) { + Main.class.notify(); + } + } else if (wait) { + // This is the other thread. + synchronized(Main.class) { + sOtherThreadStarted = true; + // Wait for Main2 to be linked and deoptimization is triggered. + try { + Main.class.wait(); + } catch (Exception e) { + } + } + } - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + // There should be a deoptimization here right after Main2 is linked by + // calling Helper.createMain2(), even though sMain1 didn't change. + // The behavior here would be different if inline-cache is used, which + // doesn't deoptimize since sMain1 still hits the type cache. + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { + // This method should be deoptimized right after Main2 is created. + assertIsInterpreted(); + } + + if (sMain2 != null) { + sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + } } - } - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); + // Test scenarios under which CHA-based devirtualization happens, + // and class loading that overrides a method can invalidate compiled code. + public static void main(String[] args) { + System.loadLibrary(args[0]); - if (isInterpreted()) { - sIsOptimizing = false; - } + if (isInterpreted()) { + sIsOptimizing = false; + } - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); + // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. + sMain1 = new Main1(); - ensureJitCompiled(Main.class, "testImplement"); - testImplement(false, false, true); + ensureJitCompiled(Main.class, "testImplement"); + testImplement(false, false, true); - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main2 is verified ahead-of-time so it's linked in already. + if (sHasJIT && !sIsOptimizing) { + assertSingleImplementation(Base.class, "foo", true); + assertSingleImplementation(Main1.class, "foo", true); + } else { + // Main2 is verified ahead-of-time so it's linked in already. + } + + // Create another thread that also calls sMain1.foo(). + // Try to test suspend and deopt another thread. + new Thread() { + public void run() { + testImplement(false, true, false); + } + }.start(); + + // This will create Main2 instance in the middle of testImplement(). + testImplement(true, false, false); + assertSingleImplementation(Base.class, "foo", false); + assertSingleImplementation(Main1.class, "foo", false); } - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testImplement(false, true, false); - } - }.start(); - - // This will create Main2 instance in the middle of testImplement(). - testImplement(true, false, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", false); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); + private static native void ensureJitCompiled(Class<?> itf, String method_name); + private static native void assertIsInterpreted(); + private static native void assertIsManaged(); + private static native boolean isInterpreted(); + private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); } // Put createMain2() in another class to avoid class loading due to verifier. class Helper { - static Main1 createMain2() { - return new Main2(); - } + static Main1 createMain2() { + return new Main2(); + } } diff --git a/test/616-cha-miranda/src/Main.java b/test/616-cha-miranda/src/Main.java index c12575820f..eede84492d 100644 --- a/test/616-cha-miranda/src/Main.java +++ b/test/616-cha-miranda/src/Main.java @@ -15,142 +15,142 @@ */ interface Iface { - public void foo(int i); + public void foo(int i); } abstract class Base implements Iface { - // Iface.foo(int) will be added as a miranda method. + // Iface.foo(int) will be added as a miranda method. - void printError(String msg) { - System.out.println(msg); - } + void printError(String msg) { + System.out.println(msg); + } } class Main1 extends Base { - public void foo(int i) { - if (i != 1) { - printError("error1"); + public void foo(int i) { + if (i != 1) { + printError("error1"); + } } - } } class Main2 extends Main1 { - public void foo(int i) { - if (i != 2) { - printError("error2"); + public void foo(int i) { + if (i != 2) { + printError("error2"); + } } - } } public class Main { - static Base sMain1; - static Base sMain2; + static Base sMain1; + static Base sMain2; - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; + static boolean sIsOptimizing = true; + static boolean sHasJIT = true; + static volatile boolean sOtherThreadStarted; - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Helper.createMain2() which links in Main2, live testOverride() on stack - // should be deoptimized. - static void testOverride(boolean createMain2, boolean wait) { - if (createMain2 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); + private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { + if (hasSingleImplementation(clazz, method_name) != b) { + System.out.println(clazz + "." + method_name + + " doesn't have single implementation value of " + b); + } } - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - - if (createMain2) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Helper.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { + // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. + // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. + // After Helper.createMain2() which links in Main2, live testOverride() on stack + // should be deoptimized. + static void testOverride(boolean createMain2, boolean wait) { + if (createMain2 && (sIsOptimizing || sHasJIT)) { + assertIsManaged(); } - } - } - // There should be a deoptimization here right after Main2 is linked by - // calling Helper.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main2 is created. - assertIsInterpreted(); - } + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + + if (createMain2) { + // Wait for the other thread to start. + while (!sOtherThreadStarted); + // Create an Main2 instance and assign it to sMain2. + // sMain1 is kept the same. + sMain2 = Helper.createMain2(); + // Wake up the other thread. + synchronized(Main.class) { + Main.class.notify(); + } + } else if (wait) { + // This is the other thread. + synchronized(Main.class) { + sOtherThreadStarted = true; + // Wait for Main2 to be linked and deoptimization is triggered. + try { + Main.class.wait(); + } catch (Exception e) { + } + } + } + + // There should be a deoptimization here right after Main2 is linked by + // calling Helper.createMain2(), even though sMain1 didn't change. + // The behavior here would be different if inline-cache is used, which + // doesn't deoptimize since sMain1 still hits the type cache. + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { + // This method should be deoptimized right after Main2 is created. + assertIsInterpreted(); + } - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + if (sMain2 != null) { + sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + } } - } - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); + // Test scenarios under which CHA-based devirtualization happens, + // and class loading that overrides a method can invalidate compiled code. + public static void main(String[] args) { + System.loadLibrary(args[0]); - sIsOptimizing = isAotCompiled(Main.class, "testOverride"); - sHasJIT = hasJit(); + sIsOptimizing = isAotCompiled(Main.class, "testOverride"); + sHasJIT = hasJit(); - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); + // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. + sMain1 = new Main1(); - ensureJitCompiled(Main.class, "testOverride"); + ensureJitCompiled(Main.class, "testOverride"); - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main2 is verified ahead-of-time so it's linked in already. + if (sHasJIT && !sIsOptimizing) { + assertSingleImplementation(Base.class, "foo", true); + assertSingleImplementation(Main1.class, "foo", true); + } else { + // Main2 is verified ahead-of-time so it's linked in already. + } + + // Create another thread that also calls sMain1.foo(). + // Try to test suspend and deopt another thread. + new Thread() { + public void run() { + testOverride(false, true); + } + }.start(); + + // This will create Main2 instance in the middle of testOverride(). + testOverride(true, false); + assertSingleImplementation(Base.class, "foo", false); + assertSingleImplementation(Main1.class, "foo", false); } - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testOverride(false, true); - } - }.start(); - - // This will create Main2 instance in the middle of testOverride(). - testOverride(true, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", false); - } - - private static native boolean hasJit(); - private native static boolean isAotCompiled(Class<?> cls, String methodName); - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); + private static native boolean hasJit(); + private native static boolean isAotCompiled(Class<?> cls, String methodName); + private static native void ensureJitCompiled(Class<?> itf, String method_name); + private static native void assertIsInterpreted(); + private static native void assertIsManaged(); + private static native boolean isInterpreted(); + private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); } // Put createMain2() in another class to avoid class loading due to verifier. class Helper { - static Main1 createMain2() { - return new Main2(); - } + static Main1 createMain2() { + return new Main2(); + } } diff --git a/test/616-cha-native/src/Main.java b/test/616-cha-native/src/Main.java index 53a463ce87..145cc4210c 100644 --- a/test/616-cha-native/src/Main.java +++ b/test/616-cha-native/src/Main.java @@ -15,19 +15,19 @@ */ abstract class A { - public abstract void foo(); + public abstract void foo(); } class B extends A { - public native void foo(); + public native void foo(); } class C extends B { - public void foo() {} + public void foo() {} } public class Main { - public static void main(String[] args) { - System.loadLibrary(args[0]); - } + public static void main(String[] args) { + System.loadLibrary(args[0]); + } } diff --git a/test/616-cha-proxy-method-inline/src-multidex/Foo.java b/test/616-cha-proxy-method-inline/src-multidex/Foo.java index 9deca3e646..135214d617 100644 --- a/test/616-cha-proxy-method-inline/src-multidex/Foo.java +++ b/test/616-cha-proxy-method-inline/src-multidex/Foo.java @@ -15,5 +15,5 @@ */ interface Foo { - public Object bar(Object obj); + public Object bar(Object obj); } diff --git a/test/616-cha-proxy-method-inline/src/Main.java b/test/616-cha-proxy-method-inline/src/Main.java index be7bc820b3..10adc209e1 100644 --- a/test/616-cha-proxy-method-inline/src/Main.java +++ b/test/616-cha-proxy-method-inline/src/Main.java @@ -18,53 +18,53 @@ import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; class DebugProxy implements java.lang.reflect.InvocationHandler { - private Object obj; - static Class<?>[] interfaces = {Foo.class}; + private Object obj; + static Class<?>[] interfaces = {Foo.class}; - public static Object newInstance(Object obj) { - return java.lang.reflect.Proxy.newProxyInstance( - Foo.class.getClassLoader(), - interfaces, - new DebugProxy(obj)); - } - - private DebugProxy(Object obj) { - this.obj = obj; - } + public static Object newInstance(Object obj) { + return java.lang.reflect.Proxy.newProxyInstance( + Foo.class.getClassLoader(), + interfaces, + new DebugProxy(obj)); + } - public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { - Object result; - if (obj == null) { - return null; + private DebugProxy(Object obj) { + this.obj = obj; } - try { - System.out.println("before invoking method " + m.getName()); - result = m.invoke(obj, args); - } catch (InvocationTargetException e) { - throw e.getTargetException(); - } catch (Exception e) { - throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { - System.out.println("after invoking method " + m.getName()); + + public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + Object result; + if (obj == null) { + return null; + } + try { + System.out.println("before invoking method " + m.getName()); + result = m.invoke(obj, args); + } catch (InvocationTargetException e) { + throw e.getTargetException(); + } catch (Exception e) { + throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); + } finally { + System.out.println("after invoking method " + m.getName()); + } + return result; } - return result; - } } public class Main { - public static void call(Foo foo) { - if (foo == null) { - return; + public static void call(Foo foo) { + if (foo == null) { + return; + } + foo.bar(null); } - foo.bar(null); - } - public static void main(String[] args) { - System.loadLibrary(args[0]); - Foo foo = (Foo)DebugProxy.newInstance(null); - ensureJitCompiled(Main.class, "call"); - call(foo); - } + public static void main(String[] args) { + System.loadLibrary(args[0]); + Foo foo = (Foo)DebugProxy.newInstance(null); + ensureJitCompiled(Main.class, "call"); + call(foo); + } - private static native void ensureJitCompiled(Class<?> itf, String method_name); + private static native void ensureJitCompiled(Class<?> itf, String method_name); } diff --git a/test/616-cha-regression-proxy-method/src/Main.java b/test/616-cha-regression-proxy-method/src/Main.java index 176f80b1bf..14bc7a3931 100644 --- a/test/616-cha-regression-proxy-method/src/Main.java +++ b/test/616-cha-regression-proxy-method/src/Main.java @@ -19,113 +19,113 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; class Main1 { - void foo(int i) { - if (i != 1) { - printError("error1"); + void foo(int i) { + if (i != 1) { + printError("error1"); + } } - } - void printError(String msg) { - System.out.println(msg); - } + void printError(String msg) { + System.out.println(msg); + } } class Main2 extends Main1 { - void foo(int i) { - if (i != 2) { - printError("error2"); + void foo(int i) { + if (i != 2) { + printError("error2"); + } } - } } class Proxied implements Runnable { - public void run() { - synchronized(Main.class) { - Main.sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { - } + public void run() { + synchronized(Main.class) { + Main.sOtherThreadStarted = true; + // Wait for Main2 to be linked and deoptimization is triggered. + try { + Main.class.wait(); + } catch (Exception e) { + } + } } - } } class MyInvocationHandler implements InvocationHandler { - private final Proxied proxied; + private final Proxied proxied; - public MyInvocationHandler(Proxied proxied) { - this.proxied = proxied; - } + public MyInvocationHandler(Proxied proxied) { + this.proxied = proxied; + } - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return method.invoke(proxied, args); - } + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return method.invoke(proxied, args); + } } public class Main { - static Main1 sMain1; - static Main1 sMain2; - static volatile boolean sOtherThreadStarted; - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Helper.createMain2() which links in Main2, live testOverride() on stack - // should be deoptimized. - static void testOverride() { - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Helper.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); + static Main1 sMain1; + static Main1 sMain2; + static volatile boolean sOtherThreadStarted; + + // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. + // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. + // After Helper.createMain2() which links in Main2, live testOverride() on stack + // should be deoptimized. + static void testOverride() { + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + + // Wait for the other thread to start. + while (!sOtherThreadStarted); + // Create an Main2 instance and assign it to sMain2. + // sMain1 is kept the same. + sMain2 = Helper.createMain2(); + // Wake up the other thread. + synchronized(Main.class) { + Main.class.notify(); + } + + // There should be a deoptimization here right after Main2 is linked by + // calling Helper.createMain2(), even though sMain1 didn't change. + // The behavior here would be different if inline-cache is used, which + // doesn't deoptimize since sMain1 still hits the type cache. + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + if (sMain2 != null) { + sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + } } - // There should be a deoptimization here right after Main2 is linked by - // calling Helper.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); + // Test scenarios under which CHA-based devirtualization happens, + // and class loading that overrides a method can invalidate compiled code. + // Also create a proxy method such that a proxy method's frame is visited + // during stack walking. + public static void main(String[] args) { + System.loadLibrary(args[0]); + // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. + sMain1 = new Main1(); + + // Create another thread that calls a proxy method. + new Thread() { + public void run() { + Runnable proxy = (Runnable)Proxy.newProxyInstance( + Proxied.class.getClassLoader(), + new Class[] { Runnable.class }, + new MyInvocationHandler(new Proxied())); + proxy.run(); + } + }.start(); + + ensureJitCompiled(Main.class, "testOverride"); + // This will create Main2 instance in the middle of testOverride(). + testOverride(); } - } - - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - // Also create a proxy method such that a proxy method's frame is visited - // during stack walking. - public static void main(String[] args) { - System.loadLibrary(args[0]); - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); - - // Create another thread that calls a proxy method. - new Thread() { - public void run() { - Runnable proxy = (Runnable)Proxy.newProxyInstance( - Proxied.class.getClassLoader(), - new Class[] { Runnable.class }, - new MyInvocationHandler(new Proxied())); - proxy.run(); - } - }.start(); - - ensureJitCompiled(Main.class, "testOverride"); - // This will create Main2 instance in the middle of testOverride(). - testOverride(); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); + + private static native void ensureJitCompiled(Class<?> itf, String method_name); } // Put createMain2() in another class to avoid class loading due to verifier. class Helper { - static Main1 createMain2() { - return new Main2(); - } + static Main1 createMain2() { + return new Main2(); + } } diff --git a/test/616-cha/src/Main.java b/test/616-cha/src/Main.java index 39f47fae72..d2d4bcf2e8 100644 --- a/test/616-cha/src/Main.java +++ b/test/616-cha/src/Main.java @@ -15,239 +15,239 @@ */ class Main1 { - String getName() { - return "Main1"; - } - - void printError(String msg) { - System.out.println(msg); - } - - void foo(int i) { - if (i != 1) { - printError("error1"); - } - } - - int getValue1() { - return 1; - } - int getValue2() { - return 2; - } - int getValue3() { - return 3; - } - int getValue4() { - return 4; - } - int getValue5() { - return 5; - } - int getValue6() { - return 6; - } + String getName() { + return "Main1"; + } + + void printError(String msg) { + System.out.println(msg); + } + + void foo(int i) { + if (i != 1) { + printError("error1"); + } + } + + int getValue1() { + return 1; + } + int getValue2() { + return 2; + } + int getValue3() { + return 3; + } + int getValue4() { + return 4; + } + int getValue5() { + return 5; + } + int getValue6() { + return 6; + } } class Main2 extends Main1 { - String getName() { - return "Main2"; - } + String getName() { + return "Main2"; + } - void foo(int i) { - if (i != 2) { - printError("error2"); + void foo(int i) { + if (i != 2) { + printError("error2"); + } } - } } class Main3 extends Main1 { - String getName() { - return "Main3"; - } + String getName() { + return "Main3"; + } } public class Main { - static Main1 sMain1; - static Main1 sMain2; - - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Helper.createMain2() which links in Main2, live testOverride() on stack - // should be deoptimized. - static void testOverride(boolean createMain2, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; - } - - if (createMain2 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } - - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - - if (createMain2) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Helper.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { + static Main1 sMain1; + static Main1 sMain2; + + static boolean sIsOptimizing = true; + static boolean sHasJIT = true; + static volatile boolean sOtherThreadStarted; + + // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. + // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. + // After Helper.createMain2() which links in Main2, live testOverride() on stack + // should be deoptimized. + static void testOverride(boolean createMain2, boolean wait, boolean setHasJIT) { + if (setHasJIT) { + if (isInterpreted()) { + sHasJIT = false; + } + return; + } + + if (createMain2 && (sIsOptimizing || sHasJIT)) { + assertIsManaged(); + } + + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + + if (createMain2) { + // Wait for the other thread to start. + while (!sOtherThreadStarted); + // Create an Main2 instance and assign it to sMain2. + // sMain1 is kept the same. + sMain2 = Helper.createMain2(); + // Wake up the other thread. + synchronized(Main.class) { + Main.class.notify(); + } + } else if (wait) { + // This is the other thread. + synchronized(Main.class) { + sOtherThreadStarted = true; + // Wait for Main2 to be linked and deoptimization is triggered. + try { + Main.class.wait(); + } catch (Exception e) { + } + } + } + + // There should be a deoptimization here right after Main2 is linked by + // calling Helper.createMain2(), even though sMain1 didn't change. + // The behavior here would be different if inline-cache is used, which + // doesn't deoptimize since sMain1 still hits the type cache. + sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); + if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { + // This method should be deoptimized right after Main2 is created. + assertIsInterpreted(); + } + + if (sMain2 != null) { + sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); } - } } - // There should be a deoptimization here right after Main2 is linked by - // calling Helper.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main2 is created. - assertIsInterpreted(); - } - - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); - } - } - - static Main1[] sArray; - - static long calcValue(Main1 m) { - return m.getValue1() - + m.getValue2() * 2 - + m.getValue3() * 3 - + m.getValue4() * 4 - + m.getValue5() * 5 - + m.getValue6() * 6; - } - - static long testNoOverrideLoop(int count) { - long sum = 0; - for (int i=0; i<count; i++) { - sum += calcValue(sArray[0]); - sum += calcValue(sArray[1]); - sum += calcValue(sArray[2]); - } - return sum; - } - - static void testNoOverride() { - sArray = new Main1[3]; - sArray[0] = new Main1(); - sArray[1] = Helper.createMain2(); - sArray[2] = Helper.createMain3(); - long sum = 0; - // Loop enough to get methods JITed. - for (int i=0; i<100; i++) { - testNoOverrideLoop(1); - } - ensureJitCompiled(Main.class, "testNoOverrideLoop"); - ensureJitCompiled(Main.class, "calcValue"); - - long t1 = System.currentTimeMillis(); - sum = testNoOverrideLoop(100000); - long t2 = System.currentTimeMillis(); - if (sum != 27300000L) { - System.out.println("Unexpected result."); - } - } - - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - // Also test pure non-overriding case, which is more for checking generated - // code form. - public static void main(String[] args) { - System.loadLibrary(args[0]); - - // CHeck some boot-image methods. - - // We would want to have this, but currently setting single-implementation in the boot image - // does not work well with app images. b/34193647 - final boolean ARRAYLIST_SIZE_EXPECTED = false; - assertSingleImplementation(java.util.ArrayList.class, "size", ARRAYLIST_SIZE_EXPECTED); - - // java.util.LinkedHashMap overrides get(). - assertSingleImplementation(java.util.HashMap.class, "get", false); - - // We don't set single-implementation modifier bit for final classes or methods - // since we can devirtualize without CHA for those cases. However hasSingleImplementation() - // should return true for those cases. - assertSingleImplementation(java.lang.String.class, "charAt", true); - assertSingleImplementation(java.lang.Thread.class, "join", true); - - if (isInterpreted()) { - sIsOptimizing = false; - } - - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); - - ensureJitCompiled(Main.class, "testOverride"); - testOverride(false, false, true); - - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main2 is verified ahead-of-time so it's linked in already. - } - assertSingleImplementation(Main1.class, "getValue1", true); - - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testOverride(false, true, false); - } - }.start(); - - // This will create Main2 instance in the middle of testOverride(). - testOverride(true, false, false); - assertSingleImplementation(Main1.class, "foo", false); - assertSingleImplementation(Main1.class, "getValue1", true); - - testNoOverride(); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); + static Main1[] sArray; + + static long calcValue(Main1 m) { + return m.getValue1() + + m.getValue2() * 2 + + m.getValue3() * 3 + + m.getValue4() * 4 + + m.getValue5() * 5 + + m.getValue6() * 6; + } + + static long testNoOverrideLoop(int count) { + long sum = 0; + for (int i=0; i<count; i++) { + sum += calcValue(sArray[0]); + sum += calcValue(sArray[1]); + sum += calcValue(sArray[2]); + } + return sum; + } + + static void testNoOverride() { + sArray = new Main1[3]; + sArray[0] = new Main1(); + sArray[1] = Helper.createMain2(); + sArray[2] = Helper.createMain3(); + long sum = 0; + // Loop enough to get methods JITed. + for (int i=0; i<100; i++) { + testNoOverrideLoop(1); + } + ensureJitCompiled(Main.class, "testNoOverrideLoop"); + ensureJitCompiled(Main.class, "calcValue"); + + long t1 = System.currentTimeMillis(); + sum = testNoOverrideLoop(100000); + long t2 = System.currentTimeMillis(); + if (sum != 27300000L) { + System.out.println("Unexpected result."); + } + } + + private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { + if (hasSingleImplementation(clazz, method_name) != b) { + System.out.println(clazz + "." + method_name + + " doesn't have single implementation value of " + b); + } + } + + // Test scenarios under which CHA-based devirtualization happens, + // and class loading that overrides a method can invalidate compiled code. + // Also test pure non-overriding case, which is more for checking generated + // code form. + public static void main(String[] args) { + System.loadLibrary(args[0]); + + // CHeck some boot-image methods. + + // We would want to have this, but currently setting single-implementation in the boot image + // does not work well with app images. b/34193647 + final boolean ARRAYLIST_SIZE_EXPECTED = false; + assertSingleImplementation(java.util.ArrayList.class, "size", ARRAYLIST_SIZE_EXPECTED); + + // java.util.LinkedHashMap overrides get(). + assertSingleImplementation(java.util.HashMap.class, "get", false); + + // We don't set single-implementation modifier bit for final classes or methods + // since we can devirtualize without CHA for those cases. However hasSingleImplementation() + // should return true for those cases. + assertSingleImplementation(java.lang.String.class, "charAt", true); + assertSingleImplementation(java.lang.Thread.class, "join", true); + + if (isInterpreted()) { + sIsOptimizing = false; + } + + // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. + sMain1 = new Main1(); + + ensureJitCompiled(Main.class, "testOverride"); + testOverride(false, false, true); + + if (sHasJIT && !sIsOptimizing) { + assertSingleImplementation(Main1.class, "foo", true); + } else { + // Main2 is verified ahead-of-time so it's linked in already. + } + assertSingleImplementation(Main1.class, "getValue1", true); + + // Create another thread that also calls sMain1.foo(). + // Try to test suspend and deopt another thread. + new Thread() { + public void run() { + testOverride(false, true, false); + } + }.start(); + + // This will create Main2 instance in the middle of testOverride(). + testOverride(true, false, false); + assertSingleImplementation(Main1.class, "foo", false); + assertSingleImplementation(Main1.class, "getValue1", true); + + testNoOverride(); + } + + private static native void ensureJitCompiled(Class<?> itf, String method_name); + private static native void assertIsInterpreted(); + private static native void assertIsManaged(); + private static native boolean isInterpreted(); + private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); } // Put createMain2() in another class to avoid class loading due to verifier. class Helper { - static Main1 createMain2() { - return new Main2(); - } - static Main1 createMain3() { - return new Main3(); - } + static Main1 createMain2() { + return new Main2(); + } + static Main1 createMain3() { + return new Main3(); + } } diff --git a/test/816-illegal-new-array/src/Main.java b/test/816-illegal-new-array/src/Main.java index 2d48c12d8d..7a960bbe7e 100644 --- a/test/816-illegal-new-array/src/Main.java +++ b/test/816-illegal-new-array/src/Main.java @@ -19,37 +19,37 @@ import java.lang.reflect.Method; public class Main { - public static void main(String[] args) throws Exception { - Class<?> c = Class.forName("TestCase"); - Method m = c.getMethod("filledNewArray"); - try { - m.invoke(null); - throw new Error("Expected IllegalAccessError"); - } catch (InvocationTargetException e) { - if (!(e.getCause() instanceof IllegalAccessError)) { - throw new Error("Expected IllegalAccessError, got " + e.getCause()); - } - } + public static void main(String[] args) throws Exception { + Class<?> c = Class.forName("TestCase"); + Method m = c.getMethod("filledNewArray"); + try { + m.invoke(null); + throw new Error("Expected IllegalAccessError"); + } catch (InvocationTargetException e) { + if (!(e.getCause() instanceof IllegalAccessError)) { + throw new Error("Expected IllegalAccessError, got " + e.getCause()); + } + } - m = c.getMethod("filledNewArrayRange"); - try { - m.invoke(null); - throw new Error("Expected IllegalAccessError"); - } catch (InvocationTargetException e) { - if (!(e.getCause() instanceof IllegalAccessError)) { - throw new Error("Expected IllegalAccessError, got " + e.getCause()); - } - } + m = c.getMethod("filledNewArrayRange"); + try { + m.invoke(null); + throw new Error("Expected IllegalAccessError"); + } catch (InvocationTargetException e) { + if (!(e.getCause() instanceof IllegalAccessError)) { + throw new Error("Expected IllegalAccessError, got " + e.getCause()); + } + } - m = c.getMethod("newArray"); - try { - m.invoke(null); - throw new Error("Expected IllegalAccessError"); - } catch (InvocationTargetException e) { - if (!(e.getCause() instanceof IllegalAccessError)) { - throw new Error("Expected IllegalAccessError, got " + e.getCause()); - } + m = c.getMethod("newArray"); + try { + m.invoke(null); + throw new Error("Expected IllegalAccessError"); + } catch (InvocationTargetException e) { + if (!(e.getCause() instanceof IllegalAccessError)) { + throw new Error("Expected IllegalAccessError, got " + e.getCause()); + } + } } - } } diff --git a/test/916-obsolete-jit/src/Main.java b/test/916-obsolete-jit/src/Main.java index d7b32ba102..c265db99aa 100644 --- a/test/916-obsolete-jit/src/Main.java +++ b/test/916-obsolete-jit/src/Main.java @@ -23,151 +23,151 @@ import java.util.Base64; public class Main { - // import java.util.function.Consumer; - // - // class Transform { - // private void Start(Consumer<String> reporter) { - // reporter.accept("Hello - private - Transformed"); - // } - // - // private void Finish(Consumer<String> reporter) { - // reporter.accept("Goodbye - private - Transformed"); - // } - // - // public void sayHi(Runnable r, Consumer<String> reporter) { - // reporter.accept("pre Start private method call - Transformed"); - // Start(reporter); - // reporter.accept("post Start private method call - Transformed"); - // r.run(); - // reporter.accept("pre Finish private method call - Transformed"); - // Finish(reporter); - // reporter.accept("post Finish private method call - Transformed"); - // } - // } - private static final byte[] CLASS_BYTES = Base64.getDecoder().decode( - "yv66vgAAADQAMAoADQAcCAAdCwAeAB8IACAIACEKAAwAIggAIwsAJAAlCAAmCgAMACcIACgHACkH" + - "ACoBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQAFU3RhcnQBACAoTGph" + - "dmEvdXRpbC9mdW5jdGlvbi9Db25zdW1lcjspVgEACVNpZ25hdHVyZQEANChMamF2YS91dGlsL2Z1" + - "bmN0aW9uL0NvbnN1bWVyPExqYXZhL2xhbmcvU3RyaW5nOz47KVYBAAZGaW5pc2gBAAVzYXlIaQEA" + - "NChMamF2YS9sYW5nL1J1bm5hYmxlO0xqYXZhL3V0aWwvZnVuY3Rpb24vQ29uc3VtZXI7KVYBAEgo" + - "TGphdmEvbGFuZy9SdW5uYWJsZTtMamF2YS91dGlsL2Z1bmN0aW9uL0NvbnN1bWVyPExqYXZhL2xh" + - "bmcvU3RyaW5nOz47KVYBAApTb3VyY2VGaWxlAQAOVHJhbnNmb3JtLmphdmEMAA4ADwEAHUhlbGxv" + - "IC0gcHJpdmF0ZSAtIFRyYW5zZm9ybWVkBwArDAAsAC0BAB9Hb29kYnllIC0gcHJpdmF0ZSAtIFRy" + - "YW5zZm9ybWVkAQArcHJlIFN0YXJ0IHByaXZhdGUgbWV0aG9kIGNhbGwgLSBUcmFuc2Zvcm1lZAwA" + - "EgATAQAscG9zdCBTdGFydCBwcml2YXRlIG1ldGhvZCBjYWxsIC0gVHJhbnNmb3JtZWQHAC4MAC8A" + - "DwEALHByZSBGaW5pc2ggcHJpdmF0ZSBtZXRob2QgY2FsbCAtIFRyYW5zZm9ybWVkDAAWABMBAC1w" + - "b3N0IEZpbmlzaCBwcml2YXRlIG1ldGhvZCBjYWxsIC0gVHJhbnNmb3JtZWQBAAlUcmFuc2Zvcm0B" + - "ABBqYXZhL2xhbmcvT2JqZWN0AQAbamF2YS91dGlsL2Z1bmN0aW9uL0NvbnN1bWVyAQAGYWNjZXB0" + - "AQAVKExqYXZhL2xhbmcvT2JqZWN0OylWAQASamF2YS9sYW5nL1J1bm5hYmxlAQADcnVuACAADAAN" + - "AAAAAAAEAAAADgAPAAEAEAAAAB0AAQABAAAABSq3AAGxAAAAAQARAAAABgABAAAAEwACABIAEwAC" + - "ABAAAAAlAAIAAgAAAAkrEgK5AAMCALEAAAABABEAAAAKAAIAAAAVAAgAFgAUAAAAAgAVAAIAFgAT" + - "AAIAEAAAACUAAgACAAAACSsSBLkAAwIAsQAAAAEAEQAAAAoAAgAAABkACAAaABQAAAACABUAAQAX" + - "ABgAAgAQAAAAZQACAAMAAAAxLBIFuQADAgAqLLcABiwSB7kAAwIAK7kACAEALBIJuQADAgAqLLcA" + - "CiwSC7kAAwIAsQAAAAEAEQAAACIACAAAAB0ACAAeAA0AHwAVACAAGwAhACMAIgAoACMAMAAkABQA" + - "AAACABkAAQAaAAAAAgAb"); - private static final byte[] DEX_BYTES = Base64.getDecoder().decode( - "ZGV4CjAzNQBc8wr9PcHqnOR61m+0kimXTSddVMToJPuYBQAAcAAAAHhWNBIAAAAAAAAAAOAEAAAc" + - "AAAAcAAAAAYAAADgAAAABAAAAPgAAAAAAAAAAAAAAAcAAAAoAQAAAQAAAGABAAAYBAAAgAEAAHoC" + - "AAB9AgAAgAIAAIgCAACOAgAAlgIAALcCAADWAgAA4wIAAAIDAAAWAwAALAMAAEADAABeAwAAfQMA" + - "AIQDAACUAwAAlwMAAJsDAACgAwAAqAMAALwDAADrAwAAGQQAAEcEAAB0BAAAeQQAAIAEAAAHAAAA" + - "CAAAAAkAAAAKAAAADQAAABAAAAAQAAAABQAAAAAAAAARAAAABQAAAGQCAAASAAAABQAAAGwCAAAR" + - "AAAABQAAAHQCAAAAAAAAAgAAAAAAAwAEAAAAAAADAA4AAAAAAAIAGgAAAAIAAAACAAAAAwAAABkA" + - "AAAEAAEAEwAAAAAAAAAAAAAAAgAAAAAAAAAPAAAAPAIAAMoEAAAAAAAAAQAAAKgEAAABAAAAuAQA" + - "AAEAAQABAAAAhwQAAAQAAABwEAQAAAAOAAMAAgACAAAAjAQAAAcAAAAbAAUAAAByIAYAAgAOAAAA" + - "AwACAAIAAACTBAAABwAAABsABgAAAHIgBgACAA4AAAAEAAMAAgAAAJoEAAAiAAAAGwAYAAAAciAG" + - "AAMAcCACADEAGwAWAAAAciAGAAMAchAFAAIAGwAXAAAAciAGAAMAcCABADEAGwAVAAAAciAGAAMA" + - "DgAAAAAAAAAAAAMAAAAAAAAAAQAAAIABAAACAAAAgAEAAAMAAACIAQAAAQAAAAIAAAACAAAAAwAE" + - "AAEAAAAEAAEoAAE8AAY8aW5pdD4ABD47KVYABkZpbmlzaAAfR29vZGJ5ZSAtIHByaXZhdGUgLSBU" + - "cmFuc2Zvcm1lZAAdSGVsbG8gLSBwcml2YXRlIC0gVHJhbnNmb3JtZWQAC0xUcmFuc2Zvcm07AB1M" + - "ZGFsdmlrL2Fubm90YXRpb24vU2lnbmF0dXJlOwASTGphdmEvbGFuZy9PYmplY3Q7ABRMamF2YS9s" + - "YW5nL1J1bm5hYmxlOwASTGphdmEvbGFuZy9TdHJpbmc7ABxMamF2YS91dGlsL2Z1bmN0aW9uL0Nv" + - "bnN1bWVyAB1MamF2YS91dGlsL2Z1bmN0aW9uL0NvbnN1bWVyOwAFU3RhcnQADlRyYW5zZm9ybS5q" + - "YXZhAAFWAAJWTAADVkxMAAZhY2NlcHQAEmVtaXR0ZXI6IGphY2stNC4xOQAtcG9zdCBGaW5pc2gg" + - "cHJpdmF0ZSBtZXRob2QgY2FsbCAtIFRyYW5zZm9ybWVkACxwb3N0IFN0YXJ0IHByaXZhdGUgbWV0" + - "aG9kIGNhbGwgLSBUcmFuc2Zvcm1lZAAscHJlIEZpbmlzaCBwcml2YXRlIG1ldGhvZCBjYWxsIC0g" + - "VHJhbnNmb3JtZWQAK3ByZSBTdGFydCBwcml2YXRlIG1ldGhvZCBjYWxsIC0gVHJhbnNmb3JtZWQA" + - "A3J1bgAFc2F5SGkABXZhbHVlABMABw4AGQEABw5pABUBAAcOaQAdAgAABw5pPGk8aTxpAAIBARsc" + - "BRcAFwwXARcLFwMCAQEbHAYXABcKFwwXARcLFwMAAAMBAICABJADAQKoAwECyAMDAegDDwAAAAAA" + - "AAABAAAAAAAAAAEAAAAcAAAAcAAAAAIAAAAGAAAA4AAAAAMAAAAEAAAA+AAAAAUAAAAHAAAAKAEA" + - "AAYAAAABAAAAYAEAAAMQAAACAAAAgAEAAAEgAAAEAAAAkAEAAAYgAAABAAAAPAIAAAEQAAADAAAA" + - "ZAIAAAIgAAAcAAAAegIAAAMgAAAEAAAAhwQAAAQgAAACAAAAqAQAAAAgAAABAAAAygQAAAAQAAAB" + - "AAAA4AQAAA=="); + // import java.util.function.Consumer; + // + // class Transform { + // private void Start(Consumer<String> reporter) { + // reporter.accept("Hello - private - Transformed"); + // } + // + // private void Finish(Consumer<String> reporter) { + // reporter.accept("Goodbye - private - Transformed"); + // } + // + // public void sayHi(Runnable r, Consumer<String> reporter) { + // reporter.accept("pre Start private method call - Transformed"); + // Start(reporter); + // reporter.accept("post Start private method call - Transformed"); + // r.run(); + // reporter.accept("pre Finish private method call - Transformed"); + // Finish(reporter); + // reporter.accept("post Finish private method call - Transformed"); + // } + // } + private static final byte[] CLASS_BYTES = Base64.getDecoder().decode( + "yv66vgAAADQAMAoADQAcCAAdCwAeAB8IACAIACEKAAwAIggAIwsAJAAlCAAmCgAMACcIACgHACkH" + + "ACoBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQAFU3RhcnQBACAoTGph" + + "dmEvdXRpbC9mdW5jdGlvbi9Db25zdW1lcjspVgEACVNpZ25hdHVyZQEANChMamF2YS91dGlsL2Z1" + + "bmN0aW9uL0NvbnN1bWVyPExqYXZhL2xhbmcvU3RyaW5nOz47KVYBAAZGaW5pc2gBAAVzYXlIaQEA" + + "NChMamF2YS9sYW5nL1J1bm5hYmxlO0xqYXZhL3V0aWwvZnVuY3Rpb24vQ29uc3VtZXI7KVYBAEgo" + + "TGphdmEvbGFuZy9SdW5uYWJsZTtMamF2YS91dGlsL2Z1bmN0aW9uL0NvbnN1bWVyPExqYXZhL2xh" + + "bmcvU3RyaW5nOz47KVYBAApTb3VyY2VGaWxlAQAOVHJhbnNmb3JtLmphdmEMAA4ADwEAHUhlbGxv" + + "IC0gcHJpdmF0ZSAtIFRyYW5zZm9ybWVkBwArDAAsAC0BAB9Hb29kYnllIC0gcHJpdmF0ZSAtIFRy" + + "YW5zZm9ybWVkAQArcHJlIFN0YXJ0IHByaXZhdGUgbWV0aG9kIGNhbGwgLSBUcmFuc2Zvcm1lZAwA" + + "EgATAQAscG9zdCBTdGFydCBwcml2YXRlIG1ldGhvZCBjYWxsIC0gVHJhbnNmb3JtZWQHAC4MAC8A" + + "DwEALHByZSBGaW5pc2ggcHJpdmF0ZSBtZXRob2QgY2FsbCAtIFRyYW5zZm9ybWVkDAAWABMBAC1w" + + "b3N0IEZpbmlzaCBwcml2YXRlIG1ldGhvZCBjYWxsIC0gVHJhbnNmb3JtZWQBAAlUcmFuc2Zvcm0B" + + "ABBqYXZhL2xhbmcvT2JqZWN0AQAbamF2YS91dGlsL2Z1bmN0aW9uL0NvbnN1bWVyAQAGYWNjZXB0" + + "AQAVKExqYXZhL2xhbmcvT2JqZWN0OylWAQASamF2YS9sYW5nL1J1bm5hYmxlAQADcnVuACAADAAN" + + "AAAAAAAEAAAADgAPAAEAEAAAAB0AAQABAAAABSq3AAGxAAAAAQARAAAABgABAAAAEwACABIAEwAC" + + "ABAAAAAlAAIAAgAAAAkrEgK5AAMCALEAAAABABEAAAAKAAIAAAAVAAgAFgAUAAAAAgAVAAIAFgAT" + + "AAIAEAAAACUAAgACAAAACSsSBLkAAwIAsQAAAAEAEQAAAAoAAgAAABkACAAaABQAAAACABUAAQAX" + + "ABgAAgAQAAAAZQACAAMAAAAxLBIFuQADAgAqLLcABiwSB7kAAwIAK7kACAEALBIJuQADAgAqLLcA" + + "CiwSC7kAAwIAsQAAAAEAEQAAACIACAAAAB0ACAAeAA0AHwAVACAAGwAhACMAIgAoACMAMAAkABQA" + + "AAACABkAAQAaAAAAAgAb"); + private static final byte[] DEX_BYTES = Base64.getDecoder().decode( + "ZGV4CjAzNQBc8wr9PcHqnOR61m+0kimXTSddVMToJPuYBQAAcAAAAHhWNBIAAAAAAAAAAOAEAAAc" + + "AAAAcAAAAAYAAADgAAAABAAAAPgAAAAAAAAAAAAAAAcAAAAoAQAAAQAAAGABAAAYBAAAgAEAAHoC" + + "AAB9AgAAgAIAAIgCAACOAgAAlgIAALcCAADWAgAA4wIAAAIDAAAWAwAALAMAAEADAABeAwAAfQMA" + + "AIQDAACUAwAAlwMAAJsDAACgAwAAqAMAALwDAADrAwAAGQQAAEcEAAB0BAAAeQQAAIAEAAAHAAAA" + + "CAAAAAkAAAAKAAAADQAAABAAAAAQAAAABQAAAAAAAAARAAAABQAAAGQCAAASAAAABQAAAGwCAAAR" + + "AAAABQAAAHQCAAAAAAAAAgAAAAAAAwAEAAAAAAADAA4AAAAAAAIAGgAAAAIAAAACAAAAAwAAABkA" + + "AAAEAAEAEwAAAAAAAAAAAAAAAgAAAAAAAAAPAAAAPAIAAMoEAAAAAAAAAQAAAKgEAAABAAAAuAQA" + + "AAEAAQABAAAAhwQAAAQAAABwEAQAAAAOAAMAAgACAAAAjAQAAAcAAAAbAAUAAAByIAYAAgAOAAAA" + + "AwACAAIAAACTBAAABwAAABsABgAAAHIgBgACAA4AAAAEAAMAAgAAAJoEAAAiAAAAGwAYAAAAciAG" + + "AAMAcCACADEAGwAWAAAAciAGAAMAchAFAAIAGwAXAAAAciAGAAMAcCABADEAGwAVAAAAciAGAAMA" + + "DgAAAAAAAAAAAAMAAAAAAAAAAQAAAIABAAACAAAAgAEAAAMAAACIAQAAAQAAAAIAAAACAAAAAwAE" + + "AAEAAAAEAAEoAAE8AAY8aW5pdD4ABD47KVYABkZpbmlzaAAfR29vZGJ5ZSAtIHByaXZhdGUgLSBU" + + "cmFuc2Zvcm1lZAAdSGVsbG8gLSBwcml2YXRlIC0gVHJhbnNmb3JtZWQAC0xUcmFuc2Zvcm07AB1M" + + "ZGFsdmlrL2Fubm90YXRpb24vU2lnbmF0dXJlOwASTGphdmEvbGFuZy9PYmplY3Q7ABRMamF2YS9s" + + "YW5nL1J1bm5hYmxlOwASTGphdmEvbGFuZy9TdHJpbmc7ABxMamF2YS91dGlsL2Z1bmN0aW9uL0Nv" + + "bnN1bWVyAB1MamF2YS91dGlsL2Z1bmN0aW9uL0NvbnN1bWVyOwAFU3RhcnQADlRyYW5zZm9ybS5q" + + "YXZhAAFWAAJWTAADVkxMAAZhY2NlcHQAEmVtaXR0ZXI6IGphY2stNC4xOQAtcG9zdCBGaW5pc2gg" + + "cHJpdmF0ZSBtZXRob2QgY2FsbCAtIFRyYW5zZm9ybWVkACxwb3N0IFN0YXJ0IHByaXZhdGUgbWV0" + + "aG9kIGNhbGwgLSBUcmFuc2Zvcm1lZAAscHJlIEZpbmlzaCBwcml2YXRlIG1ldGhvZCBjYWxsIC0g" + + "VHJhbnNmb3JtZWQAK3ByZSBTdGFydCBwcml2YXRlIG1ldGhvZCBjYWxsIC0gVHJhbnNmb3JtZWQA" + + "A3J1bgAFc2F5SGkABXZhbHVlABMABw4AGQEABw5pABUBAAcOaQAdAgAABw5pPGk8aTxpAAIBARsc" + + "BRcAFwwXARcLFwMCAQEbHAYXABcKFwwXARcLFwMAAAMBAICABJADAQKoAwECyAMDAegDDwAAAAAA" + + "AAABAAAAAAAAAAEAAAAcAAAAcAAAAAIAAAAGAAAA4AAAAAMAAAAEAAAA+AAAAAUAAAAHAAAAKAEA" + + "AAYAAAABAAAAYAEAAAMQAAACAAAAgAEAAAEgAAAEAAAAkAEAAAYgAAABAAAAPAIAAAEQAAADAAAA" + + "ZAIAAAIgAAAcAAAAegIAAAMgAAAEAAAAhwQAAAQgAAACAAAAqAQAAAAgAAABAAAAygQAAAAQAAAB" + + "AAAA4AQAAA=="); - // A class that we can use to keep track of the output of this test. - private static class TestWatcher implements Consumer<String> { - private StringBuilder sb; - public TestWatcher() { - sb = new StringBuilder(); - } + // A class that we can use to keep track of the output of this test. + private static class TestWatcher implements Consumer<String> { + private StringBuilder sb; + public TestWatcher() { + sb = new StringBuilder(); + } - @Override - public void accept(String s) { - sb.append(s); - sb.append('\n'); - } + @Override + public void accept(String s) { + sb.append(s); + sb.append('\n'); + } - public String getOutput() { - return sb.toString(); - } + public String getOutput() { + return sb.toString(); + } - public void clear() { - sb = new StringBuilder(); + public void clear() { + sb = new StringBuilder(); + } } - } - public static void main(String[] args) { - doTest(new Transform(), new TestWatcher()); - } + public static void main(String[] args) { + doTest(new Transform(), new TestWatcher()); + } - private static boolean interpreting = true; - private static boolean retry = false; + private static boolean interpreting = true; + private static boolean retry = false; - public static void doTest(Transform t, TestWatcher w) { - // Get the methods that need to be optimized. - Method say_hi_method; - // Figure out if we can even JIT at all. - final boolean has_jit = hasJit(); - try { - say_hi_method = Transform.class.getDeclaredMethod( - "sayHi", Runnable.class, Consumer.class); - } catch (Exception e) { - System.out.println("Unable to find methods!"); - e.printStackTrace(System.out); - return; + public static void doTest(Transform t, TestWatcher w) { + // Get the methods that need to be optimized. + Method say_hi_method; + // Figure out if we can even JIT at all. + final boolean has_jit = hasJit(); + try { + say_hi_method = Transform.class.getDeclaredMethod( + "sayHi", Runnable.class, Consumer.class); + } catch (Exception e) { + System.out.println("Unable to find methods!"); + e.printStackTrace(System.out); + return; + } + // Makes sure the stack is the way we want it for the test and does the redefinition. + // It will set the retry boolean to true if the stack does not have a JIT-compiled + // sayHi entry. This can only happen if the method gets GC'd. + Runnable do_redefinition = () -> { + if (has_jit && Main.isInterpretedFunction(say_hi_method, true)) { + // Try again. We are not running the right jitted methods/cannot redefine them now. + retry = true; + } else { + // Actually do the redefinition. The stack looks good. + retry = false; + w.accept("transforming calling function"); + Redefinition.doCommonClassRedefinition(Transform.class, CLASS_BYTES, DEX_BYTES); + } + }; + // This just prints something out to show we are running the Runnable. + Runnable say_nothing = () -> { w.accept("Not doing anything here"); }; + do { + // Run ensureJitCompiled here since it might get GCd + ensureJitCompiled(Transform.class, "sayHi"); + // Clear output. + w.clear(); + // Try and redefine. + t.sayHi(say_nothing, w); + t.sayHi(do_redefinition, w); + t.sayHi(say_nothing, w); + } while (retry); + // Print output of last run. + System.out.print(w.getOutput()); } - // Makes sure the stack is the way we want it for the test and does the redefinition. It will - // set the retry boolean to true if the stack does not have a JIT-compiled sayHi entry. This can - // only happen if the method gets GC'd. - Runnable do_redefinition = () -> { - if (has_jit && Main.isInterpretedFunction(say_hi_method, true)) { - // Try again. We are not running the right jitted methods/cannot redefine them now. - retry = true; - } else { - // Actually do the redefinition. The stack looks good. - retry = false; - w.accept("transforming calling function"); - Redefinition.doCommonClassRedefinition(Transform.class, CLASS_BYTES, DEX_BYTES); - } - }; - // This just prints something out to show we are running the Runnable. - Runnable say_nothing = () -> { w.accept("Not doing anything here"); }; - do { - // Run ensureJitCompiled here since it might get GCd - ensureJitCompiled(Transform.class, "sayHi"); - // Clear output. - w.clear(); - // Try and redefine. - t.sayHi(say_nothing, w); - t.sayHi(do_redefinition, w); - t.sayHi(say_nothing, w); - } while (retry); - // Print output of last run. - System.out.print(w.getOutput()); - } - private static native boolean hasJit(); + private static native boolean hasJit(); - private static native boolean isInterpretedFunction(Method m, boolean require_deoptimizable); + private static native boolean isInterpretedFunction(Method m, boolean require_deoptimizable); - private static native void ensureJitCompiled(Class c, String name); + private static native void ensureJitCompiled(Class c, String name); } diff --git a/test/916-obsolete-jit/src/Transform.java b/test/916-obsolete-jit/src/Transform.java index 9c9adbc22d..5dbc04e6ac 100644 --- a/test/916-obsolete-jit/src/Transform.java +++ b/test/916-obsolete-jit/src/Transform.java @@ -17,21 +17,21 @@ import java.util.function.Consumer; class Transform { - private void Start(Consumer<String> reporter) { - reporter.accept("hello - private"); - } + private void Start(Consumer<String> reporter) { + reporter.accept("hello - private"); + } - private void Finish(Consumer<String> reporter) { - reporter.accept("goodbye - private"); - } + private void Finish(Consumer<String> reporter) { + reporter.accept("goodbye - private"); + } - public void sayHi(Runnable r, Consumer<String> reporter) { - reporter.accept("Pre Start private method call"); - Start(reporter); - reporter.accept("Post Start private method call"); - r.run(); - reporter.accept("Pre Finish private method call"); - Finish(reporter); - reporter.accept("Post Finish private method call"); - } + public void sayHi(Runnable r, Consumer<String> reporter) { + reporter.accept("Pre Start private method call"); + Start(reporter); + reporter.accept("Post Start private method call"); + r.run(); + reporter.accept("Pre Finish private method call"); + Finish(reporter); + reporter.accept("Post Finish private method call"); + } } |