Thu, 13 Dec 2012 09:05:20 -0800
Added tag jdk8-b68 for changeset 121aa71316af
stefank@4298 | 1 | /* |
stefank@4298 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
stefank@4298 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
stefank@4298 | 4 | * |
stefank@4298 | 5 | * This code is free software; you can redistribute it and/or modify it |
stefank@4298 | 6 | * under the terms of the GNU General Public License version 2 only, as |
stefank@4298 | 7 | * published by the Free Software Foundation. |
stefank@4298 | 8 | * |
stefank@4298 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
stefank@4298 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
stefank@4298 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
stefank@4298 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
stefank@4298 | 13 | * accompanied this code). |
stefank@4298 | 14 | * |
stefank@4298 | 15 | * You should have received a copy of the GNU General Public License version |
stefank@4298 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
stefank@4298 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
stefank@4298 | 18 | * |
stefank@4298 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
stefank@4298 | 20 | * or visit www.oracle.com if you need additional information or have any |
stefank@4298 | 21 | * questions. |
stefank@4298 | 22 | * |
stefank@4298 | 23 | */ |
stefank@4298 | 24 | |
stefank@4298 | 25 | /* |
stefank@4298 | 26 | * @test |
stefank@4298 | 27 | * @bug 8003720 |
stefank@4298 | 28 | * @summary Method in interpreter stack frame can be deallocated |
stefank@4305 | 29 | * @compile -XDignore.symbol.file -source 1.7 -target 1.7 Victim.java |
stefank@4298 | 30 | * @run main/othervm -Xverify:all -Xint Test8003720 |
stefank@4298 | 31 | */ |
stefank@4298 | 32 | |
stefank@4298 | 33 | // Attempts to make the JVM unload a class while still executing one of its methods. |
stefank@4298 | 34 | public class Test8003720 { |
stefank@4298 | 35 | final static String VICTIM_CLASS_NAME = "Victim"; |
stefank@4298 | 36 | final static boolean QUIET = true; |
stefank@4298 | 37 | final static long DURATION = 30000; |
stefank@4298 | 38 | |
stefank@4298 | 39 | public interface CallMe { void callme(); } |
stefank@4298 | 40 | |
stefank@4298 | 41 | public static void main(String... av) throws Throwable { |
stefank@4298 | 42 | newVictimClassLoader(); |
stefank@4298 | 43 | System.gc(); |
stefank@4298 | 44 | |
stefank@4298 | 45 | newVictimClass(); |
stefank@4298 | 46 | System.gc(); |
stefank@4298 | 47 | |
stefank@4298 | 48 | newVictimInstance(); |
stefank@4298 | 49 | System.gc(); |
stefank@4298 | 50 | |
stefank@4298 | 51 | ((CallMe)newVictimInstance()).callme(); |
stefank@4298 | 52 | } |
stefank@4298 | 53 | |
stefank@4298 | 54 | public static Object newVictimInstance() throws Throwable { |
stefank@4298 | 55 | return newVictimClass().newInstance(); |
stefank@4298 | 56 | } |
stefank@4298 | 57 | |
stefank@4298 | 58 | public static Class<?> newVictimClass() throws Throwable { |
stefank@4298 | 59 | return Class.forName(VICTIM_CLASS_NAME, true, new VictimClassLoader()); |
stefank@4298 | 60 | } |
stefank@4298 | 61 | |
stefank@4298 | 62 | public static ClassLoader newVictimClassLoader() throws Throwable { |
stefank@4298 | 63 | return new VictimClassLoader(); |
stefank@4298 | 64 | } |
stefank@4298 | 65 | |
stefank@4298 | 66 | public static void println(String line) { |
stefank@4298 | 67 | if (!QUIET) { |
stefank@4298 | 68 | System.out.println(line); |
stefank@4298 | 69 | } |
stefank@4298 | 70 | } |
stefank@4298 | 71 | } |