871 // having a superinterface that declares, non-static, concrete methods 872 if (!HAS_PENDING_EXCEPTION && has_nonstatic_concrete_methods()) { 873 initialize_super_interfaces(THREAD); 874 } 875 876 // If any exceptions, complete abruptly, throwing the same exception as above. 877 if (HAS_PENDING_EXCEPTION) { 878 Handle e(THREAD, PENDING_EXCEPTION); 879 CLEAR_PENDING_EXCEPTION; 880 { 881 EXCEPTION_MARK; 882 // Locks object, set state, and notify all waiting threads 883 set_initialization_state_and_notify(initialization_error, THREAD); 884 CLEAR_PENDING_EXCEPTION; 885 } 886 DTRACE_CLASSINIT_PROBE_WAIT(super__failed, -1, wait); 887 THROW_OOP(e()); 888 } 889 } 890 891 892 // Look for aot compiled methods for this klass, including class initializer. 893 AOTLoader::load_for_klass(this, THREAD); 894 895 // Step 8 896 { 897 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); 898 JavaThread* jt = (JavaThread*)THREAD; 899 DTRACE_CLASSINIT_PROBE_WAIT(clinit, -1, wait); 900 // Timer includes any side effects of class initialization (resolution, 901 // etc), but not recursive entry into call_class_initializer(). 902 PerfClassTraceTime timer(ClassLoader::perf_class_init_time(), 903 ClassLoader::perf_class_init_selftime(), 904 ClassLoader::perf_classes_inited(), 905 jt->get_thread_stat()->perf_recursion_counts_addr(), 906 jt->get_thread_stat()->perf_timers_addr(), 907 PerfClassTraceTime::CLASS_CLINIT); 908 call_class_initializer(THREAD); 909 } 910 911 // Step 9 912 if (!HAS_PENDING_EXCEPTION) { 913 set_initialization_state_and_notify(fully_initialized, CHECK); 914 { 915 debug_only(vtable().verify(tty, true);) 916 } 917 } 918 else { 919 // Step 10 and 11 920 Handle e(THREAD, PENDING_EXCEPTION); 921 CLEAR_PENDING_EXCEPTION; 922 // JVMTI has already reported the pending exception 923 // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError 924 JvmtiExport::clear_detected_exception((JavaThread*)THREAD); 925 { 926 EXCEPTION_MARK; 927 set_initialization_state_and_notify(initialization_error, THREAD); 928 CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below 929 // JVMTI has already reported the pending exception 930 // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError 931 JvmtiExport::clear_detected_exception((JavaThread*)THREAD); 932 } 933 DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait); 934 if (e->is_a(SystemDictionary::Error_klass())) { 935 THROW_OOP(e()); 936 } else { 937 JavaCallArguments args(e); 938 THROW_ARG(vmSymbols::java_lang_ExceptionInInitializerError(), 939 vmSymbols::throwable_void_signature(), | 871 // having a superinterface that declares, non-static, concrete methods 872 if (!HAS_PENDING_EXCEPTION && has_nonstatic_concrete_methods()) { 873 initialize_super_interfaces(THREAD); 874 } 875 876 // If any exceptions, complete abruptly, throwing the same exception as above. 877 if (HAS_PENDING_EXCEPTION) { 878 Handle e(THREAD, PENDING_EXCEPTION); 879 CLEAR_PENDING_EXCEPTION; 880 { 881 EXCEPTION_MARK; 882 // Locks object, set state, and notify all waiting threads 883 set_initialization_state_and_notify(initialization_error, THREAD); 884 CLEAR_PENDING_EXCEPTION; 885 } 886 DTRACE_CLASSINIT_PROBE_WAIT(super__failed, -1, wait); 887 THROW_OOP(e()); 888 } 889 } 890 891 // Step 8 892 // Initialize classes of flattenable fields 893 { 894 for (AllFieldStream fs(this); !fs.done(); fs.next()) { 895 if (fs.is_flattenable()) { 896 InstanceKlass* field_klass = InstanceKlass::cast(this->get_value_field_klass(fs.index())); 897 field_klass->initialize(CHECK); 898 } 899 } 900 } 901 902 903 // Look for aot compiled methods for this klass, including class initializer. 904 AOTLoader::load_for_klass(this, THREAD); 905 906 // Step 9 907 { 908 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); 909 JavaThread* jt = (JavaThread*)THREAD; 910 DTRACE_CLASSINIT_PROBE_WAIT(clinit, -1, wait); 911 // Timer includes any side effects of class initialization (resolution, 912 // etc), but not recursive entry into call_class_initializer(). 913 PerfClassTraceTime timer(ClassLoader::perf_class_init_time(), 914 ClassLoader::perf_class_init_selftime(), 915 ClassLoader::perf_classes_inited(), 916 jt->get_thread_stat()->perf_recursion_counts_addr(), 917 jt->get_thread_stat()->perf_timers_addr(), 918 PerfClassTraceTime::CLASS_CLINIT); 919 call_class_initializer(THREAD); 920 } 921 922 // Step 10 923 if (!HAS_PENDING_EXCEPTION) { 924 set_initialization_state_and_notify(fully_initialized, CHECK); 925 { 926 debug_only(vtable().verify(tty, true);) 927 } 928 } 929 else { 930 // Step 11 and 12 931 Handle e(THREAD, PENDING_EXCEPTION); 932 CLEAR_PENDING_EXCEPTION; 933 // JVMTI has already reported the pending exception 934 // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError 935 JvmtiExport::clear_detected_exception((JavaThread*)THREAD); 936 { 937 EXCEPTION_MARK; 938 set_initialization_state_and_notify(initialization_error, THREAD); 939 CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below 940 // JVMTI has already reported the pending exception 941 // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError 942 JvmtiExport::clear_detected_exception((JavaThread*)THREAD); 943 } 944 DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait); 945 if (e->is_a(SystemDictionary::Error_klass())) { 946 THROW_OOP(e()); 947 } else { 948 JavaCallArguments args(e); 949 THROW_ARG(vmSymbols::java_lang_ExceptionInInitializerError(), 950 vmSymbols::throwable_void_signature(), |