Mercurial > hg > truffle
comparison src/share/vm/oops/instanceKlass.cpp @ 20576:90257dfad6e3
8043275: 8u40 backport: Fix interface initialization for default methods.
Reviewed-by: dcubed, coleenp
author | acorn |
---|---|
date | Fri, 24 Oct 2014 12:29:08 -0700 |
parents | 7dca5ed0e13d |
children | 3c87c13918fb |
comparison
equal
deleted
inserted
replaced
20570:1bd99e1dc168 | 20576:90257dfad6e3 |
---|---|
778 } | 778 } |
779 #endif //ASSERT | 779 #endif //ASSERT |
780 } | 780 } |
781 } | 781 } |
782 | 782 |
783 // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access) | |
784 void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_oop, TRAPS) { | |
785 if (this_oop->has_default_methods()) { | |
786 for (int i = 0; i < this_oop->local_interfaces()->length(); ++i) { | |
787 Klass* iface = this_oop->local_interfaces()->at(i); | |
788 InstanceKlass* ik = InstanceKlass::cast(iface); | |
789 if (ik->should_be_initialized()) { | |
790 if (ik->has_default_methods()) { | |
791 ik->initialize_super_interfaces(ik, THREAD); | |
792 } | |
793 // Only initialize() interfaces that "declare" concrete methods. | |
794 // has_default_methods drives searching superinterfaces since it | |
795 // means has_default_methods in its superinterface hierarchy | |
796 if (!HAS_PENDING_EXCEPTION && ik->declares_default_methods()) { | |
797 ik->initialize(THREAD); | |
798 } | |
799 if (HAS_PENDING_EXCEPTION) { | |
800 Handle e(THREAD, PENDING_EXCEPTION); | |
801 CLEAR_PENDING_EXCEPTION; | |
802 { | |
803 EXCEPTION_MARK; | |
804 // Locks object, set state, and notify all waiting threads | |
805 this_oop->set_initialization_state_and_notify( | |
806 initialization_error, THREAD); | |
807 | |
808 // ignore any exception thrown, superclass initialization error is | |
809 // thrown below | |
810 CLEAR_PENDING_EXCEPTION; | |
811 } | |
812 THROW_OOP(e()); | |
813 } | |
814 } | |
815 } | |
816 } | |
817 } | |
783 | 818 |
784 void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { | 819 void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { |
785 // Make sure klass is linked (verified) before initialization | 820 // Make sure klass is linked (verified) before initialization |
786 // A class could already be verified, since it has been reflected upon. | 821 // A class could already be verified, since it has been reflected upon. |
787 this_oop->link_class(CHECK); | 822 this_oop->link_class(CHECK); |
857 DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_oop()), -1,wait); | 892 DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_oop()), -1,wait); |
858 THROW_OOP(e()); | 893 THROW_OOP(e()); |
859 } | 894 } |
860 } | 895 } |
861 | 896 |
897 // Recursively initialize any superinterfaces that declare default methods | |
898 // Only need to recurse if has_default_methods which includes declaring and | |
899 // inheriting default methods | |
862 if (this_oop->has_default_methods()) { | 900 if (this_oop->has_default_methods()) { |
863 // Step 7.5: initialize any interfaces which have default methods | 901 this_oop->initialize_super_interfaces(this_oop, CHECK); |
864 for (int i = 0; i < this_oop->local_interfaces()->length(); ++i) { | |
865 Klass* iface = this_oop->local_interfaces()->at(i); | |
866 InstanceKlass* ik = InstanceKlass::cast(iface); | |
867 if (ik->has_default_methods() && ik->should_be_initialized()) { | |
868 ik->initialize(THREAD); | |
869 | |
870 if (HAS_PENDING_EXCEPTION) { | |
871 Handle e(THREAD, PENDING_EXCEPTION); | |
872 CLEAR_PENDING_EXCEPTION; | |
873 { | |
874 EXCEPTION_MARK; | |
875 // Locks object, set state, and notify all waiting threads | |
876 this_oop->set_initialization_state_and_notify( | |
877 initialization_error, THREAD); | |
878 | |
879 // ignore any exception thrown, superclass initialization error is | |
880 // thrown below | |
881 CLEAR_PENDING_EXCEPTION; | |
882 } | |
883 DTRACE_CLASSINIT_PROBE_WAIT( | |
884 super__failed, InstanceKlass::cast(this_oop()), -1, wait); | |
885 THROW_OOP(e()); | |
886 } | |
887 } | |
888 } | |
889 } | 902 } |
890 | 903 |
891 // Step 8 | 904 // Step 8 |
892 { | 905 { |
893 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); | 906 assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); |