test/hotspot/jtreg/runtime/MirrorFrame/Test8003720.java
author shade
Thu, 30 Nov 2017 17:13:33 +0100
branchepsilon-gc-branch
changeset 55934 912c55e702d6
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 25476
diff changeset
     2
 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     4
 *
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     8
 *
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    13
 * accompanied this code).
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    14
 *
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    18
 *
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    21
 * questions.
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    22
 */
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    23
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    24
/*
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    25
 * @test
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    26
 * @bug 8003720
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    27
 * @summary Method in interpreter stack frame can be deallocated
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 25476
diff changeset
    28
 * @modules java.base/jdk.internal.org.objectweb.asm
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 29678
diff changeset
    29
 *          java.base/jdk.internal.misc
25476
b97716c4b5c9 8048620: Remove unneeded/obsolete -source/-target options in hotspot tests
darcy
parents: 14589
diff changeset
    30
 * @compile -XDignore.symbol.file Victim.java
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    31
 * @run main/othervm -Xverify:all -Xint Test8003720
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    32
 */
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    33
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    34
// Attempts to make the JVM unload a class while still executing one of its methods.
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    35
public class Test8003720 {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    36
    final static String VICTIM_CLASS_NAME = "Victim";
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    37
    final static boolean QUIET = true;
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    38
    final static long DURATION = 30000;
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    39
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    40
    public interface CallMe { void callme(); }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    41
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    42
    public static void main(String... av) throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    43
        newVictimClassLoader();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    44
        System.gc();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    45
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    46
        newVictimClass();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    47
        System.gc();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    48
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    49
        newVictimInstance();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    50
        System.gc();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    51
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    52
        ((CallMe)newVictimInstance()).callme();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    53
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    54
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    55
    public static Object newVictimInstance() throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    56
        return newVictimClass().newInstance();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    57
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    58
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    59
    public static Class<?> newVictimClass() throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    60
        return Class.forName(VICTIM_CLASS_NAME, true, new VictimClassLoader());
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    61
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    62
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    63
    public static ClassLoader newVictimClassLoader() throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    64
        return new VictimClassLoader();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    65
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    66
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    67
    public static void println(String line) {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    68
        if (!QUIET) {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    69
            System.out.println(line);
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    70
        }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    71
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    72
}