Skip to content

Commit 003be0d

Browse files
committed
8361325: Refactor ClassLoaderExt
Reviewed-by: coleenp, sspitsyn
1 parent 2d9f032 commit 003be0d

14 files changed

+63
-169
lines changed

src/hotspot/share/cds/archiveBuilder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "cds/regeneratedClasses.hpp"
3939
#include "classfile/classLoader.hpp"
4040
#include "classfile/classLoaderDataShared.hpp"
41-
#include "classfile/classLoaderExt.hpp"
4241
#include "classfile/javaClasses.hpp"
4342
#include "classfile/symbolTable.hpp"
4443
#include "classfile/systemDictionaryShared.hpp"

src/hotspot/share/cds/cdsProtectionDomain.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "cds/cdsProtectionDomain.hpp"
2828
#include "classfile/classLoader.hpp"
2929
#include "classfile/classLoaderData.inline.hpp"
30-
#include "classfile/classLoaderExt.hpp"
3130
#include "classfile/javaClasses.hpp"
3231
#include "classfile/moduleEntry.hpp"
3332
#include "classfile/systemDictionaryShared.hpp"

src/hotspot/share/cds/classListParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "cds/lambdaProxyClassDictionary.hpp"
3131
#include "cds/metaspaceShared.hpp"
3232
#include "cds/unregisteredClasses.hpp"
33-
#include "classfile/classLoaderExt.hpp"
33+
#include "classfile/classLoader.hpp"
3434
#include "classfile/javaClasses.inline.hpp"
3535
#include "classfile/symbolTable.hpp"
3636
#include "classfile/systemDictionary.hpp"

src/hotspot/share/cds/filemap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "classfile/classLoader.hpp"
4040
#include "classfile/classLoader.inline.hpp"
4141
#include "classfile/classLoaderData.inline.hpp"
42-
#include "classfile/classLoaderExt.hpp"
4342
#include "classfile/symbolTable.hpp"
4443
#include "classfile/systemDictionaryShared.hpp"
4544
#include "classfile/vmClasses.hpp"

src/hotspot/share/cds/heapShared.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "cds/metaspaceShared.hpp"
3939
#include "cds/regeneratedClasses.hpp"
4040
#include "classfile/classLoaderData.hpp"
41-
#include "classfile/classLoaderExt.hpp"
4241
#include "classfile/javaClasses.inline.hpp"
4342
#include "classfile/modules.hpp"
4443
#include "classfile/stringTable.hpp"

src/hotspot/share/cds/metaspaceShared.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include "cds/metaspaceShared.hpp"
5050
#include "classfile/classLoaderDataGraph.hpp"
5151
#include "classfile/classLoaderDataShared.hpp"
52-
#include "classfile/classLoaderExt.hpp"
5352
#include "classfile/javaClasses.inline.hpp"
5453
#include "classfile/loaderConstraints.hpp"
5554
#include "classfile/modules.hpp"

src/hotspot/share/classfile/classLoader.cpp

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
#include "cds/aotClassLocation.hpp"
2626
#include "cds/cds_globals.hpp"
2727
#include "cds/cdsConfig.hpp"
28+
#include "cds/dynamicArchive.hpp"
2829
#include "cds/heapShared.hpp"
2930
#include "classfile/classFileStream.hpp"
3031
#include "classfile/classLoader.inline.hpp"
3132
#include "classfile/classLoaderData.inline.hpp"
32-
#include "classfile/classLoaderExt.hpp"
3333
#include "classfile/classLoadInfo.hpp"
3434
#include "classfile/javaClasses.hpp"
3535
#include "classfile/klassFactory.hpp"
@@ -1283,7 +1283,47 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
12831283
const char* const file_name = file_name_for_class_name(class_name,
12841284
ik->name()->utf8_length());
12851285
assert(file_name != nullptr, "invariant");
1286-
ClassLoaderExt::record_result_for_builtin_loader(checked_cast<s2>(classpath_index), ik, redefined);
1286+
record_result_for_builtin_loader(checked_cast<s2>(classpath_index), ik, redefined);
1287+
}
1288+
1289+
void ClassLoader::record_result_for_builtin_loader(s2 classpath_index, InstanceKlass* result, bool redefined) {
1290+
assert(CDSConfig::is_dumping_archive(), "sanity");
1291+
1292+
oop loader = result->class_loader();
1293+
if (SystemDictionary::is_system_class_loader(loader)) {
1294+
AOTClassLocationConfig::dumptime_set_has_app_classes();
1295+
} else if (SystemDictionary::is_platform_class_loader(loader)) {
1296+
AOTClassLocationConfig::dumptime_set_has_platform_classes();
1297+
} else {
1298+
precond(loader == nullptr);
1299+
}
1300+
1301+
if (CDSConfig::is_dumping_preimage_static_archive() || CDSConfig::is_dumping_dynamic_archive()) {
1302+
if (!AOTClassLocationConfig::dumptime()->is_valid_classpath_index(classpath_index, result)) {
1303+
classpath_index = -1;
1304+
}
1305+
}
1306+
1307+
AOTClassLocationConfig::dumptime_update_max_used_index(classpath_index);
1308+
result->set_shared_classpath_index(classpath_index);
1309+
1310+
#if INCLUDE_CDS_JAVA_HEAP
1311+
if (CDSConfig::is_dumping_heap() && AllowArchivingWithJavaAgent && result->defined_by_boot_loader() &&
1312+
classpath_index < 0 && redefined) {
1313+
// When dumping the heap (which happens only during static dump), classes for the built-in
1314+
// loaders are always loaded from known locations (jimage, classpath or modulepath),
1315+
// so classpath_index should always be >= 0.
1316+
// The only exception is when a java agent is used during dump time (for testing
1317+
// purposes only). If a class is transformed by the agent, the AOTClassLocation of
1318+
// this class may point to an unknown location. This may break heap object archiving,
1319+
// which requires all the boot classes to be from known locations. This is an
1320+
// uncommon scenario (even in test cases). Let's simply disable heap object archiving.
1321+
ResourceMark rm;
1322+
log_warning(aot)("heap objects cannot be written because class %s maybe modified by ClassFileLoadHook.",
1323+
result->external_name());
1324+
CDSConfig::disable_heap_dumping();
1325+
}
1326+
#endif // INCLUDE_CDS_JAVA_HEAP
12871327
}
12881328

12891329
void ClassLoader::record_hidden_class(InstanceKlass* ik) {
@@ -1308,6 +1348,17 @@ void ClassLoader::record_hidden_class(InstanceKlass* ik) {
13081348
}
13091349
}
13101350
}
1351+
1352+
void ClassLoader::append_boot_classpath(ClassPathEntry* new_entry) {
1353+
if (CDSConfig::is_using_archive()) {
1354+
warning("Sharing is only supported for boot loader classes because bootstrap classpath has been appended");
1355+
FileMapInfo::current_info()->set_has_platform_or_app_classes(false);
1356+
if (DynamicArchive::is_mapped()) {
1357+
FileMapInfo::dynamic_info()->set_has_platform_or_app_classes(false);
1358+
}
1359+
}
1360+
add_to_boot_append_entries(new_entry);
1361+
}
13111362
#endif // INCLUDE_CDS
13121363

13131364
// Initialize the class loader's access to methods in libzip. Parse and

src/hotspot/share/classfile/classLoader.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ class ClassLoader: AllStatic {
345345
static char* uri_to_path(const char* uri);
346346
static void record_result(JavaThread* current, InstanceKlass* ik,
347347
const ClassFileStream* stream, bool redefined);
348+
static void record_result_for_builtin_loader(s2 classpath_index, InstanceKlass* result, bool redefined);
348349
static void record_hidden_class(InstanceKlass* ik);
350+
static void append_boot_classpath(ClassPathEntry* new_entry);
349351
#endif
350352

351353
static char* lookup_vm_options();

src/hotspot/share/classfile/classLoaderExt.cpp

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/hotspot/share/classfile/classLoaderExt.hpp

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)