8308073: ClassLoaderExt::append_boot_classpath should handle dynamic archive

Reviewed-by: iklam, matsaave
This commit is contained in:
Calvin Cheung 2023-05-25 21:26:54 +00:00
parent 4870234552
commit dc7683a051
3 changed files with 8 additions and 8 deletions
src/hotspot/share/classfile
test/hotspot/jtreg/runtime/cds/appcds

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "cds/cds_globals.hpp"
#include "cds/dynamicArchive.hpp"
#include "cds/filemap.hpp"
#include "cds/heapShared.hpp"
#include "classfile/classFileParser.hpp"
@ -60,6 +61,9 @@ void ClassLoaderExt::append_boot_classpath(ClassPathEntry* new_entry) {
if (UseSharedSpaces) {
warning("Sharing is only supported for boot loader classes because bootstrap classpath has been appended");
FileMapInfo::current_info()->set_has_platform_or_app_classes(false);
if (DynamicArchive::is_mapped()) {
FileMapInfo::dynamic_info()->set_has_platform_or_app_classes(false);
}
}
ClassLoader::add_to_boot_append_entries(new_entry);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
@ -81,9 +81,7 @@ public class JvmtiAddPath {
run(check_appcds_enabled, appJar, "-Xlog:class+load", "JvmtiApp", "noadd"); // appcds should be enabled
System.out.println("Test case 2: add to boot classpath only - should find Hello.class in boot loader");
String[] toCheck = (TestCommon.isDynamicArchive()) ? check_appcds_enabled
: check_appcds_disabled;
run(toCheck, appJar, "-Xlog:class+load", "JvmtiApp", "bootonly", addbootJar); // appcds should be disabled
run(check_appcds_disabled, appJar, "-Xlog:class+load", "JvmtiApp", "bootonly", addbootJar); // appcds should be disabled
System.out.println("Test case 3: add to app classpath only - should find Hello.class in app loader");
run(appJar, "JvmtiApp", "apponly", addappJar);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -119,9 +119,7 @@ public class JvmtiAddPath {
"-Xlog:class+load", "JvmtiApp", "noadd", MAIN_CLASS); // appcds should be enabled
System.out.println("Test case 2: add to boot classpath only - should find Hello.class in boot loader");
String[] toCheck = TestCommon.isDynamicArchive() ? check_appcds_enabled :
check_appcds_disabled;
run(toCheck, appJar,
run(check_appcds_disabled, appJar,
"-Xlog:class+load=trace",
modulePath,
"JvmtiApp", "bootonly", addbootJar, MAIN_CLASS); // appcds should be disabled