hotspot/test/runtime/8003720/Test8003720.java
author mlarsson
Tue, 29 Mar 2016 09:43:05 +0200
changeset 37201 928cf689af1a
parent 29678 dd2f3932c21e
child 36851 03e2f4d0a421
permissions -rw-r--r--
8151993: Remove inclusion of inline.hpp in log.hpp Reviewed-by: kbarrett, stefank
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
/*
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    26
 * @test
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    27
 * @bug 8003720
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    28
 * @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
    29
 * @modules java.base/jdk.internal.org.objectweb.asm
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 25476
diff changeset
    30
 *          java.base/sun.misc
25476
b97716c4b5c9 8048620: Remove unneeded/obsolete -source/-target options in hotspot tests
darcy
parents: 14589
diff changeset
    31
 * @compile -XDignore.symbol.file Victim.java
14582
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    32
 * @run main/othervm -Xverify:all -Xint Test8003720
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
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    35
// 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
    36
public class Test8003720 {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    37
    final static String VICTIM_CLASS_NAME = "Victim";
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    38
    final static boolean QUIET = true;
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    39
    final static long DURATION = 30000;
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    40
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    41
    public interface CallMe { void callme(); }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    42
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    43
    public static void main(String... av) throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    44
        newVictimClassLoader();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    45
        System.gc();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    46
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    47
        newVictimClass();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    48
        System.gc();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    49
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    50
        newVictimInstance();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    51
        System.gc();
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    52
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    53
        ((CallMe)newVictimInstance()).callme();
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
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    56
    public static Object newVictimInstance() throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    57
        return newVictimClass().newInstance();
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
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    60
    public static Class<?> newVictimClass() throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    61
        return Class.forName(VICTIM_CLASS_NAME, true, new VictimClassLoader());
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
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    64
    public static ClassLoader newVictimClassLoader() throws Throwable {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    65
        return new VictimClassLoader();
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
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    68
    public static void println(String line) {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    69
        if (!QUIET) {
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    70
            System.out.println(line);
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
    }
490bb6c0df7c 8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
diff changeset
    73
}