diff options
| author | 2016-11-22 14:58:42 +0000 | |
|---|---|---|
| committer | 2016-11-22 14:58:42 +0000 | |
| commit | 701bb7d1d750850b41b26c75255e1829efb4860e (patch) | |
| tree | dc98891e1a3288d1bfd4ff558a2681b0e066abe5 | |
| parent | eb9c58e88f8e0f4a0a413efce04b49b183ad23e3 (diff) | |
| parent | ddb8afec79492750f16f98e5bd07d44f3dc485d4 (diff) | |
Merge changes If9d1da45,I6daecb52
* changes:
Do not test class unloading in 626-const-class-linking
Fix 626-const-class-linking for no-dex2oat configuration.
| -rw-r--r-- | test/626-const-class-linking/expected.txt | 1 | ||||
| -rw-r--r-- | test/626-const-class-linking/src/Main.java | 93 | ||||
| -rw-r--r-- | test/626-const-class-linking/src/MisbehavingLoader.java | 1 |
3 files changed, 35 insertions, 60 deletions
diff --git a/test/626-const-class-linking/expected.txt b/test/626-const-class-linking/expected.txt index e83aa78f42..1243226ff6 100644 --- a/test/626-const-class-linking/expected.txt +++ b/test/626-const-class-linking/expected.txt @@ -33,7 +33,6 @@ total: 4 throwables: 0 class_weaks: 4 (2 unique) testRacyLoader2 done -MisbehavingLoader loading Helper2 instead of Test java.lang.NoClassDefFoundError: Initiating class loader of type MisbehavingLoader returned class Helper2 instead of Test. testMisbehavingLoader done first: Helper1 class loader: RacyMisbehavingLoader diff --git a/test/626-const-class-linking/src/Main.java b/test/626-const-class-linking/src/Main.java index 44ea1c1800..05a6baca71 100644 --- a/test/626-const-class-linking/src/Main.java +++ b/test/626-const-class-linking/src/Main.java @@ -49,6 +49,7 @@ public class Main { } Runtime.getRuntime().gc(); WeakReference<Class<?>> weak_test2 = wrapHelperGet(helper); + Runtime.getRuntime().gc(); Class<?> test1 = weak_test1.get(); if (test1 == null) { @@ -62,20 +63,6 @@ public class Main { System.out.println("test1 != test2"); } - test1 = null; - test2 = null; - if (!usingRI) { - clearResolvedTypes(helper); - } - helper = null; - delegating_loader = null; - Runtime.getRuntime().gc(); - if (weak_test1.get() != null) { - System.out.println("weak_test1 still not null"); - } - if (weak_test2.get() != null) { - System.out.println("weak_test2 still not null"); - } System.out.println("testClearDexCache done"); } @@ -90,6 +77,8 @@ public class Main { Class<?> helper2 = delegating_loader.loadClass("Helper2"); WeakReference<Class<?>> weak_test2 = wrapHelperGet(helper2); + Runtime.getRuntime().gc(); + Class<?> test1 = weak_test1.get(); if (test1 == null) { System.out.println("test1 disappeared"); @@ -102,18 +91,6 @@ public class Main { System.out.println("test1 != test2"); } - test1 = null; - test2 = null; - delegating_loader = null; - helper1 = null; - helper2 = null; - Runtime.getRuntime().gc(); - if (weak_test1.get() != null) { - System.out.println("weak_test1 still not null"); - } - if (weak_test2.get() != null) { - System.out.println("weak_test2 still not null"); - } System.out.println("testMultiDex done"); } @@ -271,38 +248,38 @@ public class Main { } private static void testRacyMisbehavingLoader2() throws Exception { - final ClassLoader system_loader = ClassLoader.getSystemClassLoader(); - - final Thread[] threads = new Thread[4]; - final Object[] results = new Object[threads.length]; - - final RacyMisbehavingLoader racy_loader = - new RacyMisbehavingLoader(system_loader, threads.length, true); - final Class<?> helper1 = racy_loader.loadClass("RacyMisbehavingHelper"); - - for (int i = 0; i != threads.length; ++i) { - final int my_index = i; - Thread t = new Thread() { - public void run() { - try { - Method get = helper1.getDeclaredMethod("get"); - results[my_index] = get.invoke(null); - } catch (InvocationTargetException ite) { - results[my_index] = ite.getCause(); - } catch (Throwable t) { - results[my_index] = t; - } - } - }; - t.start(); - threads[i] = t; - } - for (Thread t : threads) { - t.join(); - } - dumpResultStats(results); - System.out.println("testRacyMisbehavingLoader2 done"); - } + final ClassLoader system_loader = ClassLoader.getSystemClassLoader(); + + final Thread[] threads = new Thread[4]; + final Object[] results = new Object[threads.length]; + + final RacyMisbehavingLoader racy_loader = + new RacyMisbehavingLoader(system_loader, threads.length, true); + final Class<?> helper1 = racy_loader.loadClass("RacyMisbehavingHelper"); + + for (int i = 0; i != threads.length; ++i) { + final int my_index = i; + Thread t = new Thread() { + public void run() { + try { + Method get = helper1.getDeclaredMethod("get"); + results[my_index] = get.invoke(null); + } catch (InvocationTargetException ite) { + results[my_index] = ite.getCause(); + } catch (Throwable t) { + results[my_index] = t; + } + } + }; + t.start(); + threads[i] = t; + } + for (Thread t : threads) { + t.join(); + } + dumpResultStats(results); + System.out.println("testRacyMisbehavingLoader2 done"); + } private static DelegatingLoader createDelegatingLoader() { ClassLoader system_loader = ClassLoader.getSystemClassLoader(); diff --git a/test/626-const-class-linking/src/MisbehavingLoader.java b/test/626-const-class-linking/src/MisbehavingLoader.java index 61639ba736..ca9783e4ef 100644 --- a/test/626-const-class-linking/src/MisbehavingLoader.java +++ b/test/626-const-class-linking/src/MisbehavingLoader.java @@ -40,7 +40,6 @@ public class MisbehavingLoader extends DefiningLoader { return super.loadClass(name, resolve); } else if (name.equals("Test")) { // Ask for a different class. - System.out.println("MisbehavingLoader loading Helper2 instead of Test"); return defining_loader.loadClass("Helper2", resolve); } return super.loadClass(name, resolve); |