hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java
author alanb
Wed, 05 Jul 2017 13:25:45 +0100
changeset 45825 4fa7bd62eb84
parent 42650 1f304d0c888b
permissions -rw-r--r--
8183503: Update hotspot tests to allow for unique test classes directory Reviewed-by: iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
26174
ca46a107cb78 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.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
     4
 *
ca46a107cb78 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
ca46a107cb78 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
ca46a107cb78 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.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
     8
 *
ca46a107cb78 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
ca46a107cb78 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
ca46a107cb78 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
ca46a107cb78 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
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    13
 * accompanied this code).
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    14
 *
ca46a107cb78 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
ca46a107cb78 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,
ca46a107cb78 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.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    18
 *
ca46a107cb78 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
ca46a107cb78 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
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    21
 * questions.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    22
 */
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    23
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    24
/*
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    25
 * @test TestAnonymousClassUnloading
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    26
 * @bug 8054402
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    27
 * @summary "Tests unloading of anonymous classes."
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    28
 * @library /test/lib /
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    29
 * @modules java.base/jdk.internal.misc
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    30
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    31
 * @run main/othervm/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    32
 *      -XX:-BackgroundCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 *      compiler.classUnloading.anonymousClass.TestAnonymousClassUnloading
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    34
 */
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    35
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
package compiler.classUnloading.anonymousClass;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    37
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    38
import jdk.internal.misc.Unsafe;
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    39
import sun.hotspot.WhiteBox;
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    40
32924
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
    41
import java.io.IOException;
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    42
import java.lang.reflect.Method;
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    43
import java.net.URL;
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    44
import java.net.URLConnection;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40631
diff changeset
    45
import compiler.whitebox.CompilerWhiteBoxTest;
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    46
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    47
public class TestAnonymousClassUnloading {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    48
    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    49
    private static final Unsafe UNSAFE = Unsafe.getUnsafe();
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    50
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    51
    /**
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    52
     * We override hashCode here to be able to access this implementation
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    53
     * via an Object reference (we cannot cast to TestAnonymousClassUnloading).
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    54
     */
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    55
    @Override
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    56
    public int hashCode() {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    57
        return 42;
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    58
    }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    59
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    60
    /**
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    61
     * Does some work by using the anonymousClass.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    62
     * @param anonymousClass Class performing some work (will be unloaded)
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    63
     */
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    64
    static private void doWork(Class<?> anonymousClass) throws InstantiationException, IllegalAccessException {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    65
        // Create a new instance
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    66
        Object anon = anonymousClass.newInstance();
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    67
        // We would like to call a method of anonymousClass here but we cannot cast because the class
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    68
        // was loaded by a different class loader. One solution would be to use reflection but since
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    69
        // we want C2 to implement the call as an IC we call Object::hashCode() here which actually
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    70
        // calls anonymousClass::hashCode(). C2 will then implement this call as an IC.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    71
        if (anon.hashCode() != 42) {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    72
            new RuntimeException("Work not done");
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    73
        }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    74
    }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    75
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    76
    /**
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    77
     * Makes sure that method is compiled by forcing compilation if not yet compiled.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    78
     * @param m Method to be checked
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    79
     */
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    80
    static private void makeSureIsCompiled(Method m) {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    81
        // Make sure background compilation is disabled
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    82
        if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    83
            throw new RuntimeException("Background compilation enabled");
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    84
        }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    85
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    86
        // Check if already compiled
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    87
        if (!WHITE_BOX.isMethodCompiled(m)) {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    88
            // If not, try to compile it with C2
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40631
diff changeset
    89
            if(!WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) {
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    90
                // C2 compiler not available, try to compile with C1
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 40631
diff changeset
    91
                WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    92
            }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    93
            // Because background compilation is disabled, method should now be compiled
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    94
            if(!WHITE_BOX.isMethodCompiled(m)) {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    95
                throw new RuntimeException(m + " not compiled");
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    96
            }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    97
        }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    98
    }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
    99
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   100
    /**
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   101
     * This test creates stale Klass* metadata referenced by a compiled IC.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   102
     *
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   103
     * The following steps are performed:
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   104
     * (1) An anonymous version of TestAnonymousClassUnloading is loaded by a custom class loader
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   105
     * (2) The method doWork that calls a method of the anonymous class is compiled. The call
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   106
     *     is implemented as an IC referencing Klass* metadata of the anonymous class.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   107
     * (3) Unloading of the anonymous class is enforced. The IC now references dead metadata.
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   108
     */
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   109
    static public void main(String[] args) throws Exception {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   110
        // (1) Load an anonymous version of this class using the corresponding Unsafe method
45825
4fa7bd62eb84 8183503: Update hotspot tests to allow for unique test classes directory
alanb
parents: 42650
diff changeset
   111
        String rn = TestAnonymousClassUnloading.class.getSimpleName() + ".class";
4fa7bd62eb84 8183503: Update hotspot tests to allow for unique test classes directory
alanb
parents: 42650
diff changeset
   112
        URL classUrl = TestAnonymousClassUnloading.class.getResource(rn);
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   113
        URLConnection connection = classUrl.openConnection();
32924
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   114
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   115
        int length = connection.getContentLength();
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   116
        byte[] classBytes = connection.getInputStream().readAllBytes();
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   117
        if (length != -1 && classBytes.length != length) {
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   118
            throw new IOException("Expected:" + length + ", actual: " + classBytes.length);
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   119
        }
89da05adaa00 8138978: Examine usages of sun.misc.IOUtils
chegar
parents: 29678
diff changeset
   120
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   121
        Class<?> anonymousClass = UNSAFE.defineAnonymousClass(TestAnonymousClassUnloading.class, classBytes, null);
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   122
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   123
        // (2) Make sure all paths of doWork are profiled and compiled
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   124
        for (int i = 0; i < 100000; ++i) {
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   125
            doWork(anonymousClass);
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   126
        }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   127
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   128
        // Make sure doWork is compiled now
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   129
        Method doWork = TestAnonymousClassUnloading.class.getDeclaredMethod("doWork", Class.class);
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   130
        makeSureIsCompiled(doWork);
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   131
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   132
        // (3) Throw away reference to anonymousClass to allow unloading
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   133
        anonymousClass = null;
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   134
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   135
        // Force garbage collection to trigger unloading of anonymousClass
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   136
        // Dead metadata reference to anonymousClass triggers JDK-8054402
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   137
        WHITE_BOX.fullGC();
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   138
    }
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
diff changeset
   139
}