annotate test/runtime/ClassUnload/UnloadTest.java @ 10374:87c64c0438fb

6976350: G1: deal with fragmentation while copying objects during GC Summary: Create G1ParGCAllocBufferContainer to contain two buffers instead of previously using one buffer, in order to hold the first priority buffer longer. Thus, when some large objects hits the value of free space left in the first priority buffer it has an alternative to fit in the second priority buffer while the first priority buffer is given more chances to try allocating smaller objects. Overall, it will improve heap space efficiency. Reviewed-by: johnc, jmasa, brutisso Contributed-by: tamao <tao.mao@oracle.com>
author tamao
date Mon, 03 Jun 2013 14:37:13 -0700
parents 33bcd9ead1d5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10230
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
1 /*
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
4 *
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
7 * published by the Free Software Foundation.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
8 *
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
13 * accompanied this code).
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
14 *
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
18 *
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
21 * questions.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
22 */
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
23
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
24 /*
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
25 * @test UnloadTest
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
26 * @library /runtime/testlibrary /testlibrary /testlibrary/whitebox
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
27 * @library classes
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
28 * @build ClassUnloadCommon test.Empty
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
29 * @build UnloadTest
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
31 * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI UnloadTest
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
32 */
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
33 import sun.hotspot.WhiteBox;
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
34
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
35 /**
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
36 * Test that verifies that classes are unloaded when they are no longer reachable.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
37 *
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
38 * The test creates a class loader, uses the loader to load a class and creates an instance
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
39 * of that class. The it nulls out all the references to the instance, class and class loader
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
40 * and tries to trigger class unloading. Then it verifies that the class is no longer
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
41 * loaded by the VM.
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
42 */
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
43 public class UnloadTest {
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
44 private static String className = "test.Empty";
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
45
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
46 public static void main(String... args) throws Exception {
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
47 run();
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
48 }
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
49
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
50 private static void run() throws Exception {
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
51 final WhiteBox wb = WhiteBox.getWhiteBox();
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
52
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
53 ClassUnloadCommon.failIf(wb.isClassAlive(className), "is not expected to be alive yet");
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
54
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
55 ClassLoader cl = ClassUnloadCommon.newClassLoader();
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
56 Class<?> c = cl.loadClass(className);
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
57 Object o = c.newInstance();
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
58
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
59 ClassUnloadCommon.failIf(!wb.isClassAlive(className), "should be live here");
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
60
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
61 cl = null; c = null; o = null;
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
62 ClassUnloadCommon.triggerUnloading();
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
63 ClassUnloadCommon.failIf(wb.isClassAlive(className), "should have been unloaded");
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
64 }
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
65 }
33bcd9ead1d5 8009577: Test test/closed/runtime/classunload broken
ctornqvi
parents:
diff changeset
66