1039 }
1040
1041 post_class_load_event(&class_load_start_event, k, loader_data);
1042 }
1043 assert(host_klass != NULL || NULL == cp_patches,
1044 "cp_patches only found with host_klass");
1045
1046 return k;
1047 }
1048
1049 // Add a klass to the system from a stream (called by jni_DefineClass and
1050 // JVM_DefineClass).
1051 // Note: class_name can be NULL. In that case we do not know the name of
1052 // the class until we have parsed the stream.
1053
1054 InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name,
1055 Handle class_loader,
1056 Handle protection_domain,
1057 ClassFileStream* st,
1058 TRAPS) {
1059 #if INCLUDE_CDS
1060 ResourceMark rm(THREAD);
1061 if (DumpSharedSpaces && !class_loader.is_null() &&
1062 !UseAppCDS && strcmp(class_name->as_C_string(), "Unnamed") != 0) {
1063 // If AppCDS is not enabled, don't define the class at dump time (except for the "Unnamed"
1064 // class, which is used by MethodHandles).
1065 THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string());
1066 }
1067 #endif
1068
1069 HandleMark hm(THREAD);
1070
1071 // Classloaders that support parallelism, e.g. bootstrap classloader,
1072 // do not acquire lock here
1073 bool DoObjectLock = true;
1074 if (is_parallelCapable(class_loader)) {
1075 DoObjectLock = false;
1076 }
1077
1078 ClassLoaderData* loader_data = register_loader(class_loader, CHECK_NULL);
1079
1080 // Make sure we are synchronized on the class loader before we proceed
1081 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1082 check_loader_lock_contention(lockObject, THREAD);
1083 ObjectLocker ol(lockObject, THREAD, DoObjectLock);
1084
1085 assert(st != NULL, "invariant");
1086
1087 // Parse the stream and create a klass.
3062 int d_index = _master_dictionary->hash_to_index(d_hash);
3063 DictionaryEntry* next = p->next();
3064 if (p->literal()->class_loader_data() != cld) {
3065 // This is an initiating class loader entry; don't use it
3066 log_trace(cds)("Skipping initiating cl entry: %s", name->as_C_string());
3067 curr_dictionary->free_entry(p);
3068 } else {
3069 log_trace(cds)("Moved to boot dictionary: %s", name->as_C_string());
3070 curr_dictionary->unlink_entry(p);
3071 p->set_pd_set(NULL); // pd_set is runtime only information and will be reconstructed.
3072 _master_dictionary->add_entry(d_index, p);
3073 }
3074 p = next;
3075 }
3076 *curr_dictionary->bucket_addr(i) = NULL;
3077 }
3078 }
3079 }
3080 };
3081
3082 // Combining platform and system loader dictionaries into boot loader dictionaries.
3083 // During run time, we only have one shared dictionary.
3084 void SystemDictionary::combine_shared_dictionaries() {
3085 assert(DumpSharedSpaces, "dump time only");
3086 Dictionary* master_dictionary = ClassLoaderData::the_null_class_loader_data()->dictionary();
3087 CombineDictionariesClosure cdc(master_dictionary);
3088 ClassLoaderDataGraph::cld_do(&cdc);
3089
3090 // These tables are no longer valid or necessary. Keeping them around will
3091 // cause SystemDictionary::verify() to fail. Let's empty them.
3092 _placeholders = new PlaceholderTable(_placeholder_table_size);
3093 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size);
3094
3095 NOT_PRODUCT(SystemDictionary::verify());
3096 }
3097
3098 // caller needs ResourceMark
3099 const char* SystemDictionary::loader_name(const oop loader) {
3100 return ((loader) == NULL ? "<bootloader>" :
3101 InstanceKlass::cast((loader)->klass())->name()->as_C_string());
3102 }
3103
3104 // caller needs ResourceMark
3105 const char* SystemDictionary::loader_name(const ClassLoaderData* loader_data) {
3106 return (loader_data->class_loader() == NULL ? "<bootloader>" :
3107 SystemDictionary::loader_name(loader_data->class_loader()));
3108 }
|
1039 }
1040
1041 post_class_load_event(&class_load_start_event, k, loader_data);
1042 }
1043 assert(host_klass != NULL || NULL == cp_patches,
1044 "cp_patches only found with host_klass");
1045
1046 return k;
1047 }
1048
1049 // Add a klass to the system from a stream (called by jni_DefineClass and
1050 // JVM_DefineClass).
1051 // Note: class_name can be NULL. In that case we do not know the name of
1052 // the class until we have parsed the stream.
1053
1054 InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name,
1055 Handle class_loader,
1056 Handle protection_domain,
1057 ClassFileStream* st,
1058 TRAPS) {
1059
1060 HandleMark hm(THREAD);
1061
1062 // Classloaders that support parallelism, e.g. bootstrap classloader,
1063 // do not acquire lock here
1064 bool DoObjectLock = true;
1065 if (is_parallelCapable(class_loader)) {
1066 DoObjectLock = false;
1067 }
1068
1069 ClassLoaderData* loader_data = register_loader(class_loader, CHECK_NULL);
1070
1071 // Make sure we are synchronized on the class loader before we proceed
1072 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1073 check_loader_lock_contention(lockObject, THREAD);
1074 ObjectLocker ol(lockObject, THREAD, DoObjectLock);
1075
1076 assert(st != NULL, "invariant");
1077
1078 // Parse the stream and create a klass.
3053 int d_index = _master_dictionary->hash_to_index(d_hash);
3054 DictionaryEntry* next = p->next();
3055 if (p->literal()->class_loader_data() != cld) {
3056 // This is an initiating class loader entry; don't use it
3057 log_trace(cds)("Skipping initiating cl entry: %s", name->as_C_string());
3058 curr_dictionary->free_entry(p);
3059 } else {
3060 log_trace(cds)("Moved to boot dictionary: %s", name->as_C_string());
3061 curr_dictionary->unlink_entry(p);
3062 p->set_pd_set(NULL); // pd_set is runtime only information and will be reconstructed.
3063 _master_dictionary->add_entry(d_index, p);
3064 }
3065 p = next;
3066 }
3067 *curr_dictionary->bucket_addr(i) = NULL;
3068 }
3069 }
3070 }
3071 };
3072
3073 // Combining platform and system loader dictionaries into boot loader dictionary.
3074 // During run time, we only have one shared dictionary.
3075 void SystemDictionary::combine_shared_dictionaries() {
3076 assert(DumpSharedSpaces, "dump time only");
3077 // If AppCDS isn't enabled, we only dump the classes in the boot loader dictionary
3078 // into the shared archive.
3079 if (UseAppCDS) {
3080 Dictionary* master_dictionary = ClassLoaderData::the_null_class_loader_data()->dictionary();
3081 CombineDictionariesClosure cdc(master_dictionary);
3082 ClassLoaderDataGraph::cld_do(&cdc);
3083 }
3084
3085 // These tables are no longer valid or necessary. Keeping them around will
3086 // cause SystemDictionary::verify() to fail. Let's empty them.
3087 _placeholders = new PlaceholderTable(_placeholder_table_size);
3088 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size);
3089
3090 NOT_PRODUCT(SystemDictionary::verify());
3091 }
3092
3093 // caller needs ResourceMark
3094 const char* SystemDictionary::loader_name(const oop loader) {
3095 return ((loader) == NULL ? "<bootloader>" :
3096 InstanceKlass::cast((loader)->klass())->name()->as_C_string());
3097 }
3098
3099 // caller needs ResourceMark
3100 const char* SystemDictionary::loader_name(const ClassLoaderData* loader_data) {
3101 return (loader_data->class_loader() == NULL ? "<bootloader>" :
3102 SystemDictionary::loader_name(loader_data->class_loader()));
3103 }
|