This commit is contained in:
Jiangli Zhou 2016-05-05 00:56:06 +02:00
commit 9a430638df
4 changed files with 17 additions and 13 deletions

View File

@ -941,6 +941,10 @@ int ClassLoader::crc32(int crc, const char* buf, int len) {
#if INCLUDE_CDS
void ClassLoader::initialize_module_loader_map(JImageFile* jimage) {
if (!DumpSharedSpaces) {
return; // only needed for CDS dump time
}
jlong size;
JImageLocationRef location = (*JImageFindResource)(jimage, "java.base", get_jimage_version_string(), MODULE_LOADER_MAP, &size);
if (location == 0) {
@ -1085,6 +1089,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) {
#if INCLUDE_CDS
s2 ClassLoader::module_to_classloader(const char* module_name) {
assert(DumpSharedSpaces, "dump time only");
assert(_boot_modules_array != NULL, "_boot_modules_array is NULL");
assert(_platform_modules_array != NULL, "_platform_modules_array is NULL");
@ -1104,11 +1109,11 @@ s2 ClassLoader::module_to_classloader(const char* module_name) {
return APP_LOADER;
}
#endif
s2 ClassLoader::classloader_type(Symbol* class_name, ClassPathEntry* e,
int classpath_index, TRAPS) {
#if INCLUDE_CDS
assert(DumpSharedSpaces, "Only used for CDS dump time");
// obtain the classloader type based on the class name.
// First obtain the package name based on the class name. Then obtain
// the classloader type based on the package name from the jimage using
@ -1133,10 +1138,8 @@ s2 ClassLoader::classloader_type(Symbol* class_name, ClassPathEntry* e,
loader_type = ClassLoader::BOOT_LOADER;
}
return loader_type;
#endif
return ClassLoader::BOOT_LOADER; // the classloader type is ignored in non-CDS cases
}
#endif
// caller needs ResourceMark
const char* ClassLoader::file_name_for_class_name(const char* class_name,
@ -1253,8 +1256,7 @@ instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_onl
return NULL;
}
jshort loader_type = classloader_type(name, e, classpath_index, CHECK_NULL);
return context.record_result(classpath_index, loader_type, e, result, THREAD);
return context.record_result(name, e, classpath_index, result, THREAD);
}
// Initialize the class loader's access to methods in libzip. Parse and

View File

@ -379,9 +379,9 @@ class ClassLoader: AllStatic {
static s2 module_to_classloader(const char* module_name);
static void initialize_module_loader_map(JImageFile* jimage);
#endif
static s2 classloader_type(Symbol* class_name, ClassPathEntry* e,
int classpath_index, TRAPS);
int classpath_index, TRAPS);
#endif
static void trace_class_path(const char* msg, const char* name = NULL);

View File

@ -49,12 +49,14 @@ public:
return false;
}
instanceKlassHandle record_result(const s2 classpath_index,
const jshort classloader_type,
const ClassPathEntry* e,
instanceKlassHandle record_result(Symbol* class_name,
ClassPathEntry* e,
const s2 classpath_index,
instanceKlassHandle result, TRAPS) {
if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) {
if (DumpSharedSpaces) {
s2 classloader_type = ClassLoader::classloader_type(
class_name, e, classpath_index, CHECK_(result));
result->set_shared_classpath_index(classpath_index);
result->set_class_loader_type(classloader_type);
}

View File

@ -321,7 +321,7 @@ class InstanceKlass: public Klass {
return (_misc_flags & _misc_is_shared_app_class) != 0;
}
void set_class_loader_type(jshort loader_type) {
void set_class_loader_type(s2 loader_type) {
assert(( _misc_flags & loader_type_bits()) == 0,
"Should only be called once for each class.");
switch (loader_type) {