917 #define WK_KLASS_CASE(name, symbol, ignore_option) \
918 case vmSymbols::VM_SYMBOL_ENUM_NAME(symbol): \
919 k = WK_KLASS(name); break;
920 WK_KLASSES_DO(WK_KLASS_CASE)
921 #undef WK_KLASS_CASE
922 }
923 NOT_PRODUCT(if (k != NULL) find_wkk_wins++);
924 return k;
925 }
926 }
927 return NULL;
928 }
929
930 // Note: this method is much like resolve_from_stream, but
931 // updates no supplemental data structures.
932 // TODO consolidate the two methods with a helper routine?
933 klassOop SystemDictionary::parse_stream(symbolHandle class_name,
934 Handle class_loader,
935 Handle protection_domain,
936 ClassFileStream* st,
937 TRAPS) {
938 symbolHandle parsed_name;
939
940 // Parse the stream. Note that we do this even though this klass might
941 // already be present in the SystemDictionary, otherwise we would not
942 // throw potential ClassFormatErrors.
943 //
944 // Note: "name" is updated.
945 // Further note: a placeholder will be added for this class when
946 // super classes are loaded (resolve_super_or_fail). We expect this
947 // to be called for all classes but java.lang.Object; and we preload
948 // java.lang.Object through resolve_or_fail, not this path.
949
950 instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name,
951 class_loader,
952 protection_domain,
953 parsed_name,
954 THREAD);
955
956
957 // We don't redefine the class, so we just need to clean up whether there
958 // was an error or not (don't want to modify any system dictionary
959 // data structures).
960 // Parsed name could be null if we threw an error before we got far
961 // enough along to parse it -- in that case, there is nothing to clean up.
962 if (!parsed_name.is_null()) {
963 unsigned int p_hash = placeholders()->compute_hash(parsed_name,
964 class_loader);
965 int p_index = placeholders()->hash_to_index(p_hash);
966 {
967 MutexLocker mu(SystemDictionary_lock, THREAD);
968 placeholders()->find_and_remove(p_index, p_hash, parsed_name, class_loader, THREAD);
969 SystemDictionary_lock->notify_all();
970 }
971 }
972
973 return k();
974 }
975
976 // Add a klass to the system from a stream (called by jni_DefineClass and
977 // JVM_DefineClass).
978 // Note: class_name can be NULL. In that case we do not know the name of
979 // the class until we have parsed the stream.
980
981 klassOop SystemDictionary::resolve_from_stream(symbolHandle class_name,
982 Handle class_loader,
983 Handle protection_domain,
984 ClassFileStream* st,
985 TRAPS) {
986
987 // Make sure we are synchronized on the class loader before we initiate
988 // loading.
989 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
990 check_loader_lock_contention(lockObject, THREAD);
991 ObjectLocker ol(lockObject, THREAD);
|
917 #define WK_KLASS_CASE(name, symbol, ignore_option) \
918 case vmSymbols::VM_SYMBOL_ENUM_NAME(symbol): \
919 k = WK_KLASS(name); break;
920 WK_KLASSES_DO(WK_KLASS_CASE)
921 #undef WK_KLASS_CASE
922 }
923 NOT_PRODUCT(if (k != NULL) find_wkk_wins++);
924 return k;
925 }
926 }
927 return NULL;
928 }
929
930 // Note: this method is much like resolve_from_stream, but
931 // updates no supplemental data structures.
932 // TODO consolidate the two methods with a helper routine?
933 klassOop SystemDictionary::parse_stream(symbolHandle class_name,
934 Handle class_loader,
935 Handle protection_domain,
936 ClassFileStream* st,
937 KlassHandle host_klass,
938 GrowableArray<Handle>* cp_patches,
939 TRAPS) {
940 symbolHandle parsed_name;
941
942 // Parse the stream. Note that we do this even though this klass might
943 // already be present in the SystemDictionary, otherwise we would not
944 // throw potential ClassFormatErrors.
945 //
946 // Note: "name" is updated.
947 // Further note: a placeholder will be added for this class when
948 // super classes are loaded (resolve_super_or_fail). We expect this
949 // to be called for all classes but java.lang.Object; and we preload
950 // java.lang.Object through resolve_or_fail, not this path.
951
952 instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name,
953 class_loader,
954 protection_domain,
955 cp_patches,
956 parsed_name,
957 THREAD);
958
959 // We don't redefine the class, so we just need to clean up whether there
960 // was an error or not (don't want to modify any system dictionary
961 // data structures).
962 // Parsed name could be null if we threw an error before we got far
963 // enough along to parse it -- in that case, there is nothing to clean up.
964 if (!parsed_name.is_null()) {
965 unsigned int p_hash = placeholders()->compute_hash(parsed_name,
966 class_loader);
967 int p_index = placeholders()->hash_to_index(p_hash);
968 {
969 MutexLocker mu(SystemDictionary_lock, THREAD);
970 placeholders()->find_and_remove(p_index, p_hash, parsed_name, class_loader, THREAD);
971 SystemDictionary_lock->notify_all();
972 }
973 }
974
975 if (host_klass.not_null() && k.not_null()) {
976 // If it's anonymous, initialize it now, since nobody else will.
977 k->set_host_klass(host_klass());
978
979 {
980 MutexLocker mu_r(Compile_lock, THREAD);
981
982 // Add to class hierarchy, initialize vtables, and do possible
983 // deoptimizations.
984 add_to_hierarchy(k, CHECK_NULL); // No exception, but can block
985
986 // But, do not add to system dictionary.
987 }
988
989 k->eager_initialize(THREAD);
990
991 // notify jvmti
992 if (JvmtiExport::should_post_class_load()) {
993 assert(THREAD->is_Java_thread(), "thread->is_Java_thread()");
994 JvmtiExport::post_class_load((JavaThread *) THREAD, k());
995 }
996 }
997
998 return k();
999 }
1000
1001 // Add a klass to the system from a stream (called by jni_DefineClass and
1002 // JVM_DefineClass).
1003 // Note: class_name can be NULL. In that case we do not know the name of
1004 // the class until we have parsed the stream.
1005
1006 klassOop SystemDictionary::resolve_from_stream(symbolHandle class_name,
1007 Handle class_loader,
1008 Handle protection_domain,
1009 ClassFileStream* st,
1010 TRAPS) {
1011
1012 // Make sure we are synchronized on the class loader before we initiate
1013 // loading.
1014 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1015 check_loader_lock_contention(lockObject, THREAD);
1016 ObjectLocker ol(lockObject, THREAD);
|