734 } |
734 } |
735 #endif //ASSERT |
735 #endif //ASSERT |
736 } |
736 } |
737 } |
737 } |
738 |
738 |
|
739 // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access) |
|
740 void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAPS) { |
|
741 if (this_k->has_default_methods()) { |
|
742 for (int i = 0; i < this_k->local_interfaces()->length(); ++i) { |
|
743 Klass* iface = this_k->local_interfaces()->at(i); |
|
744 InstanceKlass* ik = InstanceKlass::cast(iface); |
|
745 if (ik->should_be_initialized()) { |
|
746 if (ik->has_default_methods()) { |
|
747 ik->initialize_super_interfaces(ik, THREAD); |
|
748 } |
|
749 // Only initialize() interfaces that "declare" concrete methods. |
|
750 // has_default_methods drives searching superinterfaces since it |
|
751 // means has_default_methods in its superinterface hierarchy |
|
752 if (!HAS_PENDING_EXCEPTION && ik->declares_default_methods()) { |
|
753 ik->initialize(THREAD); |
|
754 } |
|
755 if (HAS_PENDING_EXCEPTION) { |
|
756 Handle e(THREAD, PENDING_EXCEPTION); |
|
757 CLEAR_PENDING_EXCEPTION; |
|
758 { |
|
759 EXCEPTION_MARK; |
|
760 // Locks object, set state, and notify all waiting threads |
|
761 this_k->set_initialization_state_and_notify( |
|
762 initialization_error, THREAD); |
|
763 |
|
764 // ignore any exception thrown, superclass initialization error is |
|
765 // thrown below |
|
766 CLEAR_PENDING_EXCEPTION; |
|
767 } |
|
768 THROW_OOP(e()); |
|
769 } |
|
770 } |
|
771 } |
|
772 } |
|
773 } |
739 |
774 |
740 void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) { |
775 void InstanceKlass::initialize_impl(instanceKlassHandle this_k, TRAPS) { |
741 // Make sure klass is linked (verified) before initialization |
776 // Make sure klass is linked (verified) before initialization |
742 // A class could already be verified, since it has been reflected upon. |
777 // A class could already be verified, since it has been reflected upon. |
743 this_k->link_class(CHECK); |
778 this_k->link_class(CHECK); |
813 DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_k()), -1,wait); |
848 DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_k()), -1,wait); |
814 THROW_OOP(e()); |
849 THROW_OOP(e()); |
815 } |
850 } |
816 } |
851 } |
817 |
852 |
|
853 // Recursively initialize any superinterfaces that declare default methods |
|
854 // Only need to recurse if has_default_methods which includes declaring and |
|
855 // inheriting default methods |
818 if (this_k->has_default_methods()) { |
856 if (this_k->has_default_methods()) { |
819 // Step 7.5: initialize any interfaces which have default methods |
857 this_k->initialize_super_interfaces(this_k, CHECK); |
820 for (int i = 0; i < this_k->local_interfaces()->length(); ++i) { |
|
821 Klass* iface = this_k->local_interfaces()->at(i); |
|
822 InstanceKlass* ik = InstanceKlass::cast(iface); |
|
823 if (ik->has_default_methods() && ik->should_be_initialized()) { |
|
824 ik->initialize(THREAD); |
|
825 |
|
826 if (HAS_PENDING_EXCEPTION) { |
|
827 Handle e(THREAD, PENDING_EXCEPTION); |
|
828 CLEAR_PENDING_EXCEPTION; |
|
829 { |
|
830 EXCEPTION_MARK; |
|
831 // Locks object, set state, and notify all waiting threads |
|
832 this_k->set_initialization_state_and_notify( |
|
833 initialization_error, THREAD); |
|
834 |
|
835 // ignore any exception thrown, superclass initialization error is |
|
836 // thrown below |
|
837 CLEAR_PENDING_EXCEPTION; |
|
838 } |
|
839 DTRACE_CLASSINIT_PROBE_WAIT( |
|
840 super__failed, InstanceKlass::cast(this_k()), -1, wait); |
|
841 THROW_OOP(e()); |
|
842 } |
|
843 } |
|
844 } |
|
845 } |
858 } |
846 |
859 |
847 // Step 8 |
860 // Step 8 |
848 { |
861 { |
849 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); |
862 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); |