test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52811 ff04b71bf6f1
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
       
     1 /*
       
     2  * Copyright (c) 2018, 2019, 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  * @summary Test how CDS dumping handles the existence of humongous G1 regions.
       
    28  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes
       
    29  * @requires vm.cds.archived.java.heap
       
    30  * @requires vm.flavor != "minimal"
       
    31  * @build HumongousDuringDumpTransformer Hello
       
    32  * @run main/othervm/timeout=240 HumongousDuringDump
       
    33  */
       
    34 
       
    35 import jdk.test.lib.cds.CDSOptions;
       
    36 import jdk.test.lib.process.OutputAnalyzer;
       
    37 import jdk.test.lib.process.ProcessTools;
       
    38 
       
    39 public class HumongousDuringDump {
       
    40     public static String appClasses[] = {
       
    41         "Hello",
       
    42     };
       
    43     public static String agentClasses[] = {
       
    44         "HumongousDuringDumpTransformer",
       
    45     };
       
    46 
       
    47     public static void main(String[] args) throws Throwable {
       
    48         String agentJar =
       
    49             ClassFileInstaller.writeJar("HumongousDuringDumpTransformer.jar",
       
    50                                         ClassFileInstaller.Manifest.fromSourceFile("HumongousDuringDumpTransformer.mf"),
       
    51                                         agentClasses);
       
    52 
       
    53         String appJar =
       
    54             ClassFileInstaller.writeJar("HumongousDuringDumpApp.jar", appClasses);
       
    55 
       
    56         String gcLog = Boolean.getBoolean("test.cds.verbose.gc") ?
       
    57             "-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug" : "-showversion";
       
    58 
       
    59         String extraArg = "-javaagent:" + agentJar;
       
    60         String extraOption = "-XX:+AllowArchivingWithJavaAgent";
       
    61 
       
    62         OutputAnalyzer out =
       
    63           TestCommon.testDump(appJar, TestCommon.list("Hello"),
       
    64                               "-XX:+UnlockDiagnosticVMOptions", extraOption,
       
    65                               "-Xlog:gc+region+cds",
       
    66                               "-Xlog:gc+region=trace",
       
    67                               extraArg, "-Xmx64m", gcLog);
       
    68         out.shouldContain("(Unmovable) humongous regions have been found and may lead to fragmentation");
       
    69         out.shouldContain("All free regions should be at the top end of the heap, but we found holes.");
       
    70         out.shouldMatch("gc,region,cds. HeapRegion .* HUM. hole");
       
    71         String pattern = "gc,region,cds. HeapRegion .*hole";
       
    72         out.shouldMatch(pattern);
       
    73         out.shouldNotMatch(pattern + ".*unexpected");
       
    74 
       
    75         TestCommon.run(
       
    76                 "-cp", appJar,
       
    77                 "-verbose",
       
    78                 "-Xmx64m",
       
    79                 "-XX:+PrintSharedSpaces",
       
    80                 "-XX:+UnlockDiagnosticVMOptions", extraOption,
       
    81                 gcLog,
       
    82                 "Hello")
       
    83               .assertNormalExit();
       
    84     }
       
    85 }
       
    86