Skip to content
Permalink
Browse files

8242134: Consolidate the get_package_entry() in SystemDictionaryShare…

…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 dd4e04d6f5180410fe21f24c4b60e774378b1019
@@ -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);
}

// 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.
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) {
return NULL;
}
@@ -396,9 +396,9 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(const char* name, C
if (!Universe::is_module_initialized()) {
location = (*JImageFindResource)(_jimage, JAVA_BASE_NAME, get_jimage_version_string(), name, &size);
} 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) {
ResourceMark rm;
ResourceMark rm(THREAD);
// Get the module name
ModuleEntry* module = package_entry->module();
assert(module != NULL, "Boot classLoader package missing module");
@@ -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
TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name);
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;

// If the module system has not defined java.base yet, then
@@ -272,9 +272,7 @@ class ClassLoader: AllStatic {
static bool get_canonical_path(const char* orig, char* out, int len);
static const char* file_name_for_class_name(const char* class_name,
int class_name_len);
static PackageEntry* get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data, TRAPS);

public:
static PackageEntry* get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data);
static int crc32(int crc, const char* buf, int len);
static bool update_class_path_entry_list(const char *path,
bool check_for_duplicates,
@@ -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
// PackageEntry cannot be found from the AppClassloader. Need to check
// the boot and platform classloader as well.
if (get_package_entry(pkg_name, ClassLoaderData::class_loader_data_or_null(SystemDictionary::java_platform_loader())) == NULL &&
get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data()) == NULL) {
ClassLoaderData* platform_loader_data =
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 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() &&
@@ -248,14 +248,6 @@ class SystemDictionaryShared: public SystemDictionary {
PackageEntry* pkg_entry,
ModuleEntry* mod_entry,
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 InstanceKlass* dump_time_resolve_super_or_fail(Symbol* child_name,

0 comments on commit dd4e04d

Please sign in to comment.