8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
authoriklam
Tue, 28 Nov 2017 09:47:04 -0800
changeset 48155 551de50b4ff7
parent 48154 dea4d68f1340
child 48156 a8f9aac3c2e5
8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX Summary: Added "@requires vm.cds.custom.loaders" to mark tests related to custom loaders Reviewed-by: simonis, mseledtsov Contributed-by: volker.simonis@gmail.com
src/hotspot/share/classfile/classListParser.cpp
test/hotspot/jtreg/TEST.ROOT
test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java
test/hotspot/jtreg/runtime/appcds/TestCommon.java
test/hotspot/jtreg/runtime/appcds/cacheObject/CheckCachedResolvedReferences.java
test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatA.java
test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatB.java
test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatC.java
test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatD.java
test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatE.java
test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java
test/hotspot/jtreg/runtime/appcds/customLoader/LoaderSegregationTest.java
test/hotspot/jtreg/runtime/appcds/customLoader/ParallelTestMultiFP.java
test/hotspot/jtreg/runtime/appcds/customLoader/ParallelTestSingleFP.java
test/hotspot/jtreg/runtime/appcds/customLoader/ProhibitedPackageNamesTest.java
test/hotspot/jtreg/runtime/appcds/customLoader/ProtectionDomain.java
test/hotspot/jtreg/runtime/appcds/customLoader/SameNameInTwoLoadersTest.java
test/hotspot/jtreg/runtime/appcds/customLoader/UnintendedLoadersTest.java
test/hotspot/jtreg/runtime/appcds/customLoader/UnloadUnregisteredLoaderTest.java
test/hotspot/jtreg/runtime/appcds/customLoader/UnsupportedPlatforms.java
test/hotspot/jtreg/runtime/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java
test/jtreg-ext/requires/VMProps.java
test/lib/jdk/test/lib/Platform.java
--- a/src/hotspot/share/classfile/classListParser.cpp	Wed Nov 29 16:45:31 2017 -0800
+++ b/src/hotspot/share/classfile/classListParser.cpp	Tue Nov 28 09:47:04 2017 -0800
@@ -272,9 +272,11 @@
 // This function is used for loading classes for customized class loaders
 // during archive dumping.
 InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS) {
-#if !((defined(LINUX) && defined(X86) && defined(_LP64)) || \
-      (defined(SOLARIS) && defined(_LP64)))
-  // The only supported platforms are: (1) Linux/AMD64; (2) Solaris/64-bit
+#if !(defined(_LP64) && (defined(LINUX)|| defined(SOLARIS) || defined(AIX)))
+  // The only supported platforms are: (1) Linux/64-bit; (2) Solaris/64-bit; (3) AIX/64-bit
+  //
+  // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
+  // method in test/lib/jdk/test/lib/Platform.java.
   error("AppCDS custom class loaders not supported on this platform");
 #endif
 
--- a/test/hotspot/jtreg/TEST.ROOT	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/TEST.ROOT	Tue Nov 28 09:47:04 2017 -0800
@@ -53,6 +53,7 @@
     vm.rtm.os \
     vm.aot \
     vm.cds \
+    vm.cds.custom.loaders \
     vm.graal.enabled \
     docker.support
 
--- a/test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java	Tue Nov 28 09:47:04 2017 -0800
@@ -27,6 +27,7 @@
  * @summary AppCDS handling of prohibited package.
  * AppCDS does not support uncompressed oops
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires vm.cds
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
@@ -45,10 +46,8 @@
 
         String appJar = TestCommon.getTestJar("prohibited_pkg.jar");
 
-        // AppCDS for custom loader is only supported on linux-x64 and
-        // Solaris 64-bit platforms.
-        if ((Platform.isLinux() || Platform.isSolaris()) &&
-            Platform.is64bit()) {
+        // Test support for customer loaders
+        if (Platform.areCustomLoadersSupportedForCDS()) {
             String classlist[] = new String[] {
                 "java/lang/Object id: 1",
                 "java/lang/Prohibited id: 2 super: 1 source: " + appJar
--- a/test/hotspot/jtreg/runtime/appcds/TestCommon.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/TestCommon.java	Tue Nov 28 09:47:04 2017 -0800
@@ -321,19 +321,4 @@
         }
         return dirFile.getPath();
     }
-
-
-    // Returns true if custom loader is supported, based on a platform.
-    // Custom loader AppCDS is only supported for Linux-x64 and Solaris.
-    public static boolean isCustomLoaderSupported() {
-        boolean isLinux = Platform.isLinux();
-        boolean isX64 = Platform.isX64();
-        boolean isSolaris = Platform.isSolaris();
-
-        System.out.println("isCustomLoaderSupported: isX64 = " + isX64);
-        System.out.println("isCustomLoaderSupported: isLinux = " + isLinux);
-        System.out.println("isCustomLoaderSupported: isSolaris = " + isSolaris);
-
-        return ((isX64 && isLinux) || isSolaris);
-    }
 }
--- a/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckCachedResolvedReferences.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckCachedResolvedReferences.java	Tue Nov 28 09:47:04 2017 -0800
@@ -26,8 +26,7 @@
  * @test
  * @summary Test resolved_references
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @requires (vm.gc=="null")
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
@@ -53,9 +52,9 @@
         String helloJarPath = ClassFileInstaller.getJarPath("hello.jar");
 
         String classlist[] = new String[] {
-            "CheckCachedResolvedReferencesApp",
-            "java/lang/Object id: 1",
-            "Hello id: 2 super: 1 source: " + helloJarPath
+            "CheckCachedResolvedReferencesApp",            // built-in app loader
+            "java/lang/Object id: 1",                      // boot loader
+            "Hello id: 2 super: 1 source: " + helloJarPath // custom loader
         };
 
         TestCommon.testDump(appJar, classlist, use_whitebox_jar);
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatA.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatA.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatB.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatB.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatC.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatC.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatD.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatD.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatE.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ClassListFormatE.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java	Tue Nov 28 09:47:04 2017 -0800
@@ -27,8 +27,7 @@
  * @summary Hello World test for AppCDS custom loader support
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/LoaderSegregationTest.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/LoaderSegregationTest.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *          custom loader classes.
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ParallelTestMultiFP.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ParallelTestMultiFP.java	Tue Nov 28 09:47:04 2017 -0800
@@ -27,8 +27,7 @@
  * @summary Load classes from CDS archive into multiple custom loader using parallel threads
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ParallelTestSingleFP.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ParallelTestSingleFP.java	Tue Nov 28 09:47:04 2017 -0800
@@ -27,8 +27,7 @@
  * @summary Load classes from CDS archive into a single custom loader using parallel threads (finger print)
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ProhibitedPackageNamesTest.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ProhibitedPackageNamesTest.java	Tue Nov 28 09:47:04 2017 -0800
@@ -27,8 +27,7 @@
  * @summary Make sure prohibited packages cannot be stored into archive for custom loaders.
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/ProtectionDomain.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/ProtectionDomain.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * AppCDS does not support uncompressed oops
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  *
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/SameNameInTwoLoadersTest.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/SameNameInTwoLoadersTest.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  *
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/UnintendedLoadersTest.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/UnintendedLoadersTest.java	Tue Nov 28 09:47:04 2017 -0800
@@ -27,8 +27,7 @@
  * @summary Make sure classes intended for custom loaders cannot be loaded by BOOT/EXT/APP loaders
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/UnloadUnregisteredLoaderTest.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/UnloadUnregisteredLoaderTest.java	Tue Nov 28 09:47:04 2017 -0800
@@ -28,8 +28,7 @@
  *          unloaded.
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
- * @requires (sun.arch.data.model == "64")
- * @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
+ * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds /test/hotspot/jtreg/runtime/testlibrary
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/UnsupportedPlatforms.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/UnsupportedPlatforms.java	Tue Nov 28 09:47:04 2017 -0800
@@ -25,9 +25,9 @@
 /*
  * @test
  * @summary Ensure that support for AppCDS custom class loaders are not enabled on unsupported platforms.
- * The only supported platforms are Linux/AMD64 and 64-bit Solaris.
  * (NOTE: AppCDS does not support uncompressed oops)
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires vm.cds
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
@@ -55,8 +55,7 @@
 
         OutputAnalyzer out = TestCommon.dump(appJar, classlist);
 
-        if ((Platform.isSolaris() && Platform.is64bit()) ||
-            (Platform.isLinux() && Platform.isX64())) {
+        if (Platform.areCustomLoadersSupportedForCDS()) {
             out.shouldNotContain(PLATFORM_NOT_SUPPORTED_WARNING);
             out.shouldHaveExitValue(0);
         } else {
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/transformRelatedClasses/TransformRelatedClassesAppCDS.java	Tue Nov 28 09:47:04 2017 -0800
@@ -39,6 +39,7 @@
 
 import java.io.File;
 import java.util.ArrayList;
+import jdk.test.lib.Platform;
 import jdk.test.lib.process.OutputAnalyzer;
 
 // This class is intended to test 2 parent-child relationships:
@@ -148,7 +149,7 @@
 
 
     private void runWithCustomLoader(ArrayList<TestEntry> testTable) throws Exception {
-        if (!TestCommon.isCustomLoaderSupported()) {
+        if (!Platform.areCustomLoadersSupportedForCDS()) {
             log("custom loader not supported for this platform" +
                 " - skipping test case for custom loader");
             return;
--- a/test/jtreg-ext/requires/VMProps.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/jtreg-ext/requires/VMProps.java	Tue Nov 28 09:47:04 2017 -0800
@@ -74,6 +74,7 @@
         map.put("vm.aot", vmAOT());
         // vm.cds is true if the VM is compiled with cds support.
         map.put("vm.cds", vmCDS());
+        map.put("vm.cds.custom.loaders", vmCDSForCustomLoaders());
         // vm.graal.enabled is true if Graal is used as JIT
         map.put("vm.graal.enabled", isGraalEnabled());
         map.put("docker.support", dockerSupport());
@@ -297,6 +298,19 @@
     }
 
     /**
+     * Check for CDS support for custom loaders.
+     *
+     * @return true if CDS is supported for customer loader by the VM to be tested.
+     */
+    protected String vmCDSForCustomLoaders() {
+        if (vmCDS().equals("true") && Platform.areCustomLoadersSupportedForCDS()) {
+            return "true";
+        } else {
+            return "false";
+        }
+    }
+
+    /**
      * Check if Graal is used as JIT compiler.
      *
      * @return true if Graal is used as JIT compiler.
--- a/test/lib/jdk/test/lib/Platform.java	Wed Nov 29 16:45:31 2017 -0800
+++ b/test/lib/jdk/test/lib/Platform.java	Tue Nov 28 09:47:04 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -288,4 +288,16 @@
             return "so";
         }
     }
+
+    /*
+     * This should match the #if condition in ClassListParser::load_class_from_source().
+     */
+    public static boolean areCustomLoadersSupportedForCDS() {
+        boolean isLinux = Platform.isLinux();
+        boolean is64 = Platform.is64bit();
+        boolean isSolaris = Platform.isSolaris();
+        boolean isAix = Platform.isAix();
+
+        return (is64 && (isLinux || isSolaris || isAix));
+    }
 }