|
| 1 | +/* |
| 2 | + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + * |
| 23 | + */ |
| 24 | + |
| 25 | +/* |
| 26 | + * @test |
| 27 | + * @bug 8278602 |
| 28 | + * @summary Lots of classes being unloaded while we try to dump a dynamic archive |
| 29 | + * @requires vm.cds |
| 30 | + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds |
| 31 | + * /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes |
| 32 | + * @build sun.hotspot.WhiteBox |
| 33 | + * @build LotsUnloadApp |
| 34 | + * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox |
| 35 | + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar LotsUnloadApp.jar LotsUnloadApp DefinedAsHiddenKlass |
| 36 | + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LotsUnloadTest |
| 37 | + */ |
| 38 | + |
| 39 | +// Note: for https://bugs.openjdk.java.net/browse/JDK-8278602, this test case does NOT |
| 40 | +// reliably reproduce the problem. Reproduction requires patching ZGC. Please see |
| 41 | +// the bug report for instructions. |
| 42 | +// |
| 43 | +// This test case is included so that it may find a similar bug under stress conditions |
| 44 | +// in the CI runs. |
| 45 | +import jdk.test.lib.helpers.ClassFileInstaller; |
| 46 | + |
| 47 | +public class LotsUnloadTest extends DynamicArchiveTestBase { |
| 48 | + public static void main(String[] args) throws Exception { |
| 49 | + runTest(LotsUnloadTest::test); |
| 50 | + } |
| 51 | + |
| 52 | + static void test() throws Exception { |
| 53 | + String topArchiveName = getNewArchiveName(); |
| 54 | + String appJar = ClassFileInstaller.getJarPath("LotsUnloadApp.jar"); |
| 55 | + String mainClass = "LotsUnloadApp"; |
| 56 | + String logging; |
| 57 | + |
| 58 | + if (Boolean.getBoolean("verbose.LotsUnloadTest")) { |
| 59 | + // class+unload logs may change GC timing and cause the bug to be |
| 60 | + // less reproducible. |
| 61 | + logging = "-Xlog:cds,class+unload"; |
| 62 | + } else { |
| 63 | + logging = "-Xlog:cds"; |
| 64 | + } |
| 65 | + |
| 66 | + dump(topArchiveName, |
| 67 | + logging, |
| 68 | + "-Xmx64m", "-Xms32m", |
| 69 | + "-cp", appJar, mainClass) |
| 70 | + .assertNormalExit(output -> { |
| 71 | + output.shouldHaveExitValue(0); |
| 72 | + }); |
| 73 | + |
| 74 | + run(topArchiveName, |
| 75 | + logging, |
| 76 | + "-Xmx64m", "-Xms32m", |
| 77 | + "-cp", appJar, mainClass) |
| 78 | + .assertNormalExit(output -> { |
| 79 | + output.shouldHaveExitValue(0); |
| 80 | + }); |
| 81 | + } |
| 82 | +} |
0 commit comments