8271420: Extend CDS custom loader support to Windows platform

Reviewed-by: iklam, ccheung
This commit is contained in:
Yumin Qi 2021-11-03 23:16:15 +00:00
parent ce8c76700b
commit 603bba282a
4 changed files with 5 additions and 6 deletions

View File

@ -446,9 +446,9 @@ void ClassListParser::error(const char* msg, ...) {
// 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(_LP64) && (defined(LINUX) || defined(__APPLE__)))
#if !(defined(_LP64) && (defined(LINUX) || defined(__APPLE__) || defined(_WINDOWS)))
// The only supported platforms are: (1) Linux/64-bit and (2) Solaris/64-bit and
// (3) MacOSX/64-bit
// (3) MacOSX/64-bit and (4) Windowss/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");

View File

@ -51,7 +51,6 @@ import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import jdk.test.lib.Asserts;
import jdk.test.lib.helpers.ClassFileInstaller;
import jdk.test.lib.Platform;
public class LoaderConstraintsTest {
static String mainClass = LoaderConstraintsApp.class.getName();

View File

@ -40,7 +40,7 @@ public class CustomAppLoader {
// args[2...] = arguments for the main class
public static void main(String args[]) throws Throwable {
File f = new File(args[0]);
URL[] classLoaderUrls = new URL[] {new URL("file://" + f.getCanonicalPath())};
URL[] classLoaderUrls = new URL[] {f.getAbsoluteFile().toURI().toURL()};
URLClassLoader loader = new URLClassLoader(classLoaderUrls, CustomAppLoader.class.getClassLoader());
Class k = Class.forName(args[1], true, loader);
Class parameterTypes[] = new Class[] {String[].class};

View File

@ -387,6 +387,6 @@ public class Platform {
* This should match the #if condition in ClassListParser::load_class_from_source().
*/
public static boolean areCustomLoadersSupportedForCDS() {
return (is64bit() && (isLinux() || isOSX()));
return (is64bit() && (isLinux() || isOSX() || isWindows()));
}
}