Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8242134: Consolidate the get_package_entry() in SystemDictionaryShare…
Browse files Browse the repository at this point in the history
…d and ClassLoader

Keep the version in ClassLoader.

Reviewed-by: hseigel, redestad, lfoltan
  • Loading branch information
calvinccheung committed Apr 8, 2020
1 parent 0ffbbc8 commit dd4e04d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/hotspot/share/classfile/classLoader.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ Symbol* ClassLoader::package_from_class_name(const Symbol* name, bool* bad_class
return SymbolTable::new_symbol(name, start - base, end - base); return SymbolTable::new_symbol(name, start - base, end - base);
} }


// Given a fully qualified class name, find its defining package in the class loader's // Given a fully qualified package name, find its defining package in the class loader's
// package entry table. // package entry table.
PackageEntry* ClassLoader::get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data, TRAPS) { PackageEntry* ClassLoader::get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data) {
if (pkg_name == NULL) { if (pkg_name == NULL) {
return NULL; return NULL;
} }
Expand Down Expand Up @@ -396,9 +396,9 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(const char* name, C
if (!Universe::is_module_initialized()) { if (!Universe::is_module_initialized()) {
location = (*JImageFindResource)(_jimage, JAVA_BASE_NAME, get_jimage_version_string(), name, &size); location = (*JImageFindResource)(_jimage, JAVA_BASE_NAME, get_jimage_version_string(), name, &size);
} else { } else {
PackageEntry* package_entry = ClassLoader::get_package_entry(pkg_name, loader_data, CHECK_NULL); PackageEntry* package_entry = ClassLoader::get_package_entry(pkg_name, loader_data);
if (package_entry != NULL) { if (package_entry != NULL) {
ResourceMark rm; ResourceMark rm(THREAD);
// Get the module name // Get the module name
ModuleEntry* module = package_entry->module(); ModuleEntry* module = package_entry->module();
assert(module != NULL, "Boot classLoader package missing module"); assert(module != NULL, "Boot classLoader package missing module");
Expand Down Expand Up @@ -1147,7 +1147,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleCl
// Find the class' defining module in the boot loader's module entry table // Find the class' defining module in the boot loader's module entry table
TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name); TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name);
TempNewSymbol pkg_name = package_from_class_name(class_name_symbol); TempNewSymbol pkg_name = package_from_class_name(class_name_symbol);
PackageEntry* pkg_entry = get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data(), CHECK_NULL); PackageEntry* pkg_entry = get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data());
ModuleEntry* mod_entry = (pkg_entry != NULL) ? pkg_entry->module() : NULL; ModuleEntry* mod_entry = (pkg_entry != NULL) ? pkg_entry->module() : NULL;


// If the module system has not defined java.base yet, then // If the module system has not defined java.base yet, then
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/share/classfile/classLoader.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ class ClassLoader: AllStatic {
static bool get_canonical_path(const char* orig, char* out, int len); static bool get_canonical_path(const char* orig, char* out, int len);
static const char* file_name_for_class_name(const char* class_name, static const char* file_name_for_class_name(const char* class_name,
int class_name_len); int class_name_len);
static PackageEntry* get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data, TRAPS); static PackageEntry* get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data);

public:
static int crc32(int crc, const char* buf, int len); static int crc32(int crc, const char* buf, int len);
static bool update_class_path_entry_list(const char *path, static bool update_class_path_entry_list(const char *path,
bool check_for_duplicates, bool check_for_duplicates,
Expand Down
7 changes: 5 additions & 2 deletions src/hotspot/share/classfile/systemDictionaryShared.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -703,8 +703,11 @@ bool SystemDictionaryShared::is_shared_class_visible_for_classloader(
// It's not guaranteed that the class is from the classpath if the // It's not guaranteed that the class is from the classpath if the
// PackageEntry cannot be found from the AppClassloader. Need to check // PackageEntry cannot be found from the AppClassloader. Need to check
// the boot and platform classloader as well. // the boot and platform classloader as well.
if (get_package_entry(pkg_name, ClassLoaderData::class_loader_data_or_null(SystemDictionary::java_platform_loader())) == NULL && ClassLoaderData* platform_loader_data =
get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data()) == NULL) { ClassLoaderData::class_loader_data_or_null(SystemDictionary::java_platform_loader()); // can be NULL during bootstrap
if ((platform_loader_data == NULL ||
ClassLoader::get_package_entry(pkg_name, platform_loader_data) == NULL) &&
ClassLoader::get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data()) == NULL) {
// The PackageEntry is not defined in any of the boot/platform/app classloaders. // The PackageEntry is not defined in any of the boot/platform/app classloaders.
// The archived class must from -cp path and not from the runtime image. // The archived class must from -cp path and not from the runtime image.
if (!ent->is_modules_image() && path_index >= ClassLoaderExt::app_class_paths_start_index() && if (!ent->is_modules_image() && path_index >= ClassLoaderExt::app_class_paths_start_index() &&
Expand Down
8 changes: 0 additions & 8 deletions src/hotspot/share/classfile/systemDictionaryShared.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -248,14 +248,6 @@ class SystemDictionaryShared: public SystemDictionary {
PackageEntry* pkg_entry, PackageEntry* pkg_entry,
ModuleEntry* mod_entry, ModuleEntry* mod_entry,
TRAPS); TRAPS);
static PackageEntry* get_package_entry(Symbol* pkg,
ClassLoaderData *loader_data) {
if (loader_data != NULL) {
PackageEntryTable* pkgEntryTable = loader_data->packages();
return pkgEntryTable->lookup_only(pkg);
}
return NULL;
}


static bool add_unregistered_class(InstanceKlass* k, TRAPS); static bool add_unregistered_class(InstanceKlass* k, TRAPS);
static InstanceKlass* dump_time_resolve_super_or_fail(Symbol* child_name, static InstanceKlass* dump_time_resolve_super_or_fail(Symbol* child_name,
Expand Down

0 comments on commit dd4e04d

Please sign in to comment.