test/hotspot/jtreg/runtime/appcds/jigsaw/PatchModule/PatchJavaBase.java
changeset 54927 1512d88b24c6
parent 51990 6003e034cdd8
equal deleted inserted replaced
54926:d4e7ccaf1445 54927:1512d88b24c6
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    56 
    56 
    57         JarBuilder.build("javabase", "java/lang/NewClass");
    57         JarBuilder.build("javabase", "java/lang/NewClass");
    58         moduleJar = TestCommon.getTestJar("javabase.jar");
    58         moduleJar = TestCommon.getTestJar("javabase.jar");
    59 
    59 
    60         System.out.println("Test dumping with --patch-module");
    60         System.out.println("Test dumping with --patch-module");
       
    61         String runError = "Unable to use shared archive: CDS is disabled when java.base module is patched";
       
    62         String dumpingError = "Cannot use the following option when dumping the shared archive: --patch-module";
       
    63         String errMsg;
       
    64         if (TestCommon.isDynamicArchive()) {
       
    65             errMsg = runError;
       
    66         } else {
       
    67             errMsg = dumpingError;
       
    68         }
    61         OutputAnalyzer output =
    69         OutputAnalyzer output =
    62             TestCommon.dump(null, null,
    70             TestCommon.dump(null, null,
    63                 "--patch-module=java.base=" + moduleJar,
    71                 "--patch-module=java.base=" + moduleJar,
    64                 "PatchMain", "java.lang.NewClass");
    72                 "PatchMain", "java.lang.NewClass");
    65         output.shouldHaveExitValue(1)
    73         output.shouldHaveExitValue(1)
    66               .shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
    74               .shouldContain(errMsg);
    67 
    75 
    68         TestCommon.run(
    76         TestCommon.run(
    69             "-XX:+UnlockDiagnosticVMOptions",
    77             "-XX:+UnlockDiagnosticVMOptions",
    70             "--patch-module=java.base=" + moduleJar,
    78             "--patch-module=java.base=" + moduleJar,
    71             "PatchMain", "java.lang.NewClass")
    79             "PatchMain", "java.lang.NewClass")
    72           .assertAbnormalExit("Unable to use shared archive",
    80           .assertAbnormalExit(runError);
    73                               "CDS is disabled when java.base module is patched");
       
    74     }
    81     }
    75 }
    82 }