|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, 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 | +/* |
| 27 | + * @test |
| 28 | + * @bug 8359436 |
| 29 | + * @summary Sanity-check that eager compilation flags are accepted |
| 30 | + * @requires vm.cds |
| 31 | + * @requires vm.flagless |
| 32 | + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
| 33 | + * @build Hello |
| 34 | + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar hello.jar Hello |
| 35 | + * @run driver AOTCompileEagerly |
| 36 | + */ |
| 37 | + |
| 38 | +import java.io.File; |
| 39 | +import jdk.test.lib.cds.CDSTestUtils; |
| 40 | +import jdk.test.lib.helpers.ClassFileInstaller; |
| 41 | +import jdk.test.lib.process.OutputAnalyzer; |
| 42 | +import jdk.test.lib.process.ProcessTools; |
| 43 | + |
| 44 | +public class AOTCompileEagerly { |
| 45 | + static final String appJar = ClassFileInstaller.getJarPath("hello.jar"); |
| 46 | + static final String aotConfigFile = "hello.aotconfig"; |
| 47 | + static final String aotCacheFile = "hello.aot"; |
| 48 | + static final String helloClass = "Hello"; |
| 49 | + |
| 50 | + public static void main(String[] args) throws Exception { |
| 51 | + ProcessBuilder pb; |
| 52 | + OutputAnalyzer out; |
| 53 | + |
| 54 | + //---------------------------------------------------------------------- |
| 55 | + System.out.println("Training Run"); |
| 56 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 57 | + "-XX:AOTMode=record", |
| 58 | + "-XX:AOTConfiguration=" + aotConfigFile, |
| 59 | + "-cp", appJar, helloClass); |
| 60 | + |
| 61 | + out = CDSTestUtils.executeAndLog(pb, "train"); |
| 62 | + out.shouldHaveExitValue(0); |
| 63 | + |
| 64 | + //---------------------------------------------------------------------- |
| 65 | + System.out.println("Assembly Phase"); |
| 66 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 67 | + "-XX:AOTMode=create", |
| 68 | + "-XX:AOTConfiguration=" + aotConfigFile, |
| 69 | + "-XX:AOTCache=" + aotCacheFile, |
| 70 | + "-cp", appJar); |
| 71 | + out = CDSTestUtils.executeAndLog(pb, "asm"); |
| 72 | + out.shouldHaveExitValue(0); |
| 73 | + |
| 74 | + //---------------------------------------------------------------------- |
| 75 | + System.out.println("Production Run with AOTCache defaults"); |
| 76 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 77 | + "-XX:AOTCache=" + aotCacheFile, |
| 78 | + "-cp", appJar, helloClass); |
| 79 | + out = CDSTestUtils.executeAndLog(pb, "prod-default"); |
| 80 | + out.shouldHaveExitValue(0); |
| 81 | + |
| 82 | + //---------------------------------------------------------------------- |
| 83 | + System.out.println("Production Run with AOTCache and eager compilation explicitly ON"); |
| 84 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 85 | + "-XX:AOTCache=" + aotCacheFile, |
| 86 | + "-XX:+UnlockExperimentalVMOptions", |
| 87 | + "-XX:+AOTCompileEagerly", |
| 88 | + "-cp", appJar, helloClass); |
| 89 | + out = CDSTestUtils.executeAndLog(pb, "prod-eager-on"); |
| 90 | + out.shouldHaveExitValue(0); |
| 91 | + |
| 92 | + //---------------------------------------------------------------------- |
| 93 | + System.out.println("Production Run with AOTCache and eager compilation explicitly OFF"); |
| 94 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder( |
| 95 | + "-XX:AOTCache=" + aotCacheFile, |
| 96 | + "-XX:+UnlockExperimentalVMOptions", |
| 97 | + "-XX:-AOTCompileEagerly", |
| 98 | + "-cp", appJar, helloClass); |
| 99 | + out = CDSTestUtils.executeAndLog(pb, "prod-eager-off"); |
| 100 | + out.shouldHaveExitValue(0); |
| 101 | + } |
| 102 | +} |
0 commit comments