2018-08-13 17:21:43 +00:00
|
|
|
/*
|
2023-02-15 05:12:39 +00:00
|
|
|
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
2018-08-13 17:21:43 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
2018-11-20 20:12:46 +00:00
|
|
|
* @summary Test primitive box caches integrity in various scenarios (IntegerCache etc)
|
2021-09-10 22:45:26 +00:00
|
|
|
* @requires vm.cds.write.archived.java.heap
|
2019-07-29 14:34:20 +00:00
|
|
|
* @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
2018-08-13 17:21:43 +00:00
|
|
|
* @compile CheckIntegerCacheApp.java
|
2021-03-13 14:51:53 +00:00
|
|
|
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar boxCache.jar CheckIntegerCacheApp
|
2018-10-02 21:32:33 +00:00
|
|
|
* @run driver ArchivedIntegerCacheTest
|
2018-08-13 17:21:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Paths;
|
2020-12-08 20:00:10 +00:00
|
|
|
import jdk.test.lib.cds.CDSTestUtils;
|
2018-08-13 17:21:43 +00:00
|
|
|
import jdk.test.lib.process.OutputAnalyzer;
|
2021-03-12 23:13:16 +00:00
|
|
|
import jdk.test.lib.helpers.ClassFileInstaller;
|
2018-08-13 17:21:43 +00:00
|
|
|
|
|
|
|
public class ArchivedIntegerCacheTest {
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
2018-11-20 20:12:46 +00:00
|
|
|
String appJar = ClassFileInstaller.getJarPath("boxCache.jar");
|
2018-08-13 17:21:43 +00:00
|
|
|
|
2020-12-08 20:00:10 +00:00
|
|
|
Path userDir = Paths.get(CDSTestUtils.getOutputDir());
|
2018-08-13 17:21:43 +00:00
|
|
|
Path moduleDir = Files.createTempDirectory(userDir, "mods");
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dump default archive
|
|
|
|
//
|
|
|
|
OutputAnalyzer output = TestCommon.dump(appJar,
|
2023-04-21 15:29:45 +00:00
|
|
|
TestCommon.list("CheckIntegerCacheApp"));
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkDump(output);
|
|
|
|
|
|
|
|
// Test case 1)
|
|
|
|
// - Default options
|
|
|
|
System.out.println("----------------------- Test case 1 ----------------------");
|
2023-04-21 15:29:45 +00:00
|
|
|
output = TestCommon.exec(appJar,
|
2018-08-13 17:21:43 +00:00
|
|
|
"CheckIntegerCacheApp",
|
2023-04-21 15:29:45 +00:00
|
|
|
"127");
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkExec(output);
|
|
|
|
|
|
|
|
// Test case 2)
|
|
|
|
// - Default archive
|
|
|
|
// - Larger -XX:AutoBoxCacheMax
|
|
|
|
System.out.println("----------------------- Test case 2 ----------------------");
|
2023-04-21 15:29:45 +00:00
|
|
|
output = TestCommon.exec(appJar,
|
2018-08-13 17:21:43 +00:00
|
|
|
"-XX:AutoBoxCacheMax=20000",
|
|
|
|
"CheckIntegerCacheApp",
|
2023-04-21 15:29:45 +00:00
|
|
|
"20000");
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkExec(output);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dump with -XX:AutoBoxCacheMax specified
|
|
|
|
//
|
|
|
|
output = TestCommon.dump(appJar,
|
|
|
|
TestCommon.list("CheckIntegerCacheApp"),
|
2023-04-21 15:29:45 +00:00
|
|
|
"-XX:AutoBoxCacheMax=20000");
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkDump(output);
|
|
|
|
|
|
|
|
// Test case 3)
|
|
|
|
// - Large archived cache
|
|
|
|
// - Default options
|
|
|
|
System.out.println("----------------------- Test case 3 ----------------------");
|
2023-04-21 15:29:45 +00:00
|
|
|
output = TestCommon.exec(appJar,
|
2018-08-13 17:21:43 +00:00
|
|
|
"--module-path",
|
|
|
|
moduleDir.toString(),
|
|
|
|
"CheckIntegerCacheApp",
|
2023-04-21 15:29:45 +00:00
|
|
|
"127");
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkExec(output);
|
|
|
|
|
|
|
|
|
|
|
|
// Test case 4)
|
|
|
|
// - Large archived cache
|
|
|
|
// - Matching options
|
|
|
|
System.out.println("----------------------- Test case 4 ----------------------");
|
2023-04-21 15:29:45 +00:00
|
|
|
output = TestCommon.exec(appJar,
|
2018-08-13 17:21:43 +00:00
|
|
|
"--module-path",
|
|
|
|
moduleDir.toString(),
|
|
|
|
"-XX:AutoBoxCacheMax=20000",
|
|
|
|
"CheckIntegerCacheApp",
|
2023-04-21 15:29:45 +00:00
|
|
|
"20000");
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkExec(output);
|
|
|
|
|
|
|
|
// Test case 5)
|
|
|
|
// - Large archived cache
|
|
|
|
// - Larger requested cache
|
|
|
|
System.out.println("----------------------- Test case 5 ----------------------");
|
2023-04-21 15:29:45 +00:00
|
|
|
output = TestCommon.exec(appJar,
|
2018-08-13 17:21:43 +00:00
|
|
|
"--module-path",
|
|
|
|
moduleDir.toString(),
|
|
|
|
"-XX:AutoBoxCacheMax=30000",
|
|
|
|
"CheckIntegerCacheApp",
|
2023-04-21 15:29:45 +00:00
|
|
|
"30000");
|
2018-08-13 17:21:43 +00:00
|
|
|
TestCommon.checkExec(output);
|
2018-08-16 21:29:22 +00:00
|
|
|
|
|
|
|
// Test case 6)
|
|
|
|
// - Cache is too large to archive
|
|
|
|
output = TestCommon.dump(appJar,
|
|
|
|
TestCommon.list("CheckIntegerCacheApp"),
|
|
|
|
"-XX:AutoBoxCacheMax=2000000",
|
|
|
|
"-Xmx1g",
|
|
|
|
"-XX:NewSize=1g",
|
|
|
|
"-Xlog:cds+heap=info",
|
2018-12-04 06:27:24 +00:00
|
|
|
"-Xlog:gc+region+cds",
|
2023-04-21 15:29:45 +00:00
|
|
|
"-Xlog:gc+region=trace");
|
2018-08-16 21:29:22 +00:00
|
|
|
TestCommon.checkDump(output,
|
2023-02-15 05:12:39 +00:00
|
|
|
"Cannot archive the sub-graph referenced from [Ljava.lang.Integer; object");
|
2018-08-13 17:21:43 +00:00
|
|
|
}
|
|
|
|
}
|