2153 const char *existing_klass_loader_name = "";
2154
2155 {
2156 Symbol* name = k->name();
2157 ClassLoaderData *loader_data = class_loader_data(class_loader);
2158
2159 MutexLocker mu(SystemDictionary_lock, THREAD);
2160
2161 InstanceKlass* check = find_class(d_hash, name, loader_data->dictionary());
2162 if (check != NULL) {
2163 // If different InstanceKlass - duplicate class definition,
2164 // else - ok, class loaded by a different thread in parallel.
2165 // We should only have found it if it was done loading and ok to use.
2166 // The dictionary only holds instance classes, placeholders
2167 // also hold array classes.
2168
2169 assert(check->is_instance_klass(), "noninstance in systemdictionary");
2170 if ((defining == true) || (k != check)) {
2171 linkage_error1 = "loader ";
2172 linkage_error2 = " attempted duplicate class definition for ";
2173 guarantee(check->class_loader() == class_loader(), "Per construction. Else report the other loader.");
2174 } else {
2175 return;
2176 }
2177 }
2178
2179 #ifdef ASSERT
2180 Symbol* ph_check = find_placeholder(name, loader_data);
2181 assert(ph_check == NULL || ph_check == name, "invalid symbol");
2182 #endif
2183
2184 if (linkage_error1 == NULL) {
2185 if (constraints()->check_or_update(k, class_loader, name) == false) {
2186 linkage_error1 = "loader constraint violation: loader ";
2187 linkage_error2 = " wants to load class ";
2188 linkage_error3 = ". A different class with the same name was previously loaded by ";
2189 Klass *existing_klass = constraints()->find_constrained_klass(name, class_loader);
2190 if (existing_klass->class_loader() != class_loader()) {
2191 existing_klass_loader_name =
2192 java_lang_ClassLoader::describe_external(existing_klass->class_loader());
2193 }
3090 // Combining platform and system loader dictionaries into boot loader dictionary.
3091 // During run time, we only have one shared dictionary.
3092 void SystemDictionary::combine_shared_dictionaries() {
3093 assert(DumpSharedSpaces, "dump time only");
3094 // If AppCDS isn't enabled, we only dump the classes in the boot loader dictionary
3095 // into the shared archive.
3096 if (UseAppCDS) {
3097 Dictionary* master_dictionary = ClassLoaderData::the_null_class_loader_data()->dictionary();
3098 CombineDictionariesClosure cdc(master_dictionary);
3099 ClassLoaderDataGraph::cld_do(&cdc);
3100 }
3101
3102 // These tables are no longer valid or necessary. Keeping them around will
3103 // cause SystemDictionary::verify() to fail. Let's empty them.
3104 _placeholders = new PlaceholderTable(_placeholder_table_size);
3105 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size);
3106
3107 NOT_PRODUCT(SystemDictionary::verify());
3108 }
3109
3110 // Return string to give helpful intformation about a classloader.
3111 // Caller needs ResourceMark.
3112 const char* SystemDictionary::loader_name(const oop loader) {
3113 #if INCLUDE_CDS
3114 if (DumpSharedSpaces) {
3115 // Describe_external() calls assert(is_instance...) in various places,
3116 // which may fail with DumpSharedSpaces.
3117 if ((loader) == NULL) return "<bootloader>";
3118 return InstanceKlass::cast((loader)->klass())->name()->as_C_string();
3119 }
3120 #endif
3121 return java_lang_ClassLoader::describe_external(loader);
3122 }
3123
3124 // caller needs ResourceMark
3125 const char* SystemDictionary::loader_name(const ClassLoaderData* loader_data) {
3126 return (loader_data->class_loader() == NULL ? "<bootloader>" :
3127 SystemDictionary::loader_name(loader_data->class_loader()));
3128 }
|
2153 const char *existing_klass_loader_name = "";
2154
2155 {
2156 Symbol* name = k->name();
2157 ClassLoaderData *loader_data = class_loader_data(class_loader);
2158
2159 MutexLocker mu(SystemDictionary_lock, THREAD);
2160
2161 InstanceKlass* check = find_class(d_hash, name, loader_data->dictionary());
2162 if (check != NULL) {
2163 // If different InstanceKlass - duplicate class definition,
2164 // else - ok, class loaded by a different thread in parallel.
2165 // We should only have found it if it was done loading and ok to use.
2166 // The dictionary only holds instance classes, placeholders
2167 // also hold array classes.
2168
2169 assert(check->is_instance_klass(), "noninstance in systemdictionary");
2170 if ((defining == true) || (k != check)) {
2171 linkage_error1 = "loader ";
2172 linkage_error2 = " attempted duplicate class definition for ";
2173 } else {
2174 return;
2175 }
2176 }
2177
2178 #ifdef ASSERT
2179 Symbol* ph_check = find_placeholder(name, loader_data);
2180 assert(ph_check == NULL || ph_check == name, "invalid symbol");
2181 #endif
2182
2183 if (linkage_error1 == NULL) {
2184 if (constraints()->check_or_update(k, class_loader, name) == false) {
2185 linkage_error1 = "loader constraint violation: loader ";
2186 linkage_error2 = " wants to load class ";
2187 linkage_error3 = ". A different class with the same name was previously loaded by ";
2188 Klass *existing_klass = constraints()->find_constrained_klass(name, class_loader);
2189 if (existing_klass->class_loader() != class_loader()) {
2190 existing_klass_loader_name =
2191 java_lang_ClassLoader::describe_external(existing_klass->class_loader());
2192 }
3089 // Combining platform and system loader dictionaries into boot loader dictionary.
3090 // During run time, we only have one shared dictionary.
3091 void SystemDictionary::combine_shared_dictionaries() {
3092 assert(DumpSharedSpaces, "dump time only");
3093 // If AppCDS isn't enabled, we only dump the classes in the boot loader dictionary
3094 // into the shared archive.
3095 if (UseAppCDS) {
3096 Dictionary* master_dictionary = ClassLoaderData::the_null_class_loader_data()->dictionary();
3097 CombineDictionariesClosure cdc(master_dictionary);
3098 ClassLoaderDataGraph::cld_do(&cdc);
3099 }
3100
3101 // These tables are no longer valid or necessary. Keeping them around will
3102 // cause SystemDictionary::verify() to fail. Let's empty them.
3103 _placeholders = new PlaceholderTable(_placeholder_table_size);
3104 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size);
3105
3106 NOT_PRODUCT(SystemDictionary::verify());
3107 }
3108
3109 // Caller needs ResourceMark.
3110 const char* SystemDictionary::loader_name(const oop loader) {
3111 return ((loader) == NULL ? "<bootloader>" :
3112 InstanceKlass::cast((loader)->klass())->name()->as_C_string());
3113 }
3114
3115 // caller needs ResourceMark
3116 const char* SystemDictionary::loader_name(const ClassLoaderData* loader_data) {
3117 return (loader_data->class_loader() == NULL ? "<bootloader>" :
3118 SystemDictionary::loader_name(loader_data->class_loader()));
3119 }
|