Mercurial > hg > graal-compiler
annotate test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java @ 20527:8cb56c8cb30d
Merge
author | jiangli |
---|---|
date | Mon, 15 Sep 2014 16:39:00 -0400 |
parents | c3990b8c710e |
children |
rev | line source |
---|---|
20350
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
1 /* |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
4 * |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
8 * |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
13 * accompanied this code). |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
14 * |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
18 * |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
21 * questions. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
22 */ |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
23 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
24 import sun.hotspot.WhiteBox; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
25 import sun.misc.Unsafe; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
26 import sun.misc.IOUtils; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
27 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
28 import java.lang.reflect.Method; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
29 import java.net.URL; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
30 import java.net.URLConnection; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
31 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
32 /* |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
33 * @test TestAnonymousClassUnloading |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
34 * @bug 8054402 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
35 * @summary "Tests unloading of anonymous classes." |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
36 * @library /testlibrary /testlibrary/whitebox |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
37 * @compile TestAnonymousClassUnloading.java |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
38 * @run main ClassFileInstaller TestAnonymousClassUnloading |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
39 * sun.hotspot.WhiteBox |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
40 * sun.hotspot.WhiteBox$WhiteBoxPermission |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
41 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-BackgroundCompilation TestAnonymousClassUnloading |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
42 */ |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
43 public class TestAnonymousClassUnloading { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
44 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
45 private static final Unsafe UNSAFE = Unsafe.getUnsafe(); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
46 private static int COMP_LEVEL_SIMPLE = 1; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
47 private static int COMP_LEVEL_FULL_OPTIMIZATION = 4; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
48 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
49 /** |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
50 * We override hashCode here to be able to access this implementation |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
51 * via an Object reference (we cannot cast to TestAnonymousClassUnloading). |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
52 */ |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
53 @Override |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
54 public int hashCode() { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
55 return 42; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
56 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
57 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
58 /** |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
59 * Does some work by using the anonymousClass. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
60 * @param anonymousClass Class performing some work (will be unloaded) |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
61 */ |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
62 static private void doWork(Class<?> anonymousClass) throws InstantiationException, IllegalAccessException { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
63 // Create a new instance |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
64 Object anon = anonymousClass.newInstance(); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
65 // We would like to call a method of anonymousClass here but we cannot cast because the class |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
66 // was loaded by a different class loader. One solution would be to use reflection but since |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
67 // we want C2 to implement the call as an IC we call Object::hashCode() here which actually |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
68 // calls anonymousClass::hashCode(). C2 will then implement this call as an IC. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
69 if (anon.hashCode() != 42) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
70 new RuntimeException("Work not done"); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
71 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
72 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
73 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
74 /** |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
75 * Makes sure that method is compiled by forcing compilation if not yet compiled. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
76 * @param m Method to be checked |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
77 */ |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
78 static private void makeSureIsCompiled(Method m) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
79 // Make sure background compilation is disabled |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
80 if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
81 throw new RuntimeException("Background compilation enabled"); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
82 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
83 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
84 // Check if already compiled |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
85 if (!WHITE_BOX.isMethodCompiled(m)) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
86 // If not, try to compile it with C2 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
87 if(!WHITE_BOX.enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION)) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
88 // C2 compiler not available, try to compile with C1 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
89 WHITE_BOX.enqueueMethodForCompilation(m, COMP_LEVEL_SIMPLE); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
90 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
91 // Because background compilation is disabled, method should now be compiled |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
92 if(!WHITE_BOX.isMethodCompiled(m)) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
93 throw new RuntimeException(m + " not compiled"); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
94 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
95 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
96 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
97 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
98 /** |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
99 * This test creates stale Klass* metadata referenced by a compiled IC. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
100 * |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
101 * The following steps are performed: |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
102 * (1) An anonymous version of TestAnonymousClassUnloading is loaded by a custom class loader |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
103 * (2) The method doWork that calls a method of the anonymous class is compiled. The call |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
104 * is implemented as an IC referencing Klass* metadata of the anonymous class. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
105 * (3) Unloading of the anonymous class is enforced. The IC now references dead metadata. |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
106 */ |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
107 static public void main(String[] args) throws Exception { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
108 // (1) Load an anonymous version of this class using the corresponding Unsafe method |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
109 URL classUrl = TestAnonymousClassUnloading.class.getResource("TestAnonymousClassUnloading.class"); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
110 URLConnection connection = classUrl.openConnection(); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
111 byte[] classBytes = IOUtils.readFully(connection.getInputStream(), connection.getContentLength(), true); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
112 Class<?> anonymousClass = UNSAFE.defineAnonymousClass(TestAnonymousClassUnloading.class, classBytes, null); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
113 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
114 // (2) Make sure all paths of doWork are profiled and compiled |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
115 for (int i = 0; i < 100000; ++i) { |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
116 doWork(anonymousClass); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
117 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
118 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
119 // Make sure doWork is compiled now |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
120 Method doWork = TestAnonymousClassUnloading.class.getDeclaredMethod("doWork", Class.class); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
121 makeSureIsCompiled(doWork); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
122 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
123 // (3) Throw away reference to anonymousClass to allow unloading |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
124 anonymousClass = null; |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
125 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
126 // Force garbage collection to trigger unloading of anonymousClass |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
127 // Dead metadata reference to anonymousClass triggers JDK-8054402 |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
128 WHITE_BOX.fullGC(); |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
129 } |
c3990b8c710e
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff
changeset
|
130 } |