changeset 13728 | 882756847a04 |
parent 13396 | 1b2b5f740ee0 |
child 13952 | e3cf184080bc |
13727:caf5eb7dd4a7 | 13728:882756847a04 |
---|---|
33 #include "memory/oopFactory.hpp" |
33 #include "memory/oopFactory.hpp" |
34 #include "memory/universe.inline.hpp" |
34 #include "memory/universe.inline.hpp" |
35 #include "oops/fieldStreams.hpp" |
35 #include "oops/fieldStreams.hpp" |
36 #include "oops/instanceKlass.hpp" |
36 #include "oops/instanceKlass.hpp" |
37 #include "oops/objArrayKlass.hpp" |
37 #include "oops/objArrayKlass.hpp" |
38 #include "oops/methodOop.hpp" |
38 #include "oops/method.hpp" |
39 #include "prims/jvm.h" |
39 #include "prims/jvm.h" |
40 #include "prims/jvm_misc.hpp" |
40 #include "prims/jvm_misc.hpp" |
41 #include "prims/jvmtiExport.hpp" |
41 #include "prims/jvmtiExport.hpp" |
42 #include "prims/jvmtiThreadState.hpp" |
42 #include "prims/jvmtiThreadState.hpp" |
43 #include "prims/nativeLookup.hpp" |
43 #include "prims/nativeLookup.hpp" |
118 consider use of a Handle instead of an oop so there is immunity from object |
118 consider use of a Handle instead of an oop so there is immunity from object |
119 motion. But note that the "QUICK" entries below do not have a handlemark |
119 motion. But note that the "QUICK" entries below do not have a handlemark |
120 and thus can only support use of handles passed in. |
120 and thus can only support use of handles passed in. |
121 */ |
121 */ |
122 |
122 |
123 static void trace_class_resolution_impl(klassOop to_class, TRAPS) { |
123 static void trace_class_resolution_impl(Klass* to_class, TRAPS) { |
124 ResourceMark rm; |
124 ResourceMark rm; |
125 int line_number = -1; |
125 int line_number = -1; |
126 const char * source_file = NULL; |
126 const char * source_file = NULL; |
127 const char * trace = "explicit"; |
127 const char * trace = "explicit"; |
128 klassOop caller = NULL; |
128 Klass* caller = NULL; |
129 JavaThread* jthread = JavaThread::current(); |
129 JavaThread* jthread = JavaThread::current(); |
130 if (jthread->has_last_Java_frame()) { |
130 if (jthread->has_last_Java_frame()) { |
131 vframeStream vfst(jthread); |
131 vframeStream vfst(jthread); |
132 |
132 |
133 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames |
133 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames |
134 TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController", CHECK); |
134 TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController", CHECK); |
135 klassOop access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK); |
135 Klass* access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK); |
136 TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction", CHECK); |
136 TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction", CHECK); |
137 klassOop privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); |
137 Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); |
138 |
138 |
139 methodOop last_caller = NULL; |
139 Method* last_caller = NULL; |
140 |
140 |
141 while (!vfst.at_end()) { |
141 while (!vfst.at_end()) { |
142 methodOop m = vfst.method(); |
142 Method* m = vfst.method(); |
143 if (!vfst.method()->method_holder()->klass_part()->is_subclass_of(SystemDictionary::ClassLoader_klass())&& |
143 if (!vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass())&& |
144 !vfst.method()->method_holder()->klass_part()->is_subclass_of(access_controller_klass) && |
144 !vfst.method()->method_holder()->is_subclass_of(access_controller_klass) && |
145 !vfst.method()->method_holder()->klass_part()->is_subclass_of(privileged_action_klass)) { |
145 !vfst.method()->method_holder()->is_subclass_of(privileged_action_klass)) { |
146 break; |
146 break; |
147 } |
147 } |
148 last_caller = m; |
148 last_caller = m; |
149 vfst.next(); |
149 vfst.next(); |
150 } |
150 } |
151 // if this is called from Class.forName0 and that is called from Class.forName, |
151 // if this is called from Class.forName0 and that is called from Class.forName, |
152 // then print the caller of Class.forName. If this is Class.loadClass, then print |
152 // then print the caller of Class.forName. If this is Class.loadClass, then print |
153 // that caller, otherwise keep quiet since this should be picked up elsewhere. |
153 // that caller, otherwise keep quiet since this should be picked up elsewhere. |
154 bool found_it = false; |
154 bool found_it = false; |
155 if (!vfst.at_end() && |
155 if (!vfst.at_end() && |
156 instanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class() && |
156 InstanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class() && |
157 vfst.method()->name() == vmSymbols::forName0_name()) { |
157 vfst.method()->name() == vmSymbols::forName0_name()) { |
158 vfst.next(); |
158 vfst.next(); |
159 if (!vfst.at_end() && |
159 if (!vfst.at_end() && |
160 instanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class() && |
160 InstanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class() && |
161 vfst.method()->name() == vmSymbols::forName_name()) { |
161 vfst.method()->name() == vmSymbols::forName_name()) { |
162 vfst.next(); |
162 vfst.next(); |
163 found_it = true; |
163 found_it = true; |
164 } |
164 } |
165 } else if (last_caller != NULL && |
165 } else if (last_caller != NULL && |
166 instanceKlass::cast(last_caller->method_holder())->name() == |
166 InstanceKlass::cast(last_caller->method_holder())->name() == |
167 vmSymbols::java_lang_ClassLoader() && |
167 vmSymbols::java_lang_ClassLoader() && |
168 (last_caller->name() == vmSymbols::loadClassInternal_name() || |
168 (last_caller->name() == vmSymbols::loadClassInternal_name() || |
169 last_caller->name() == vmSymbols::loadClass_name())) { |
169 last_caller->name() == vmSymbols::loadClass_name())) { |
170 found_it = true; |
170 found_it = true; |
171 } else if (!vfst.at_end()) { |
171 } else if (!vfst.at_end()) { |
180 line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
180 line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
181 if (line_number == -1) { |
181 if (line_number == -1) { |
182 // show method name if it's a native method |
182 // show method name if it's a native method |
183 trace = vfst.method()->name_and_sig_as_C_string(); |
183 trace = vfst.method()->name_and_sig_as_C_string(); |
184 } |
184 } |
185 Symbol* s = instanceKlass::cast(caller)->source_file_name(); |
185 Symbol* s = InstanceKlass::cast(caller)->source_file_name(); |
186 if (s != NULL) { |
186 if (s != NULL) { |
187 source_file = s->as_C_string(); |
187 source_file = s->as_C_string(); |
188 } |
188 } |
189 } |
189 } |
190 } |
190 } |
200 } |
200 } |
201 } |
201 } |
202 } |
202 } |
203 } |
203 } |
204 |
204 |
205 void trace_class_resolution(klassOop to_class) { |
205 void trace_class_resolution(Klass* to_class) { |
206 EXCEPTION_MARK; |
206 EXCEPTION_MARK; |
207 trace_class_resolution_impl(to_class, THREAD); |
207 trace_class_resolution_impl(to_class, THREAD); |
208 if (HAS_PENDING_EXCEPTION) { |
208 if (HAS_PENDING_EXCEPTION) { |
209 CLEAR_PENDING_EXCEPTION; |
209 CLEAR_PENDING_EXCEPTION; |
210 } |
210 } |
520 |
520 |
521 |
521 |
522 JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)) |
522 JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)) |
523 JVMWrapper("JVM_MonitorWait"); |
523 JVMWrapper("JVM_MonitorWait"); |
524 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
524 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
525 assert(obj->is_instance() || obj->is_array(), "JVM_MonitorWait must apply to an object"); |
|
526 JavaThreadInObjectWaitState jtiows(thread, ms != 0); |
525 JavaThreadInObjectWaitState jtiows(thread, ms != 0); |
527 if (JvmtiExport::should_post_monitor_wait()) { |
526 if (JvmtiExport::should_post_monitor_wait()) { |
528 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); |
527 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); |
529 } |
528 } |
530 ObjectSynchronizer::wait(obj, ms, CHECK); |
529 ObjectSynchronizer::wait(obj, ms, CHECK); |
532 |
531 |
533 |
532 |
534 JVM_ENTRY(void, JVM_MonitorNotify(JNIEnv* env, jobject handle)) |
533 JVM_ENTRY(void, JVM_MonitorNotify(JNIEnv* env, jobject handle)) |
535 JVMWrapper("JVM_MonitorNotify"); |
534 JVMWrapper("JVM_MonitorNotify"); |
536 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
535 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
537 assert(obj->is_instance() || obj->is_array(), "JVM_MonitorNotify must apply to an object"); |
|
538 ObjectSynchronizer::notify(obj, CHECK); |
536 ObjectSynchronizer::notify(obj, CHECK); |
539 JVM_END |
537 JVM_END |
540 |
538 |
541 |
539 |
542 JVM_ENTRY(void, JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)) |
540 JVM_ENTRY(void, JVM_MonitorNotifyAll(JNIEnv* env, jobject handle)) |
543 JVMWrapper("JVM_MonitorNotifyAll"); |
541 JVMWrapper("JVM_MonitorNotifyAll"); |
544 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
542 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); |
545 assert(obj->is_instance() || obj->is_array(), "JVM_MonitorNotifyAll must apply to an object"); |
|
546 ObjectSynchronizer::notifyall(obj, CHECK); |
543 ObjectSynchronizer::notifyall(obj, CHECK); |
547 JVM_END |
544 JVM_END |
548 |
545 |
549 |
546 |
550 JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) |
547 JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) |
553 const KlassHandle klass (THREAD, obj->klass()); |
550 const KlassHandle klass (THREAD, obj->klass()); |
554 JvmtiVMObjectAllocEventCollector oam; |
551 JvmtiVMObjectAllocEventCollector oam; |
555 |
552 |
556 #ifdef ASSERT |
553 #ifdef ASSERT |
557 // Just checking that the cloneable flag is set correct |
554 // Just checking that the cloneable flag is set correct |
558 if (obj->is_javaArray()) { |
555 if (obj->is_array()) { |
559 guarantee(klass->is_cloneable(), "all arrays are cloneable"); |
556 guarantee(klass->is_cloneable(), "all arrays are cloneable"); |
560 } else { |
557 } else { |
561 guarantee(obj->is_instance(), "should be instanceOop"); |
558 guarantee(obj->is_instance(), "should be instanceOop"); |
562 bool cloneable = klass->is_subtype_of(SystemDictionary::Cloneable_klass()); |
559 bool cloneable = klass->is_subtype_of(SystemDictionary::Cloneable_klass()); |
563 guarantee(cloneable == klass->is_cloneable(), "incorrect cloneable flag"); |
560 guarantee(cloneable == klass->is_cloneable(), "incorrect cloneable flag"); |
572 } |
569 } |
573 |
570 |
574 // Make shallow object copy |
571 // Make shallow object copy |
575 const int size = obj->size(); |
572 const int size = obj->size(); |
576 oop new_obj = NULL; |
573 oop new_obj = NULL; |
577 if (obj->is_javaArray()) { |
574 if (obj->is_array()) { |
578 const int length = ((arrayOop)obj())->length(); |
575 const int length = ((arrayOop)obj())->length(); |
579 new_obj = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL); |
576 new_obj = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL); |
580 } else { |
577 } else { |
581 new_obj = CollectedHeap::obj_allocate(klass, size, CHECK_NULL); |
578 new_obj = CollectedHeap::obj_allocate(klass, size, CHECK_NULL); |
582 } |
579 } |
602 |
599 |
603 // Caution: this involves a java upcall, so the clone should be |
600 // Caution: this involves a java upcall, so the clone should be |
604 // "gc-robust" by this stage. |
601 // "gc-robust" by this stage. |
605 if (klass->has_finalizer()) { |
602 if (klass->has_finalizer()) { |
606 assert(obj->is_instance(), "should be instanceOop"); |
603 assert(obj->is_instance(), "should be instanceOop"); |
607 new_obj = instanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL); |
604 new_obj = InstanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL); |
608 } |
605 } |
609 |
606 |
610 return JNIHandles::make_local(env, oop(new_obj)); |
607 return JNIHandles::make_local(env, oop(new_obj)); |
611 JVM_END |
608 JVM_END |
612 |
609 |
675 // Misc. class handling /////////////////////////////////////////////////////////// |
672 // Misc. class handling /////////////////////////////////////////////////////////// |
676 |
673 |
677 |
674 |
678 JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) |
675 JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) |
679 JVMWrapper("JVM_GetCallerClass"); |
676 JVMWrapper("JVM_GetCallerClass"); |
680 klassOop k = thread->security_get_caller_class(depth); |
677 Klass* k = thread->security_get_caller_class(depth); |
681 return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); |
678 return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); |
682 JVM_END |
679 JVM_END |
683 |
680 |
684 |
681 |
685 JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)) |
682 JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)) |
732 // into the constant pool. |
729 // into the constant pool. |
733 return NULL; |
730 return NULL; |
734 } |
731 } |
735 |
732 |
736 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
733 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
737 klassOop k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); |
734 Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); |
738 if (k == NULL) { |
735 if (k == NULL) { |
739 return NULL; |
736 return NULL; |
740 } |
737 } |
741 |
738 |
742 if (TraceClassResolution) { |
739 if (TraceClassResolution) { |
764 Handle h_loader(THREAD, JNIHandles::resolve(loader)); |
761 Handle h_loader(THREAD, JNIHandles::resolve(loader)); |
765 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, |
762 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, |
766 Handle(), throwError, THREAD); |
763 Handle(), throwError, THREAD); |
767 |
764 |
768 if (TraceClassResolution && result != NULL) { |
765 if (TraceClassResolution && result != NULL) { |
769 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); |
766 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
770 } |
767 } |
771 return result; |
768 return result; |
772 JVM_END |
769 JVM_END |
773 |
770 |
774 |
771 |
780 // into the constant pool. |
777 // into the constant pool. |
781 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
778 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
782 } |
779 } |
783 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
780 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
784 oop from_class_oop = JNIHandles::resolve(from); |
781 oop from_class_oop = JNIHandles::resolve(from); |
785 klassOop from_class = (from_class_oop == NULL) |
782 Klass* from_class = (from_class_oop == NULL) |
786 ? (klassOop)NULL |
783 ? (Klass*)NULL |
787 : java_lang_Class::as_klassOop(from_class_oop); |
784 : java_lang_Class::as_Klass(from_class_oop); |
788 oop class_loader = NULL; |
785 oop class_loader = NULL; |
789 oop protection_domain = NULL; |
786 oop protection_domain = NULL; |
790 if (from_class != NULL) { |
787 if (from_class != NULL) { |
791 class_loader = Klass::cast(from_class)->class_loader(); |
788 class_loader = Klass::cast(from_class)->class_loader(); |
792 protection_domain = Klass::cast(from_class)->protection_domain(); |
789 protection_domain = Klass::cast(from_class)->protection_domain(); |
798 |
795 |
799 if (TraceClassResolution && result != NULL) { |
796 if (TraceClassResolution && result != NULL) { |
800 // this function is generally only used for class loading during verification. |
797 // this function is generally only used for class loading during verification. |
801 ResourceMark rm; |
798 ResourceMark rm; |
802 oop from_mirror = JNIHandles::resolve_non_null(from); |
799 oop from_mirror = JNIHandles::resolve_non_null(from); |
803 klassOop from_class = java_lang_Class::as_klassOop(from_mirror); |
800 Klass* from_class = java_lang_Class::as_Klass(from_mirror); |
804 const char * from_name = Klass::cast(from_class)->external_name(); |
801 const char * from_name = Klass::cast(from_class)->external_name(); |
805 |
802 |
806 oop mirror = JNIHandles::resolve_non_null(result); |
803 oop mirror = JNIHandles::resolve_non_null(result); |
807 klassOop to_class = java_lang_Class::as_klassOop(mirror); |
804 Klass* to_class = java_lang_Class::as_Klass(mirror); |
808 const char * to = Klass::cast(to_class)->external_name(); |
805 const char * to = Klass::cast(to_class)->external_name(); |
809 tty->print("RESOLVE %s %s (verification)\n", from_name, to); |
806 tty->print("RESOLVE %s %s (verification)\n", from_name, to); |
810 } |
807 } |
811 |
808 |
812 return result; |
809 return result; |
867 is_lock_held_by_thread(class_loader, |
864 is_lock_held_by_thread(class_loader, |
868 ClassLoader::sync_JVMDefineClassLockFreeCounter(), |
865 ClassLoader::sync_JVMDefineClassLockFreeCounter(), |
869 THREAD); |
866 THREAD); |
870 } |
867 } |
871 Handle protection_domain (THREAD, JNIHandles::resolve(pd)); |
868 Handle protection_domain (THREAD, JNIHandles::resolve(pd)); |
872 klassOop k = SystemDictionary::resolve_from_stream(class_name, class_loader, |
869 Klass* k = SystemDictionary::resolve_from_stream(class_name, class_loader, |
873 protection_domain, &st, |
870 protection_domain, &st, |
874 verify != 0, |
871 verify != 0, |
875 CHECK_NULL); |
872 CHECK_NULL); |
876 |
873 |
877 if (TraceClassResolution && k != NULL) { |
874 if (TraceClassResolution && k != NULL) { |
931 is_lock_held_by_thread(h_loader, |
928 is_lock_held_by_thread(h_loader, |
932 ClassLoader::sync_JVMFindLoadedClassLockFreeCounter(), |
929 ClassLoader::sync_JVMFindLoadedClassLockFreeCounter(), |
933 THREAD); |
930 THREAD); |
934 } |
931 } |
935 |
932 |
936 klassOop k = SystemDictionary::find_instance_or_array_klass(klass_name, |
933 Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name, |
937 h_loader, |
934 h_loader, |
938 Handle(), |
935 Handle(), |
939 CHECK_NULL); |
936 CHECK_NULL); |
940 |
937 |
941 return (k == NULL) ? NULL : |
938 return (k == NULL) ? NULL : |
953 const char* name; |
950 const char* name; |
954 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
951 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
955 name = type2name(java_lang_Class::primitive_type(JNIHandles::resolve(cls))); |
952 name = type2name(java_lang_Class::primitive_type(JNIHandles::resolve(cls))); |
956 } else { |
953 } else { |
957 // Consider caching interned string in Klass |
954 // Consider caching interned string in Klass |
958 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); |
955 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
959 assert(k->is_klass(), "just checking"); |
956 assert(k->is_klass(), "just checking"); |
960 name = Klass::cast(k)->external_name(); |
957 name = Klass::cast(k)->external_name(); |
961 } |
958 } |
962 oop result = StringTable::intern((char*) name, CHECK_NULL); |
959 oop result = StringTable::intern((char*) name, CHECK_NULL); |
963 return (jstring) JNIHandles::make_local(env, result); |
960 return (jstring) JNIHandles::make_local(env, result); |
974 // Primitive objects does not have any interfaces |
971 // Primitive objects does not have any interfaces |
975 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
972 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
976 return (jobjectArray) JNIHandles::make_local(env, r); |
973 return (jobjectArray) JNIHandles::make_local(env, r); |
977 } |
974 } |
978 |
975 |
979 KlassHandle klass(thread, java_lang_Class::as_klassOop(mirror)); |
976 KlassHandle klass(thread, java_lang_Class::as_Klass(mirror)); |
980 // Figure size of result array |
977 // Figure size of result array |
981 int size; |
978 int size; |
982 if (klass->oop_is_instance()) { |
979 if (klass->oop_is_instance()) { |
983 size = instanceKlass::cast(klass())->local_interfaces()->length(); |
980 size = InstanceKlass::cast(klass())->local_interfaces()->length(); |
984 } else { |
981 } else { |
985 assert(klass->oop_is_objArray() || klass->oop_is_typeArray(), "Illegal mirror klass"); |
982 assert(klass->oop_is_objArray() || klass->oop_is_typeArray(), "Illegal mirror klass"); |
986 size = 2; |
983 size = 2; |
987 } |
984 } |
988 |
985 |
991 objArrayHandle result (THREAD, r); |
988 objArrayHandle result (THREAD, r); |
992 // Fill in result |
989 // Fill in result |
993 if (klass->oop_is_instance()) { |
990 if (klass->oop_is_instance()) { |
994 // Regular instance klass, fill in all local interfaces |
991 // Regular instance klass, fill in all local interfaces |
995 for (int index = 0; index < size; index++) { |
992 for (int index = 0; index < size; index++) { |
996 klassOop k = klassOop(instanceKlass::cast(klass())->local_interfaces()->obj_at(index)); |
993 Klass* k = InstanceKlass::cast(klass())->local_interfaces()->at(index); |
997 result->obj_at_put(index, Klass::cast(k)->java_mirror()); |
994 result->obj_at_put(index, Klass::cast(k)->java_mirror()); |
998 } |
995 } |
999 } else { |
996 } else { |
1000 // All arrays implement java.lang.Cloneable and java.io.Serializable |
997 // All arrays implement java.lang.Cloneable and java.io.Serializable |
1001 result->obj_at_put(0, Klass::cast(SystemDictionary::Cloneable_klass())->java_mirror()); |
998 result->obj_at_put(0, Klass::cast(SystemDictionary::Cloneable_klass())->java_mirror()); |
1008 JVM_ENTRY(jobject, JVM_GetClassLoader(JNIEnv *env, jclass cls)) |
1005 JVM_ENTRY(jobject, JVM_GetClassLoader(JNIEnv *env, jclass cls)) |
1009 JVMWrapper("JVM_GetClassLoader"); |
1006 JVMWrapper("JVM_GetClassLoader"); |
1010 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1007 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1011 return NULL; |
1008 return NULL; |
1012 } |
1009 } |
1013 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
1010 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1014 oop loader = Klass::cast(k)->class_loader(); |
1011 oop loader = Klass::cast(k)->class_loader(); |
1015 return JNIHandles::make_local(env, loader); |
1012 return JNIHandles::make_local(env, loader); |
1016 JVM_END |
1013 JVM_END |
1017 |
1014 |
1018 |
1015 |
1020 JVMWrapper("JVM_IsInterface"); |
1017 JVMWrapper("JVM_IsInterface"); |
1021 oop mirror = JNIHandles::resolve_non_null(cls); |
1018 oop mirror = JNIHandles::resolve_non_null(cls); |
1022 if (java_lang_Class::is_primitive(mirror)) { |
1019 if (java_lang_Class::is_primitive(mirror)) { |
1023 return JNI_FALSE; |
1020 return JNI_FALSE; |
1024 } |
1021 } |
1025 klassOop k = java_lang_Class::as_klassOop(mirror); |
1022 Klass* k = java_lang_Class::as_Klass(mirror); |
1026 jboolean result = Klass::cast(k)->is_interface(); |
1023 jboolean result = Klass::cast(k)->is_interface(); |
1027 assert(!result || Klass::cast(k)->oop_is_instance(), |
1024 assert(!result || Klass::cast(k)->oop_is_instance(), |
1028 "all interfaces are instance types"); |
1025 "all interfaces are instance types"); |
1029 // The compiler intrinsic for isInterface tests the |
1026 // The compiler intrinsic for isInterface tests the |
1030 // Klass::_access_flags bits in the same way. |
1027 // Klass::_access_flags bits in the same way. |
1038 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1035 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1039 // There are no signers for primitive types |
1036 // There are no signers for primitive types |
1040 return NULL; |
1037 return NULL; |
1041 } |
1038 } |
1042 |
1039 |
1043 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
1040 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1044 objArrayOop signers = NULL; |
1041 objArrayOop signers = NULL; |
1045 if (Klass::cast(k)->oop_is_instance()) { |
1042 if (Klass::cast(k)->oop_is_instance()) { |
1046 signers = instanceKlass::cast(k)->signers(); |
1043 signers = InstanceKlass::cast(k)->signers(); |
1047 } |
1044 } |
1048 |
1045 |
1049 // If there are no signers set in the class, or if the class |
1046 // If there are no signers set in the class, or if the class |
1050 // is an array, return NULL. |
1047 // is an array, return NULL. |
1051 if (signers == NULL) return NULL; |
1048 if (signers == NULL) return NULL; |
1052 |
1049 |
1053 // copy of the signers array |
1050 // copy of the signers array |
1054 klassOop element = objArrayKlass::cast(signers->klass())->element_klass(); |
1051 Klass* element = objArrayKlass::cast(signers->klass())->element_klass(); |
1055 objArrayOop signers_copy = oopFactory::new_objArray(element, signers->length(), CHECK_NULL); |
1052 objArrayOop signers_copy = oopFactory::new_objArray(element, signers->length(), CHECK_NULL); |
1056 for (int index = 0; index < signers->length(); index++) { |
1053 for (int index = 0; index < signers->length(); index++) { |
1057 signers_copy->obj_at_put(index, signers->obj_at(index)); |
1054 signers_copy->obj_at_put(index, signers->obj_at(index)); |
1058 } |
1055 } |
1059 |
1056 |
1066 JVMWrapper("JVM_SetClassSigners"); |
1063 JVMWrapper("JVM_SetClassSigners"); |
1067 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1064 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1068 // This call is ignored for primitive types and arrays. |
1065 // This call is ignored for primitive types and arrays. |
1069 // Signers are only set once, ClassLoader.java, and thus shouldn't |
1066 // Signers are only set once, ClassLoader.java, and thus shouldn't |
1070 // be called with an array. Only the bootstrap loader creates arrays. |
1067 // be called with an array. Only the bootstrap loader creates arrays. |
1071 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
1068 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1072 if (Klass::cast(k)->oop_is_instance()) { |
1069 if (Klass::cast(k)->oop_is_instance()) { |
1073 instanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers))); |
1070 InstanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers))); |
1074 } |
1071 } |
1075 } |
1072 } |
1076 JVM_END |
1073 JVM_END |
1077 |
1074 |
1078 |
1075 |
1085 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1082 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1086 // Primitive types does not have a protection domain. |
1083 // Primitive types does not have a protection domain. |
1087 return NULL; |
1084 return NULL; |
1088 } |
1085 } |
1089 |
1086 |
1090 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); |
1087 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
1091 return (jobject) JNIHandles::make_local(env, Klass::cast(k)->protection_domain()); |
1088 return (jobject) JNIHandles::make_local(env, Klass::cast(k)->protection_domain()); |
1092 JVM_END |
1089 JVM_END |
1093 |
1090 |
1094 |
1091 |
1095 // Obsolete since 1.2 (Class.setProtectionDomain removed), although |
1092 // Obsolete since 1.2 (Class.setProtectionDomain removed), although |
1099 if (JNIHandles::resolve(cls) == NULL) { |
1096 if (JNIHandles::resolve(cls) == NULL) { |
1100 THROW(vmSymbols::java_lang_NullPointerException()); |
1097 THROW(vmSymbols::java_lang_NullPointerException()); |
1101 } |
1098 } |
1102 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1099 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1103 // Call is ignored for primitive types |
1100 // Call is ignored for primitive types |
1104 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); |
1101 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
1105 |
1102 |
1106 // cls won't be an array, as this called only from ClassLoader.defineClass |
1103 // cls won't be an array, as this called only from ClassLoader.defineClass |
1107 if (Klass::cast(k)->oop_is_instance()) { |
1104 if (Klass::cast(k)->oop_is_instance()) { |
1108 oop pd = JNIHandles::resolve(protection_domain); |
1105 oop pd = JNIHandles::resolve(protection_domain); |
1109 assert(pd == NULL || pd->is_oop(), "just checking"); |
1106 assert(pd == NULL || pd->is_oop(), "just checking"); |
1110 instanceKlass::cast(k)->set_protection_domain(pd); |
1107 InstanceKlass::cast(k)->set_protection_domain(pd); |
1111 } |
1108 } |
1112 } |
1109 } |
1113 JVM_END |
1110 JVM_END |
1114 |
1111 |
1115 |
1112 |
1125 |
1122 |
1126 // Check that action object understands "Object run()" |
1123 // Check that action object understands "Object run()" |
1127 Handle object (THREAD, JNIHandles::resolve(action)); |
1124 Handle object (THREAD, JNIHandles::resolve(action)); |
1128 |
1125 |
1129 // get run() method |
1126 // get run() method |
1130 methodOop m_oop = Klass::cast(object->klass())->uncached_lookup_method( |
1127 Method* m_oop = Klass::cast(object->klass())->uncached_lookup_method( |
1131 vmSymbols::run_method_name(), |
1128 vmSymbols::run_method_name(), |
1132 vmSymbols::void_object_signature()); |
1129 vmSymbols::void_object_signature()); |
1133 methodHandle m (THREAD, m_oop); |
1130 methodHandle m (THREAD, m_oop); |
1134 if (m.is_null() || !m->is_method() || !methodOop(m())->is_public() || methodOop(m())->is_static()) { |
1131 if (m.is_null() || !m->is_method() || !m()->is_public() || m()->is_static()) { |
1135 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method"); |
1132 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method"); |
1136 } |
1133 } |
1137 |
1134 |
1138 // Compute the frame initiating the do privileged operation and setup the privileged stack |
1135 // Compute the frame initiating the do privileged operation and setup the privileged stack |
1139 vframeStream vfst(thread); |
1136 vframeStream vfst(thread); |
1219 bool is_privileged = false; |
1216 bool is_privileged = false; |
1220 oop protection_domain = NULL; |
1217 oop protection_domain = NULL; |
1221 |
1218 |
1222 for(; !vfst.at_end(); vfst.next()) { |
1219 for(; !vfst.at_end(); vfst.next()) { |
1223 // get method of frame |
1220 // get method of frame |
1224 methodOop method = vfst.method(); |
1221 Method* method = vfst.method(); |
1225 intptr_t* frame_id = vfst.frame_id(); |
1222 intptr_t* frame_id = vfst.frame_id(); |
1226 |
1223 |
1227 // check the privileged frames to see if we have a match |
1224 // check the privileged frames to see if we have a match |
1228 if (thread->privileged_stack_top() && thread->privileged_stack_top()->frame_id() == frame_id) { |
1225 if (thread->privileged_stack_top() && thread->privileged_stack_top()->frame_id() == frame_id) { |
1229 // this frame is privileged |
1226 // this frame is privileged |
1230 is_privileged = true; |
1227 is_privileged = true; |
1231 privileged_context = Handle(thread, thread->privileged_stack_top()->privileged_context()); |
1228 privileged_context = Handle(thread, thread->privileged_stack_top()->privileged_context()); |
1232 protection_domain = thread->privileged_stack_top()->protection_domain(); |
1229 protection_domain = thread->privileged_stack_top()->protection_domain(); |
1233 } else { |
1230 } else { |
1234 protection_domain = instanceKlass::cast(method->method_holder())->protection_domain(); |
1231 protection_domain = InstanceKlass::cast(method->method_holder())->protection_domain(); |
1235 } |
1232 } |
1236 |
1233 |
1237 if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) { |
1234 if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) { |
1238 local_array->push(protection_domain); |
1235 local_array->push(protection_domain); |
1239 previous_protection_domain = protection_domain; |
1236 previous_protection_domain = protection_domain; |
1267 JVM_END |
1264 JVM_END |
1268 |
1265 |
1269 |
1266 |
1270 JVM_QUICK_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls)) |
1267 JVM_QUICK_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls)) |
1271 JVMWrapper("JVM_IsArrayClass"); |
1268 JVMWrapper("JVM_IsArrayClass"); |
1272 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
1269 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1273 return (k != NULL) && Klass::cast(k)->oop_is_javaArray() ? true : false; |
1270 return (k != NULL) && Klass::cast(k)->oop_is_array() ? true : false; |
1274 JVM_END |
1271 JVM_END |
1275 |
1272 |
1276 |
1273 |
1277 JVM_QUICK_ENTRY(jboolean, JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)) |
1274 JVM_QUICK_ENTRY(jboolean, JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)) |
1278 JVMWrapper("JVM_IsPrimitiveClass"); |
1275 JVMWrapper("JVM_IsPrimitiveClass"); |
1294 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1291 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1295 // Primitive type |
1292 // Primitive type |
1296 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
1293 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
1297 } |
1294 } |
1298 |
1295 |
1299 Klass* k = Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls))); |
1296 Klass* k = Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); |
1300 debug_only(int computed_modifiers = k->compute_modifier_flags(CHECK_0)); |
1297 debug_only(int computed_modifiers = k->compute_modifier_flags(CHECK_0)); |
1301 assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK"); |
1298 assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK"); |
1302 return k->modifier_flags(); |
1299 return k->modifier_flags(); |
1303 JVM_END |
1300 JVM_END |
1304 |
1301 |
1306 // Inner class reflection /////////////////////////////////////////////////////////////////////////////// |
1303 // Inner class reflection /////////////////////////////////////////////////////////////////////////////// |
1307 |
1304 |
1308 JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) |
1305 JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) |
1309 JvmtiVMObjectAllocEventCollector oam; |
1306 JvmtiVMObjectAllocEventCollector oam; |
1310 // ofClass is a reference to a java_lang_Class object. The mirror object |
1307 // ofClass is a reference to a java_lang_Class object. The mirror object |
1311 // of an instanceKlass |
1308 // of an InstanceKlass |
1312 |
1309 |
1313 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1310 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1314 ! Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) { |
1311 ! Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) { |
1315 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1312 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1316 return (jobjectArray)JNIHandles::make_local(env, result); |
1313 return (jobjectArray)JNIHandles::make_local(env, result); |
1317 } |
1314 } |
1318 |
1315 |
1319 instanceKlassHandle k(thread, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass))); |
1316 instanceKlassHandle k(thread, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1320 InnerClassesIterator iter(k); |
1317 InnerClassesIterator iter(k); |
1321 |
1318 |
1322 if (iter.length() == 0) { |
1319 if (iter.length() == 0) { |
1323 // Neither an inner nor outer class |
1320 // Neither an inner nor outer class |
1324 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1321 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1340 |
1337 |
1341 if (ioff != 0 && ooff != 0) { |
1338 if (ioff != 0 && ooff != 0) { |
1342 // Check to see if the name matches the class we're looking for |
1339 // Check to see if the name matches the class we're looking for |
1343 // before attempting to find the class. |
1340 // before attempting to find the class. |
1344 if (cp->klass_name_at_matches(k, ooff)) { |
1341 if (cp->klass_name_at_matches(k, ooff)) { |
1345 klassOop outer_klass = cp->klass_at(ooff, CHECK_NULL); |
1342 Klass* outer_klass = cp->klass_at(ooff, CHECK_NULL); |
1346 if (outer_klass == k()) { |
1343 if (outer_klass == k()) { |
1347 klassOop ik = cp->klass_at(ioff, CHECK_NULL); |
1344 Klass* ik = cp->klass_at(ioff, CHECK_NULL); |
1348 instanceKlassHandle inner_klass (THREAD, ik); |
1345 instanceKlassHandle inner_klass (THREAD, ik); |
1349 |
1346 |
1350 // Throws an exception if outer klass has not declared k as |
1347 // Throws an exception if outer klass has not declared k as |
1351 // an inner klass |
1348 // an inner klass |
1352 Reflection::check_for_inner_class(k, inner_klass, true, CHECK_NULL); |
1349 Reflection::check_for_inner_class(k, inner_klass, true, CHECK_NULL); |
1373 |
1370 |
1374 JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)) |
1371 JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)) |
1375 { |
1372 { |
1376 // ofClass is a reference to a java_lang_Class object. |
1373 // ofClass is a reference to a java_lang_Class object. |
1377 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1374 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1378 ! Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) { |
1375 ! Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_instance()) { |
1379 return NULL; |
1376 return NULL; |
1380 } |
1377 } |
1381 |
1378 |
1382 bool inner_is_member = false; |
1379 bool inner_is_member = false; |
1383 klassOop outer_klass |
1380 Klass* outer_klass |
1384 = instanceKlass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass)) |
1381 = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)) |
1385 )->compute_enclosing_class(&inner_is_member, CHECK_NULL); |
1382 )->compute_enclosing_class(&inner_is_member, CHECK_NULL); |
1386 if (outer_klass == NULL) return NULL; // already a top-level class |
1383 if (outer_klass == NULL) return NULL; // already a top-level class |
1387 if (!inner_is_member) return NULL; // an anonymous class (inside a method) |
1384 if (!inner_is_member) return NULL; // an anonymous class (inside a method) |
1388 return (jclass) JNIHandles::make_local(env, Klass::cast(outer_klass)->java_mirror()); |
1385 return (jclass) JNIHandles::make_local(env, Klass::cast(outer_klass)->java_mirror()); |
1389 } |
1386 } |
1390 JVM_END |
1387 JVM_END |
1391 |
1388 |
1392 // should be in instanceKlass.cpp, but is here for historical reasons |
1389 // should be in InstanceKlass.cpp, but is here for historical reasons |
1393 klassOop instanceKlass::compute_enclosing_class_impl(instanceKlassHandle k, |
1390 Klass* InstanceKlass::compute_enclosing_class_impl(instanceKlassHandle k, |
1394 bool* inner_is_member, |
1391 bool* inner_is_member, |
1395 TRAPS) { |
1392 TRAPS) { |
1396 Thread* thread = THREAD; |
1393 Thread* thread = THREAD; |
1397 InnerClassesIterator iter(k); |
1394 InnerClassesIterator iter(k); |
1398 if (iter.length() == 0) { |
1395 if (iter.length() == 0) { |
1401 } |
1398 } |
1402 |
1399 |
1403 constantPoolHandle i_cp(thread, k->constants()); |
1400 constantPoolHandle i_cp(thread, k->constants()); |
1404 |
1401 |
1405 bool found = false; |
1402 bool found = false; |
1406 klassOop ok; |
1403 Klass* ok; |
1407 instanceKlassHandle outer_klass; |
1404 instanceKlassHandle outer_klass; |
1408 *inner_is_member = false; |
1405 *inner_is_member = false; |
1409 |
1406 |
1410 // Find inner_klass attribute |
1407 // Find inner_klass attribute |
1411 for (; !iter.done() && !found; iter.next()) { |
1408 for (; !iter.done() && !found; iter.next()) { |
1414 int noff = iter.inner_name_index(); |
1411 int noff = iter.inner_name_index(); |
1415 if (ioff != 0) { |
1412 if (ioff != 0) { |
1416 // Check to see if the name matches the class we're looking for |
1413 // Check to see if the name matches the class we're looking for |
1417 // before attempting to find the class. |
1414 // before attempting to find the class. |
1418 if (i_cp->klass_name_at_matches(k, ioff)) { |
1415 if (i_cp->klass_name_at_matches(k, ioff)) { |
1419 klassOop inner_klass = i_cp->klass_at(ioff, CHECK_NULL); |
1416 Klass* inner_klass = i_cp->klass_at(ioff, CHECK_NULL); |
1420 found = (k() == inner_klass); |
1417 found = (k() == inner_klass); |
1421 if (found && ooff != 0) { |
1418 if (found && ooff != 0) { |
1422 ok = i_cp->klass_at(ooff, CHECK_NULL); |
1419 ok = i_cp->klass_at(ooff, CHECK_NULL); |
1423 outer_klass = instanceKlassHandle(thread, ok); |
1420 outer_klass = instanceKlassHandle(thread, ok); |
1424 *inner_is_member = true; |
1421 *inner_is_member = true; |
1452 JVMWrapper("JVM_GetClassSignature"); |
1449 JVMWrapper("JVM_GetClassSignature"); |
1453 JvmtiVMObjectAllocEventCollector oam; |
1450 JvmtiVMObjectAllocEventCollector oam; |
1454 ResourceMark rm(THREAD); |
1451 ResourceMark rm(THREAD); |
1455 // Return null for arrays and primatives |
1452 // Return null for arrays and primatives |
1456 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1453 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1457 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); |
1454 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
1458 if (Klass::cast(k)->oop_is_instance()) { |
1455 if (Klass::cast(k)->oop_is_instance()) { |
1459 Symbol* sym = instanceKlass::cast(k)->generic_signature(); |
1456 Symbol* sym = InstanceKlass::cast(k)->generic_signature(); |
1460 if (sym == NULL) return NULL; |
1457 if (sym == NULL) return NULL; |
1461 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
1458 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
1462 return (jstring) JNIHandles::make_local(env, str()); |
1459 return (jstring) JNIHandles::make_local(env, str()); |
1463 } |
1460 } |
1464 } |
1461 } |
1470 assert (cls != NULL, "illegal class"); |
1467 assert (cls != NULL, "illegal class"); |
1471 JVMWrapper("JVM_GetClassAnnotations"); |
1468 JVMWrapper("JVM_GetClassAnnotations"); |
1472 ResourceMark rm(THREAD); |
1469 ResourceMark rm(THREAD); |
1473 // Return null for arrays and primitives |
1470 // Return null for arrays and primitives |
1474 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1471 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1475 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); |
1472 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); |
1476 if (Klass::cast(k)->oop_is_instance()) { |
1473 if (Klass::cast(k)->oop_is_instance()) { |
1477 return (jbyteArray) JNIHandles::make_local(env, |
1474 typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->class_annotations(), CHECK_NULL); |
1478 instanceKlass::cast(k)->class_annotations()); |
1475 return (jbyteArray) JNIHandles::make_local(env, a); |
1479 } |
1476 } |
1480 } |
1477 } |
1481 return NULL; |
1478 return NULL; |
1482 JVM_END |
1479 JVM_END |
1483 |
1480 |
1489 // some of this code was adapted from from jni_FromReflectedField |
1486 // some of this code was adapted from from jni_FromReflectedField |
1490 |
1487 |
1491 // field is a handle to a java.lang.reflect.Field object |
1488 // field is a handle to a java.lang.reflect.Field object |
1492 oop reflected = JNIHandles::resolve_non_null(field); |
1489 oop reflected = JNIHandles::resolve_non_null(field); |
1493 oop mirror = java_lang_reflect_Field::clazz(reflected); |
1490 oop mirror = java_lang_reflect_Field::clazz(reflected); |
1494 klassOop k = java_lang_Class::as_klassOop(mirror); |
1491 Klass* k = java_lang_Class::as_Klass(mirror); |
1495 int slot = java_lang_reflect_Field::slot(reflected); |
1492 int slot = java_lang_reflect_Field::slot(reflected); |
1496 int modifiers = java_lang_reflect_Field::modifiers(reflected); |
1493 int modifiers = java_lang_reflect_Field::modifiers(reflected); |
1497 |
1494 |
1498 fieldDescriptor fd; |
1495 fieldDescriptor fd; |
1499 KlassHandle kh(THREAD, k); |
1496 KlassHandle kh(THREAD, k); |
1500 intptr_t offset = instanceKlass::cast(kh())->field_offset(slot); |
1497 intptr_t offset = InstanceKlass::cast(kh())->field_offset(slot); |
1501 |
1498 |
1502 if (modifiers & JVM_ACC_STATIC) { |
1499 if (modifiers & JVM_ACC_STATIC) { |
1503 // for static fields we only look in the current class |
1500 // for static fields we only look in the current class |
1504 if (!instanceKlass::cast(kh())->find_local_field_from_offset(offset, |
1501 if (!InstanceKlass::cast(kh())->find_local_field_from_offset(offset, true, &fd)) { |
1505 true, &fd)) { |
|
1506 assert(false, "cannot find static field"); |
1502 assert(false, "cannot find static field"); |
1507 return NULL; // robustness |
1503 return NULL; // robustness |
1508 } |
1504 } |
1509 } else { |
1505 } else { |
1510 // for instance fields we start with the current class and work |
1506 // for instance fields we start with the current class and work |
1511 // our way up through the superclass chain |
1507 // our way up through the superclass chain |
1512 if (!instanceKlass::cast(kh())->find_field_from_offset(offset, false, |
1508 if (!InstanceKlass::cast(kh())->find_field_from_offset(offset, false, &fd)) { |
1513 &fd)) { |
|
1514 assert(false, "cannot find instance field"); |
1509 assert(false, "cannot find instance field"); |
1515 return NULL; // robustness |
1510 return NULL; // robustness |
1516 } |
1511 } |
1517 } |
1512 } |
1518 |
1513 |
1519 return (jbyteArray) JNIHandles::make_local(env, fd.annotations()); |
1514 return (jbyteArray) JNIHandles::make_local(env, Annotations::make_java_array(fd.annotations(), THREAD)); |
1520 JVM_END |
1515 JVM_END |
1521 |
1516 |
1522 |
1517 |
1523 static methodOop jvm_get_method_common(jobject method, TRAPS) { |
1518 static Method* jvm_get_method_common(jobject method, TRAPS) { |
1524 // some of this code was adapted from from jni_FromReflectedMethod |
1519 // some of this code was adapted from from jni_FromReflectedMethod |
1525 |
1520 |
1526 oop reflected = JNIHandles::resolve_non_null(method); |
1521 oop reflected = JNIHandles::resolve_non_null(method); |
1527 oop mirror = NULL; |
1522 oop mirror = NULL; |
1528 int slot = 0; |
1523 int slot = 0; |
1534 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), |
1529 assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), |
1535 "wrong type"); |
1530 "wrong type"); |
1536 mirror = java_lang_reflect_Method::clazz(reflected); |
1531 mirror = java_lang_reflect_Method::clazz(reflected); |
1537 slot = java_lang_reflect_Method::slot(reflected); |
1532 slot = java_lang_reflect_Method::slot(reflected); |
1538 } |
1533 } |
1539 klassOop k = java_lang_Class::as_klassOop(mirror); |
1534 Klass* k = java_lang_Class::as_Klass(mirror); |
1540 |
1535 |
1541 KlassHandle kh(THREAD, k); |
1536 KlassHandle kh(THREAD, k); |
1542 methodOop m = instanceKlass::cast(kh())->method_with_idnum(slot); |
1537 Method* m = InstanceKlass::cast(kh())->method_with_idnum(slot); |
1543 if (m == NULL) { |
1538 if (m == NULL) { |
1544 assert(false, "cannot find method"); |
1539 assert(false, "cannot find method"); |
1545 return NULL; // robustness |
1540 return NULL; // robustness |
1546 } |
1541 } |
1547 |
1542 |
1551 |
1546 |
1552 JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) |
1547 JVM_ENTRY(jbyteArray, JVM_GetMethodAnnotations(JNIEnv *env, jobject method)) |
1553 JVMWrapper("JVM_GetMethodAnnotations"); |
1548 JVMWrapper("JVM_GetMethodAnnotations"); |
1554 |
1549 |
1555 // method is a handle to a java.lang.reflect.Method object |
1550 // method is a handle to a java.lang.reflect.Method object |
1556 methodOop m = jvm_get_method_common(method, CHECK_NULL); |
1551 Method* m = jvm_get_method_common(method, CHECK_NULL); |
1557 return (jbyteArray) JNIHandles::make_local(env, m->annotations()); |
1552 return (jbyteArray) JNIHandles::make_local(env, |
1553 Annotations::make_java_array(m->annotations(), THREAD)); |
|
1558 JVM_END |
1554 JVM_END |
1559 |
1555 |
1560 |
1556 |
1561 JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)) |
1557 JVM_ENTRY(jbyteArray, JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)) |
1562 JVMWrapper("JVM_GetMethodDefaultAnnotationValue"); |
1558 JVMWrapper("JVM_GetMethodDefaultAnnotationValue"); |
1563 |
1559 |
1564 // method is a handle to a java.lang.reflect.Method object |
1560 // method is a handle to a java.lang.reflect.Method object |
1565 methodOop m = jvm_get_method_common(method, CHECK_NULL); |
1561 Method* m = jvm_get_method_common(method, CHECK_NULL); |
1566 return (jbyteArray) JNIHandles::make_local(env, m->annotation_default()); |
1562 return (jbyteArray) JNIHandles::make_local(env, |
1563 Annotations::make_java_array(m->annotation_default(), THREAD)); |
|
1567 JVM_END |
1564 JVM_END |
1568 |
1565 |
1569 |
1566 |
1570 JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)) |
1567 JVM_ENTRY(jbyteArray, JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)) |
1571 JVMWrapper("JVM_GetMethodParameterAnnotations"); |
1568 JVMWrapper("JVM_GetMethodParameterAnnotations"); |
1572 |
1569 |
1573 // method is a handle to a java.lang.reflect.Method object |
1570 // method is a handle to a java.lang.reflect.Method object |
1574 methodOop m = jvm_get_method_common(method, CHECK_NULL); |
1571 Method* m = jvm_get_method_common(method, CHECK_NULL); |
1575 return (jbyteArray) JNIHandles::make_local(env, m->parameter_annotations()); |
1572 return (jbyteArray) JNIHandles::make_local(env, |
1573 Annotations::make_java_array(m->parameter_annotations(), THREAD)); |
|
1576 JVM_END |
1574 JVM_END |
1577 |
1575 |
1578 |
1576 |
1579 // New (JDK 1.4) reflection implementation ///////////////////////////////////// |
1577 // New (JDK 1.4) reflection implementation ///////////////////////////////////// |
1580 |
1578 |
1583 JVMWrapper("JVM_GetClassDeclaredFields"); |
1581 JVMWrapper("JVM_GetClassDeclaredFields"); |
1584 JvmtiVMObjectAllocEventCollector oam; |
1582 JvmtiVMObjectAllocEventCollector oam; |
1585 |
1583 |
1586 // Exclude primitive types and array types |
1584 // Exclude primitive types and array types |
1587 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1585 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1588 Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass)))->oop_is_javaArray()) { |
1586 Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) { |
1589 // Return empty array |
1587 // Return empty array |
1590 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); |
1588 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); |
1591 return (jobjectArray) JNIHandles::make_local(env, res); |
1589 return (jobjectArray) JNIHandles::make_local(env, res); |
1592 } |
1590 } |
1593 |
1591 |
1594 instanceKlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass))); |
1592 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1595 constantPoolHandle cp(THREAD, k->constants()); |
1593 constantPoolHandle cp(THREAD, k->constants()); |
1596 |
1594 |
1597 // Ensure class is linked |
1595 // Ensure class is linked |
1598 k->link_class(CHECK_NULL); |
1596 k->link_class(CHECK_NULL); |
1599 |
1597 |
1646 JVMWrapper("JVM_GetClassDeclaredMethods"); |
1644 JVMWrapper("JVM_GetClassDeclaredMethods"); |
1647 JvmtiVMObjectAllocEventCollector oam; |
1645 JvmtiVMObjectAllocEventCollector oam; |
1648 |
1646 |
1649 // Exclude primitive types and array types |
1647 // Exclude primitive types and array types |
1650 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) |
1648 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) |
1651 || Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass)))->oop_is_javaArray()) { |
1649 || Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) { |
1652 // Return empty array |
1650 // Return empty array |
1653 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), 0, CHECK_NULL); |
1651 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), 0, CHECK_NULL); |
1654 return (jobjectArray) JNIHandles::make_local(env, res); |
1652 return (jobjectArray) JNIHandles::make_local(env, res); |
1655 } |
1653 } |
1656 |
1654 |
1657 instanceKlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass))); |
1655 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1658 |
1656 |
1659 // Ensure class is linked |
1657 // Ensure class is linked |
1660 k->link_class(CHECK_NULL); |
1658 k->link_class(CHECK_NULL); |
1661 |
1659 |
1662 objArrayHandle methods (THREAD, k->methods()); |
1660 Array<Method*>* methods = k->methods(); |
1663 int methods_length = methods->length(); |
1661 int methods_length = methods->length(); |
1664 int num_methods = 0; |
1662 int num_methods = 0; |
1665 |
1663 |
1666 int i; |
1664 int i; |
1667 for (i = 0; i < methods_length; i++) { |
1665 for (i = 0; i < methods_length; i++) { |
1668 methodHandle method(THREAD, (methodOop) methods->obj_at(i)); |
1666 methodHandle method(THREAD, methods->at(i)); |
1669 if (!method->is_initializer()) { |
1667 if (!method->is_initializer()) { |
1670 if (!publicOnly || method->is_public()) { |
1668 if (!publicOnly || method->is_public()) { |
1671 ++num_methods; |
1669 ++num_methods; |
1672 } |
1670 } |
1673 } |
1671 } |
1677 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), num_methods, CHECK_NULL); |
1675 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), num_methods, CHECK_NULL); |
1678 objArrayHandle result (THREAD, r); |
1676 objArrayHandle result (THREAD, r); |
1679 |
1677 |
1680 int out_idx = 0; |
1678 int out_idx = 0; |
1681 for (i = 0; i < methods_length; i++) { |
1679 for (i = 0; i < methods_length; i++) { |
1682 methodHandle method(THREAD, (methodOop) methods->obj_at(i)); |
1680 methodHandle method(THREAD, methods->at(i)); |
1683 if (!method->is_initializer()) { |
1681 if (!method->is_initializer()) { |
1684 if (!publicOnly || method->is_public()) { |
1682 if (!publicOnly || method->is_public()) { |
1685 oop m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL); |
1683 oop m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL); |
1686 result->obj_at_put(out_idx, m); |
1684 result->obj_at_put(out_idx, m); |
1687 ++out_idx; |
1685 ++out_idx; |
1698 JVMWrapper("JVM_GetClassDeclaredConstructors"); |
1696 JVMWrapper("JVM_GetClassDeclaredConstructors"); |
1699 JvmtiVMObjectAllocEventCollector oam; |
1697 JvmtiVMObjectAllocEventCollector oam; |
1700 |
1698 |
1701 // Exclude primitive types and array types |
1699 // Exclude primitive types and array types |
1702 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) |
1700 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) |
1703 || Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass)))->oop_is_javaArray()) { |
1701 || Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)))->oop_is_array()) { |
1704 // Return empty array |
1702 // Return empty array |
1705 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0 , CHECK_NULL); |
1703 oop res = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0 , CHECK_NULL); |
1706 return (jobjectArray) JNIHandles::make_local(env, res); |
1704 return (jobjectArray) JNIHandles::make_local(env, res); |
1707 } |
1705 } |
1708 |
1706 |
1709 instanceKlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass))); |
1707 instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))); |
1710 |
1708 |
1711 // Ensure class is linked |
1709 // Ensure class is linked |
1712 k->link_class(CHECK_NULL); |
1710 k->link_class(CHECK_NULL); |
1713 |
1711 |
1714 objArrayHandle methods (THREAD, k->methods()); |
1712 Array<Method*>* methods = k->methods(); |
1715 int methods_length = methods->length(); |
1713 int methods_length = methods->length(); |
1716 int num_constructors = 0; |
1714 int num_constructors = 0; |
1717 |
1715 |
1718 int i; |
1716 int i; |
1719 for (i = 0; i < methods_length; i++) { |
1717 for (i = 0; i < methods_length; i++) { |
1720 methodHandle method(THREAD, (methodOop) methods->obj_at(i)); |
1718 methodHandle method(THREAD, methods->at(i)); |
1721 if (method->is_initializer() && !method->is_static()) { |
1719 if (method->is_initializer() && !method->is_static()) { |
1722 if (!publicOnly || method->is_public()) { |
1720 if (!publicOnly || method->is_public()) { |
1723 ++num_constructors; |
1721 ++num_constructors; |
1724 } |
1722 } |
1725 } |
1723 } |
1729 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), num_constructors, CHECK_NULL); |
1727 objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), num_constructors, CHECK_NULL); |
1730 objArrayHandle result(THREAD, r); |
1728 objArrayHandle result(THREAD, r); |
1731 |
1729 |
1732 int out_idx = 0; |
1730 int out_idx = 0; |
1733 for (i = 0; i < methods_length; i++) { |
1731 for (i = 0; i < methods_length; i++) { |
1734 methodHandle method(THREAD, (methodOop) methods->obj_at(i)); |
1732 methodHandle method(THREAD, methods->at(i)); |
1735 if (method->is_initializer() && !method->is_static()) { |
1733 if (method->is_initializer() && !method->is_static()) { |
1736 if (!publicOnly || method->is_public()) { |
1734 if (!publicOnly || method->is_public()) { |
1737 oop m = Reflection::new_constructor(method, CHECK_NULL); |
1735 oop m = Reflection::new_constructor(method, CHECK_NULL); |
1738 result->obj_at_put(out_idx, m); |
1736 result->obj_at_put(out_idx, m); |
1739 ++out_idx; |
1737 ++out_idx; |
1751 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1749 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1752 // Primitive type |
1750 // Primitive type |
1753 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
1751 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
1754 } |
1752 } |
1755 |
1753 |
1756 Klass* k = Klass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls))); |
1754 Klass* k = Klass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls))); |
1757 return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; |
1755 return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; |
1758 } |
1756 } |
1759 JVM_END |
1757 JVM_END |
1760 |
1758 |
1761 |
1759 |
1766 JVMWrapper("JVM_GetClassConstantPool"); |
1764 JVMWrapper("JVM_GetClassConstantPool"); |
1767 JvmtiVMObjectAllocEventCollector oam; |
1765 JvmtiVMObjectAllocEventCollector oam; |
1768 |
1766 |
1769 // Return null for primitives and arrays |
1767 // Return null for primitives and arrays |
1770 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1768 if (!java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { |
1771 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
1769 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
1772 if (Klass::cast(k)->oop_is_instance()) { |
1770 if (Klass::cast(k)->oop_is_instance()) { |
1773 instanceKlassHandle k_h(THREAD, k); |
1771 instanceKlassHandle k_h(THREAD, k); |
1774 Handle jcp = sun_reflect_ConstantPool::create(CHECK_NULL); |
1772 Handle jcp = sun_reflect_ConstantPool::create(CHECK_NULL); |
1775 sun_reflect_ConstantPool::set_cp_oop(jcp(), k_h->constants()); |
1773 sun_reflect_ConstantPool::set_cp(jcp(), k_h->constants()); |
1776 return JNIHandles::make_local(jcp()); |
1774 return JNIHandles::make_local(jcp()); |
1777 } |
1775 } |
1778 } |
1776 } |
1779 return NULL; |
1777 return NULL; |
1780 } |
1778 } |
1781 JVM_END |
1779 JVM_END |
1782 |
1780 |
1783 |
1781 |
1784 JVM_ENTRY(jint, JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)) |
1782 JVM_ENTRY(jint, JVM_ConstantPoolGetSize(JNIEnv *env, jobject obj, jobject unused)) |
1785 { |
1783 { |
1786 JVMWrapper("JVM_ConstantPoolGetSize"); |
1784 JVMWrapper("JVM_ConstantPoolGetSize"); |
1787 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1785 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1788 return cp->length(); |
1786 return cp->length(); |
1789 } |
1787 } |
1790 JVM_END |
1788 JVM_END |
1791 |
1789 |
1792 |
1790 |
1795 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds"); |
1793 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool index out of bounds"); |
1796 } |
1794 } |
1797 } |
1795 } |
1798 |
1796 |
1799 |
1797 |
1800 JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1798 JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1801 { |
1799 { |
1802 JVMWrapper("JVM_ConstantPoolGetClassAt"); |
1800 JVMWrapper("JVM_ConstantPoolGetClassAt"); |
1803 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1801 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1804 bounds_check(cp, index, CHECK_NULL); |
1802 bounds_check(cp, index, CHECK_NULL); |
1805 constantTag tag = cp->tag_at(index); |
1803 constantTag tag = cp->tag_at(index); |
1806 if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
1804 if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
1807 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1805 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1808 } |
1806 } |
1809 klassOop k = cp->klass_at(index, CHECK_NULL); |
1807 Klass* k = cp->klass_at(index, CHECK_NULL); |
1810 return (jclass) JNIHandles::make_local(k->java_mirror()); |
1808 return (jclass) JNIHandles::make_local(k->java_mirror()); |
1811 } |
1809 } |
1812 JVM_END |
1810 JVM_END |
1813 |
1811 |
1814 |
1812 |
1815 JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1813 JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1816 { |
1814 { |
1817 JVMWrapper("JVM_ConstantPoolGetClassAtIfLoaded"); |
1815 JVMWrapper("JVM_ConstantPoolGetClassAtIfLoaded"); |
1818 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1816 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1819 bounds_check(cp, index, CHECK_NULL); |
1817 bounds_check(cp, index, CHECK_NULL); |
1820 constantTag tag = cp->tag_at(index); |
1818 constantTag tag = cp->tag_at(index); |
1821 if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
1819 if (!tag.is_klass() && !tag.is_unresolved_klass()) { |
1822 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1820 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1823 } |
1821 } |
1824 klassOop k = constantPoolOopDesc::klass_at_if_loaded(cp, index); |
1822 Klass* k = ConstantPool::klass_at_if_loaded(cp, index); |
1825 if (k == NULL) return NULL; |
1823 if (k == NULL) return NULL; |
1826 return (jclass) JNIHandles::make_local(k->java_mirror()); |
1824 return (jclass) JNIHandles::make_local(k->java_mirror()); |
1827 } |
1825 } |
1828 JVM_END |
1826 JVM_END |
1829 |
1827 |
1831 constantTag tag = cp->tag_at(index); |
1829 constantTag tag = cp->tag_at(index); |
1832 if (!tag.is_method() && !tag.is_interface_method()) { |
1830 if (!tag.is_method() && !tag.is_interface_method()) { |
1833 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1831 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1834 } |
1832 } |
1835 int klass_ref = cp->uncached_klass_ref_index_at(index); |
1833 int klass_ref = cp->uncached_klass_ref_index_at(index); |
1836 klassOop k_o; |
1834 Klass* k_o; |
1837 if (force_resolution) { |
1835 if (force_resolution) { |
1838 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
1836 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
1839 } else { |
1837 } else { |
1840 k_o = constantPoolOopDesc::klass_at_if_loaded(cp, klass_ref); |
1838 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
1841 if (k_o == NULL) return NULL; |
1839 if (k_o == NULL) return NULL; |
1842 } |
1840 } |
1843 instanceKlassHandle k(THREAD, k_o); |
1841 instanceKlassHandle k(THREAD, k_o); |
1844 Symbol* name = cp->uncached_name_ref_at(index); |
1842 Symbol* name = cp->uncached_name_ref_at(index); |
1845 Symbol* sig = cp->uncached_signature_ref_at(index); |
1843 Symbol* sig = cp->uncached_signature_ref_at(index); |
1854 method = Reflection::new_constructor(m, CHECK_NULL); |
1852 method = Reflection::new_constructor(m, CHECK_NULL); |
1855 } |
1853 } |
1856 return JNIHandles::make_local(method); |
1854 return JNIHandles::make_local(method); |
1857 } |
1855 } |
1858 |
1856 |
1859 JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1857 JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1860 { |
1858 { |
1861 JVMWrapper("JVM_ConstantPoolGetMethodAt"); |
1859 JVMWrapper("JVM_ConstantPoolGetMethodAt"); |
1862 JvmtiVMObjectAllocEventCollector oam; |
1860 JvmtiVMObjectAllocEventCollector oam; |
1863 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1861 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1864 bounds_check(cp, index, CHECK_NULL); |
1862 bounds_check(cp, index, CHECK_NULL); |
1865 jobject res = get_method_at_helper(cp, index, true, CHECK_NULL); |
1863 jobject res = get_method_at_helper(cp, index, true, CHECK_NULL); |
1866 return res; |
1864 return res; |
1867 } |
1865 } |
1868 JVM_END |
1866 JVM_END |
1869 |
1867 |
1870 JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1868 JVM_ENTRY(jobject, JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1871 { |
1869 { |
1872 JVMWrapper("JVM_ConstantPoolGetMethodAtIfLoaded"); |
1870 JVMWrapper("JVM_ConstantPoolGetMethodAtIfLoaded"); |
1873 JvmtiVMObjectAllocEventCollector oam; |
1871 JvmtiVMObjectAllocEventCollector oam; |
1874 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1872 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1875 bounds_check(cp, index, CHECK_NULL); |
1873 bounds_check(cp, index, CHECK_NULL); |
1876 jobject res = get_method_at_helper(cp, index, false, CHECK_NULL); |
1874 jobject res = get_method_at_helper(cp, index, false, CHECK_NULL); |
1877 return res; |
1875 return res; |
1878 } |
1876 } |
1879 JVM_END |
1877 JVM_END |
1882 constantTag tag = cp->tag_at(index); |
1880 constantTag tag = cp->tag_at(index); |
1883 if (!tag.is_field()) { |
1881 if (!tag.is_field()) { |
1884 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1882 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1885 } |
1883 } |
1886 int klass_ref = cp->uncached_klass_ref_index_at(index); |
1884 int klass_ref = cp->uncached_klass_ref_index_at(index); |
1887 klassOop k_o; |
1885 Klass* k_o; |
1888 if (force_resolution) { |
1886 if (force_resolution) { |
1889 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
1887 k_o = cp->klass_at(klass_ref, CHECK_NULL); |
1890 } else { |
1888 } else { |
1891 k_o = constantPoolOopDesc::klass_at_if_loaded(cp, klass_ref); |
1889 k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); |
1892 if (k_o == NULL) return NULL; |
1890 if (k_o == NULL) return NULL; |
1893 } |
1891 } |
1894 instanceKlassHandle k(THREAD, k_o); |
1892 instanceKlassHandle k(THREAD, k_o); |
1895 Symbol* name = cp->uncached_name_ref_at(index); |
1893 Symbol* name = cp->uncached_name_ref_at(index); |
1896 Symbol* sig = cp->uncached_signature_ref_at(index); |
1894 Symbol* sig = cp->uncached_signature_ref_at(index); |
1897 fieldDescriptor fd; |
1895 fieldDescriptor fd; |
1898 klassOop target_klass = k->find_field(name, sig, &fd); |
1896 Klass* target_klass = k->find_field(name, sig, &fd); |
1899 if (target_klass == NULL) { |
1897 if (target_klass == NULL) { |
1900 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); |
1898 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); |
1901 } |
1899 } |
1902 oop field = Reflection::new_field(&fd, true, CHECK_NULL); |
1900 oop field = Reflection::new_field(&fd, true, CHECK_NULL); |
1903 return JNIHandles::make_local(field); |
1901 return JNIHandles::make_local(field); |
1904 } |
1902 } |
1905 |
1903 |
1906 JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1904 JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject obj, jobject unusedl, jint index)) |
1907 { |
1905 { |
1908 JVMWrapper("JVM_ConstantPoolGetFieldAt"); |
1906 JVMWrapper("JVM_ConstantPoolGetFieldAt"); |
1909 JvmtiVMObjectAllocEventCollector oam; |
1907 JvmtiVMObjectAllocEventCollector oam; |
1910 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1908 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1911 bounds_check(cp, index, CHECK_NULL); |
1909 bounds_check(cp, index, CHECK_NULL); |
1912 jobject res = get_field_at_helper(cp, index, true, CHECK_NULL); |
1910 jobject res = get_field_at_helper(cp, index, true, CHECK_NULL); |
1913 return res; |
1911 return res; |
1914 } |
1912 } |
1915 JVM_END |
1913 JVM_END |
1916 |
1914 |
1917 JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1915 JVM_ENTRY(jobject, JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1918 { |
1916 { |
1919 JVMWrapper("JVM_ConstantPoolGetFieldAtIfLoaded"); |
1917 JVMWrapper("JVM_ConstantPoolGetFieldAtIfLoaded"); |
1920 JvmtiVMObjectAllocEventCollector oam; |
1918 JvmtiVMObjectAllocEventCollector oam; |
1921 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1919 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1922 bounds_check(cp, index, CHECK_NULL); |
1920 bounds_check(cp, index, CHECK_NULL); |
1923 jobject res = get_field_at_helper(cp, index, false, CHECK_NULL); |
1921 jobject res = get_field_at_helper(cp, index, false, CHECK_NULL); |
1924 return res; |
1922 return res; |
1925 } |
1923 } |
1926 JVM_END |
1924 JVM_END |
1927 |
1925 |
1928 JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1926 JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1929 { |
1927 { |
1930 JVMWrapper("JVM_ConstantPoolGetMemberRefInfoAt"); |
1928 JVMWrapper("JVM_ConstantPoolGetMemberRefInfoAt"); |
1931 JvmtiVMObjectAllocEventCollector oam; |
1929 JvmtiVMObjectAllocEventCollector oam; |
1932 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1930 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1933 bounds_check(cp, index, CHECK_NULL); |
1931 bounds_check(cp, index, CHECK_NULL); |
1934 constantTag tag = cp->tag_at(index); |
1932 constantTag tag = cp->tag_at(index); |
1935 if (!tag.is_field_or_method()) { |
1933 if (!tag.is_field_or_method()) { |
1936 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1934 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1937 } |
1935 } |
1949 dest->obj_at_put(2, str()); |
1947 dest->obj_at_put(2, str()); |
1950 return (jobjectArray) JNIHandles::make_local(dest()); |
1948 return (jobjectArray) JNIHandles::make_local(dest()); |
1951 } |
1949 } |
1952 JVM_END |
1950 JVM_END |
1953 |
1951 |
1954 JVM_ENTRY(jint, JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1952 JVM_ENTRY(jint, JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1955 { |
1953 { |
1956 JVMWrapper("JVM_ConstantPoolGetIntAt"); |
1954 JVMWrapper("JVM_ConstantPoolGetIntAt"); |
1957 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1955 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1958 bounds_check(cp, index, CHECK_0); |
1956 bounds_check(cp, index, CHECK_0); |
1959 constantTag tag = cp->tag_at(index); |
1957 constantTag tag = cp->tag_at(index); |
1960 if (!tag.is_int()) { |
1958 if (!tag.is_int()) { |
1961 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1959 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1962 } |
1960 } |
1963 return cp->int_at(index); |
1961 return cp->int_at(index); |
1964 } |
1962 } |
1965 JVM_END |
1963 JVM_END |
1966 |
1964 |
1967 JVM_ENTRY(jlong, JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1965 JVM_ENTRY(jlong, JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1968 { |
1966 { |
1969 JVMWrapper("JVM_ConstantPoolGetLongAt"); |
1967 JVMWrapper("JVM_ConstantPoolGetLongAt"); |
1970 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1968 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1971 bounds_check(cp, index, CHECK_(0L)); |
1969 bounds_check(cp, index, CHECK_(0L)); |
1972 constantTag tag = cp->tag_at(index); |
1970 constantTag tag = cp->tag_at(index); |
1973 if (!tag.is_long()) { |
1971 if (!tag.is_long()) { |
1974 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1972 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1975 } |
1973 } |
1976 return cp->long_at(index); |
1974 return cp->long_at(index); |
1977 } |
1975 } |
1978 JVM_END |
1976 JVM_END |
1979 |
1977 |
1980 JVM_ENTRY(jfloat, JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1978 JVM_ENTRY(jfloat, JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1981 { |
1979 { |
1982 JVMWrapper("JVM_ConstantPoolGetFloatAt"); |
1980 JVMWrapper("JVM_ConstantPoolGetFloatAt"); |
1983 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1981 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1984 bounds_check(cp, index, CHECK_(0.0f)); |
1982 bounds_check(cp, index, CHECK_(0.0f)); |
1985 constantTag tag = cp->tag_at(index); |
1983 constantTag tag = cp->tag_at(index); |
1986 if (!tag.is_float()) { |
1984 if (!tag.is_float()) { |
1987 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1985 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1988 } |
1986 } |
1989 return cp->float_at(index); |
1987 return cp->float_at(index); |
1990 } |
1988 } |
1991 JVM_END |
1989 JVM_END |
1992 |
1990 |
1993 JVM_ENTRY(jdouble, JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
1991 JVM_ENTRY(jdouble, JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
1994 { |
1992 { |
1995 JVMWrapper("JVM_ConstantPoolGetDoubleAt"); |
1993 JVMWrapper("JVM_ConstantPoolGetDoubleAt"); |
1996 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
1994 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
1997 bounds_check(cp, index, CHECK_(0.0)); |
1995 bounds_check(cp, index, CHECK_(0.0)); |
1998 constantTag tag = cp->tag_at(index); |
1996 constantTag tag = cp->tag_at(index); |
1999 if (!tag.is_double()) { |
1997 if (!tag.is_double()) { |
2000 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1998 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2001 } |
1999 } |
2002 return cp->double_at(index); |
2000 return cp->double_at(index); |
2003 } |
2001 } |
2004 JVM_END |
2002 JVM_END |
2005 |
2003 |
2006 JVM_ENTRY(jstring, JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
2004 JVM_ENTRY(jstring, JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject obj, jobject unused, jint index)) |
2007 { |
2005 { |
2008 JVMWrapper("JVM_ConstantPoolGetStringAt"); |
2006 JVMWrapper("JVM_ConstantPoolGetStringAt"); |
2009 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
2007 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2010 bounds_check(cp, index, CHECK_NULL); |
2008 bounds_check(cp, index, CHECK_NULL); |
2011 constantTag tag = cp->tag_at(index); |
2009 constantTag tag = cp->tag_at(index); |
2012 if (!tag.is_string() && !tag.is_unresolved_string()) { |
2010 if (!tag.is_string()) { |
2013 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2011 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2014 } |
2012 } |
2015 oop str = cp->string_at(index, CHECK_NULL); |
2013 oop str = cp->string_at(index, CHECK_NULL); |
2016 return (jstring) JNIHandles::make_local(str); |
2014 return (jstring) JNIHandles::make_local(str); |
2017 } |
2015 } |
2018 JVM_END |
2016 JVM_END |
2019 |
2017 |
2020 JVM_ENTRY(jstring, JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)) |
2018 JVM_ENTRY(jstring, JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject obj, jobject unused, jint index)) |
2021 { |
2019 { |
2022 JVMWrapper("JVM_ConstantPoolGetUTF8At"); |
2020 JVMWrapper("JVM_ConstantPoolGetUTF8At"); |
2023 JvmtiVMObjectAllocEventCollector oam; |
2021 JvmtiVMObjectAllocEventCollector oam; |
2024 constantPoolHandle cp = constantPoolHandle(THREAD, constantPoolOop(JNIHandles::resolve_non_null(jcpool))); |
2022 constantPoolHandle cp = constantPoolHandle(THREAD, sun_reflect_ConstantPool::get_cp(JNIHandles::resolve_non_null(obj))); |
2025 bounds_check(cp, index, CHECK_NULL); |
2023 bounds_check(cp, index, CHECK_NULL); |
2026 constantTag tag = cp->tag_at(index); |
2024 constantTag tag = cp->tag_at(index); |
2027 if (!tag.is_symbol()) { |
2025 if (!tag.is_symbol()) { |
2028 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2026 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2029 } |
2027 } |
2042 |
2040 |
2043 oop r = JNIHandles::resolve(cls); |
2041 oop r = JNIHandles::resolve(cls); |
2044 assert(! java_lang_Class::is_primitive(r), "primitive classes not allowed"); |
2042 assert(! java_lang_Class::is_primitive(r), "primitive classes not allowed"); |
2045 if (java_lang_Class::is_primitive(r)) return false; |
2043 if (java_lang_Class::is_primitive(r)) return false; |
2046 |
2044 |
2047 klassOop k = java_lang_Class::as_klassOop(r); |
2045 Klass* k = java_lang_Class::as_Klass(r); |
2048 assert(Klass::cast(k)->oop_is_instance(), "must be an instance klass"); |
2046 assert(Klass::cast(k)->oop_is_instance(), "must be an instance klass"); |
2049 if (! Klass::cast(k)->oop_is_instance()) return false; |
2047 if (! Klass::cast(k)->oop_is_instance()) return false; |
2050 |
2048 |
2051 ResourceMark rm(THREAD); |
2049 ResourceMark rm(THREAD); |
2052 const char* name = Klass::cast(k)->name()->as_C_string(); |
2050 const char* name = Klass::cast(k)->name()->as_C_string(); |
2069 |
2067 |
2070 // Reflection for the verifier ///////////////////////////////////////////////////////////////// |
2068 // Reflection for the verifier ///////////////////////////////////////////////////////////////// |
2071 |
2069 |
2072 // RedefineClasses support: bug 6214132 caused verification to fail. |
2070 // RedefineClasses support: bug 6214132 caused verification to fail. |
2073 // All functions from this section should call the jvmtiThreadSate function: |
2071 // All functions from this section should call the jvmtiThreadSate function: |
2074 // klassOop class_to_verify_considering_redefinition(klassOop klass). |
2072 // Klass* class_to_verify_considering_redefinition(Klass* klass). |
2075 // The function returns a klassOop of the _scratch_class if the verifier |
2073 // The function returns a Klass* of the _scratch_class if the verifier |
2076 // was invoked in the middle of the class redefinition. |
2074 // was invoked in the middle of the class redefinition. |
2077 // Otherwise it returns its argument value which is the _the_class klassOop. |
2075 // Otherwise it returns its argument value which is the _the_class Klass*. |
2078 // Please, refer to the description in the jvmtiThreadSate.hpp. |
2076 // Please, refer to the description in the jvmtiThreadSate.hpp. |
2079 |
2077 |
2080 JVM_ENTRY(const char*, JVM_GetClassNameUTF(JNIEnv *env, jclass cls)) |
2078 JVM_ENTRY(const char*, JVM_GetClassNameUTF(JNIEnv *env, jclass cls)) |
2081 JVMWrapper("JVM_GetClassNameUTF"); |
2079 JVMWrapper("JVM_GetClassNameUTF"); |
2082 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2080 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2083 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2081 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2084 return Klass::cast(k)->name()->as_utf8(); |
2082 return Klass::cast(k)->name()->as_utf8(); |
2085 JVM_END |
2083 JVM_END |
2086 |
2084 |
2087 |
2085 |
2088 JVM_QUICK_ENTRY(void, JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)) |
2086 JVM_QUICK_ENTRY(void, JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types)) |
2089 JVMWrapper("JVM_GetClassCPTypes"); |
2087 JVMWrapper("JVM_GetClassCPTypes"); |
2090 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2088 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2091 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2089 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2092 // types will have length zero if this is not an instanceKlass |
2090 // types will have length zero if this is not an InstanceKlass |
2093 // (length is determined by call to JVM_GetClassCPEntriesCount) |
2091 // (length is determined by call to JVM_GetClassCPEntriesCount) |
2094 if (Klass::cast(k)->oop_is_instance()) { |
2092 if (Klass::cast(k)->oop_is_instance()) { |
2095 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2093 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2096 for (int index = cp->length() - 1; index >= 0; index--) { |
2094 for (int index = cp->length() - 1; index >= 0; index--) { |
2097 constantTag tag = cp->tag_at(index); |
2095 constantTag tag = cp->tag_at(index); |
2098 types[index] = (tag.is_unresolved_klass()) ? JVM_CONSTANT_Class : |
2096 types[index] = (tag.is_unresolved_klass()) ? JVM_CONSTANT_Class : tag.value(); |
2099 (tag.is_unresolved_string()) ? JVM_CONSTANT_String : tag.value(); |
|
2100 } |
2097 } |
2101 } |
2098 } |
2102 JVM_END |
2099 JVM_END |
2103 |
2100 |
2104 |
2101 |
2105 JVM_QUICK_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)) |
2102 JVM_QUICK_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)) |
2106 JVMWrapper("JVM_GetClassCPEntriesCount"); |
2103 JVMWrapper("JVM_GetClassCPEntriesCount"); |
2107 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2104 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2108 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2105 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2109 if (!Klass::cast(k)->oop_is_instance()) |
2106 if (!Klass::cast(k)->oop_is_instance()) |
2110 return 0; |
2107 return 0; |
2111 return instanceKlass::cast(k)->constants()->length(); |
2108 return InstanceKlass::cast(k)->constants()->length(); |
2112 JVM_END |
2109 JVM_END |
2113 |
2110 |
2114 |
2111 |
2115 JVM_QUICK_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)) |
2112 JVM_QUICK_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)) |
2116 JVMWrapper("JVM_GetClassFieldsCount"); |
2113 JVMWrapper("JVM_GetClassFieldsCount"); |
2117 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2114 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2118 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2115 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2119 if (!Klass::cast(k)->oop_is_instance()) |
2116 if (!Klass::cast(k)->oop_is_instance()) |
2120 return 0; |
2117 return 0; |
2121 return instanceKlass::cast(k)->java_fields_count(); |
2118 return InstanceKlass::cast(k)->java_fields_count(); |
2122 JVM_END |
2119 JVM_END |
2123 |
2120 |
2124 |
2121 |
2125 JVM_QUICK_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)) |
2122 JVM_QUICK_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)) |
2126 JVMWrapper("JVM_GetClassMethodsCount"); |
2123 JVMWrapper("JVM_GetClassMethodsCount"); |
2127 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2124 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2128 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2125 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2129 if (!Klass::cast(k)->oop_is_instance()) |
2126 if (!Klass::cast(k)->oop_is_instance()) |
2130 return 0; |
2127 return 0; |
2131 return instanceKlass::cast(k)->methods()->length(); |
2128 return InstanceKlass::cast(k)->methods()->length(); |
2132 JVM_END |
2129 JVM_END |
2133 |
2130 |
2134 |
2131 |
2135 // The following methods, used for the verifier, are never called with |
2132 // The following methods, used for the verifier, are never called with |
2136 // array klasses, so a direct cast to instanceKlass is safe. |
2133 // array klasses, so a direct cast to InstanceKlass is safe. |
2137 // Typically, these methods are called in a loop with bounds determined |
2134 // Typically, these methods are called in a loop with bounds determined |
2138 // by the results of JVM_GetClass{Fields,Methods}Count, which return |
2135 // by the results of JVM_GetClass{Fields,Methods}Count, which return |
2139 // zero for arrays. |
2136 // zero for arrays. |
2140 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)) |
2137 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)) |
2141 JVMWrapper("JVM_GetMethodIxExceptionIndexes"); |
2138 JVMWrapper("JVM_GetMethodIxExceptionIndexes"); |
2142 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2139 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2143 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2140 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2144 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2141 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2145 int length = methodOop(method)->checked_exceptions_length(); |
2142 int length = method->checked_exceptions_length(); |
2146 if (length > 0) { |
2143 if (length > 0) { |
2147 CheckedExceptionElement* table= methodOop(method)->checked_exceptions_start(); |
2144 CheckedExceptionElement* table= method->checked_exceptions_start(); |
2148 for (int i = 0; i < length; i++) { |
2145 for (int i = 0; i < length; i++) { |
2149 exceptions[i] = table[i].class_cp_index; |
2146 exceptions[i] = table[i].class_cp_index; |
2150 } |
2147 } |
2151 } |
2148 } |
2152 JVM_END |
2149 JVM_END |
2153 |
2150 |
2154 |
2151 |
2155 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)) |
2152 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)) |
2156 JVMWrapper("JVM_GetMethodIxExceptionsCount"); |
2153 JVMWrapper("JVM_GetMethodIxExceptionsCount"); |
2157 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2154 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2158 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2155 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2159 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2156 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2160 return methodOop(method)->checked_exceptions_length(); |
2157 return method->checked_exceptions_length(); |
2161 JVM_END |
2158 JVM_END |
2162 |
2159 |
2163 |
2160 |
2164 JVM_QUICK_ENTRY(void, JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)) |
2161 JVM_QUICK_ENTRY(void, JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)) |
2165 JVMWrapper("JVM_GetMethodIxByteCode"); |
2162 JVMWrapper("JVM_GetMethodIxByteCode"); |
2166 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2163 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2167 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2164 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2168 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2165 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2169 memcpy(code, methodOop(method)->code_base(), methodOop(method)->code_size()); |
2166 memcpy(code, method->code_base(), method->code_size()); |
2170 JVM_END |
2167 JVM_END |
2171 |
2168 |
2172 |
2169 |
2173 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)) |
2170 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)) |
2174 JVMWrapper("JVM_GetMethodIxByteCodeLength"); |
2171 JVMWrapper("JVM_GetMethodIxByteCodeLength"); |
2175 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2172 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2176 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2173 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2177 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2174 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2178 return methodOop(method)->code_size(); |
2175 return method->code_size(); |
2179 JVM_END |
2176 JVM_END |
2180 |
2177 |
2181 |
2178 |
2182 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)) |
2179 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)) |
2183 JVMWrapper("JVM_GetMethodIxExceptionTableEntry"); |
2180 JVMWrapper("JVM_GetMethodIxExceptionTableEntry"); |
2184 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2181 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2185 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2182 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2186 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2183 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2187 ExceptionTable extable((methodOop(method))); |
2184 ExceptionTable extable(method); |
2188 entry->start_pc = extable.start_pc(entry_index); |
2185 entry->start_pc = extable.start_pc(entry_index); |
2189 entry->end_pc = extable.end_pc(entry_index); |
2186 entry->end_pc = extable.end_pc(entry_index); |
2190 entry->handler_pc = extable.handler_pc(entry_index); |
2187 entry->handler_pc = extable.handler_pc(entry_index); |
2191 entry->catchType = extable.catch_type_index(entry_index); |
2188 entry->catchType = extable.catch_type_index(entry_index); |
2192 JVM_END |
2189 JVM_END |
2193 |
2190 |
2194 |
2191 |
2195 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)) |
2192 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)) |
2196 JVMWrapper("JVM_GetMethodIxExceptionTableLength"); |
2193 JVMWrapper("JVM_GetMethodIxExceptionTableLength"); |
2197 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2194 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2198 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2195 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2199 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2196 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2200 return methodOop(method)->exception_table_length(); |
2197 return method->exception_table_length(); |
2201 JVM_END |
2198 JVM_END |
2202 |
2199 |
2203 |
2200 |
2204 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)) |
2201 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)) |
2205 JVMWrapper("JVM_GetMethodIxModifiers"); |
2202 JVMWrapper("JVM_GetMethodIxModifiers"); |
2206 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2203 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2207 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2204 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2208 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2205 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2209 return methodOop(method)->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
2206 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
2210 JVM_END |
2207 JVM_END |
2211 |
2208 |
2212 |
2209 |
2213 JVM_QUICK_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)) |
2210 JVM_QUICK_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)) |
2214 JVMWrapper("JVM_GetFieldIxModifiers"); |
2211 JVMWrapper("JVM_GetFieldIxModifiers"); |
2215 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2212 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2216 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2213 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2217 return instanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS; |
2214 return InstanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS; |
2218 JVM_END |
2215 JVM_END |
2219 |
2216 |
2220 |
2217 |
2221 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)) |
2218 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)) |
2222 JVMWrapper("JVM_GetMethodIxLocalsCount"); |
2219 JVMWrapper("JVM_GetMethodIxLocalsCount"); |
2223 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2220 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2224 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2221 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2225 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2222 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2226 return methodOop(method)->max_locals(); |
2223 return method->max_locals(); |
2227 JVM_END |
2224 JVM_END |
2228 |
2225 |
2229 |
2226 |
2230 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)) |
2227 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)) |
2231 JVMWrapper("JVM_GetMethodIxArgsSize"); |
2228 JVMWrapper("JVM_GetMethodIxArgsSize"); |
2232 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2229 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2233 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2230 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2234 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2231 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2235 return methodOop(method)->size_of_parameters(); |
2232 return method->size_of_parameters(); |
2236 JVM_END |
2233 JVM_END |
2237 |
2234 |
2238 |
2235 |
2239 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)) |
2236 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)) |
2240 JVMWrapper("JVM_GetMethodIxMaxStack"); |
2237 JVMWrapper("JVM_GetMethodIxMaxStack"); |
2241 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2238 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2242 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2239 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2243 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2240 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2244 return methodOop(method)->verifier_max_stack(); |
2241 return method->verifier_max_stack(); |
2245 JVM_END |
2242 JVM_END |
2246 |
2243 |
2247 |
2244 |
2248 JVM_QUICK_ENTRY(jboolean, JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)) |
2245 JVM_QUICK_ENTRY(jboolean, JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)) |
2249 JVMWrapper("JVM_IsConstructorIx"); |
2246 JVMWrapper("JVM_IsConstructorIx"); |
2250 ResourceMark rm(THREAD); |
2247 ResourceMark rm(THREAD); |
2251 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2248 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2252 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2249 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2253 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2250 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2254 return methodOop(method)->name() == vmSymbols::object_initializer_name(); |
2251 return method->name() == vmSymbols::object_initializer_name(); |
2255 JVM_END |
2252 JVM_END |
2256 |
2253 |
2257 |
2254 |
2258 JVM_ENTRY(const char*, JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)) |
2255 JVM_ENTRY(const char*, JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index)) |
2259 JVMWrapper("JVM_GetMethodIxIxUTF"); |
2256 JVMWrapper("JVM_GetMethodIxIxUTF"); |
2260 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2257 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2261 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2258 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2262 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2259 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2263 return methodOop(method)->name()->as_utf8(); |
2260 return method->name()->as_utf8(); |
2264 JVM_END |
2261 JVM_END |
2265 |
2262 |
2266 |
2263 |
2267 JVM_ENTRY(const char*, JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)) |
2264 JVM_ENTRY(const char*, JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index)) |
2268 JVMWrapper("JVM_GetMethodIxSignatureUTF"); |
2265 JVMWrapper("JVM_GetMethodIxSignatureUTF"); |
2269 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2266 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2270 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2267 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2271 oop method = instanceKlass::cast(k)->methods()->obj_at(method_index); |
2268 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2272 return methodOop(method)->signature()->as_utf8(); |
2269 return method->signature()->as_utf8(); |
2273 JVM_END |
2270 JVM_END |
2274 |
2271 |
2275 /** |
2272 /** |
2276 * All of these JVM_GetCP-xxx methods are used by the old verifier to |
2273 * All of these JVM_GetCP-xxx methods are used by the old verifier to |
2277 * read entries in the constant pool. Since the old verifier always |
2274 * read entries in the constant pool. Since the old verifier always |
2280 * that nothing it calls tries to use the cpCache instead of the raw |
2277 * that nothing it calls tries to use the cpCache instead of the raw |
2281 * constant pool, so we must use cp->uncached_x methods when appropriate. |
2278 * constant pool, so we must use cp->uncached_x methods when appropriate. |
2282 */ |
2279 */ |
2283 JVM_ENTRY(const char*, JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2280 JVM_ENTRY(const char*, JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2284 JVMWrapper("JVM_GetCPFieldNameUTF"); |
2281 JVMWrapper("JVM_GetCPFieldNameUTF"); |
2285 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2282 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2286 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2283 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2287 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2284 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2288 switch (cp->tag_at(cp_index).value()) { |
2285 switch (cp->tag_at(cp_index).value()) { |
2289 case JVM_CONSTANT_Fieldref: |
2286 case JVM_CONSTANT_Fieldref: |
2290 return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2287 return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2291 default: |
2288 default: |
2292 fatal("JVM_GetCPFieldNameUTF: illegal constant"); |
2289 fatal("JVM_GetCPFieldNameUTF: illegal constant"); |
2296 JVM_END |
2293 JVM_END |
2297 |
2294 |
2298 |
2295 |
2299 JVM_ENTRY(const char*, JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2296 JVM_ENTRY(const char*, JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2300 JVMWrapper("JVM_GetCPMethodNameUTF"); |
2297 JVMWrapper("JVM_GetCPMethodNameUTF"); |
2301 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2298 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2302 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2299 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2303 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2300 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2304 switch (cp->tag_at(cp_index).value()) { |
2301 switch (cp->tag_at(cp_index).value()) { |
2305 case JVM_CONSTANT_InterfaceMethodref: |
2302 case JVM_CONSTANT_InterfaceMethodref: |
2306 case JVM_CONSTANT_Methodref: |
2303 case JVM_CONSTANT_Methodref: |
2307 case JVM_CONSTANT_NameAndType: // for invokedynamic |
2304 case JVM_CONSTANT_NameAndType: // for invokedynamic |
2308 return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2305 return cp->uncached_name_ref_at(cp_index)->as_utf8(); |
2314 JVM_END |
2311 JVM_END |
2315 |
2312 |
2316 |
2313 |
2317 JVM_ENTRY(const char*, JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2314 JVM_ENTRY(const char*, JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2318 JVMWrapper("JVM_GetCPMethodSignatureUTF"); |
2315 JVMWrapper("JVM_GetCPMethodSignatureUTF"); |
2319 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2316 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2320 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2317 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2321 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2318 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2322 switch (cp->tag_at(cp_index).value()) { |
2319 switch (cp->tag_at(cp_index).value()) { |
2323 case JVM_CONSTANT_InterfaceMethodref: |
2320 case JVM_CONSTANT_InterfaceMethodref: |
2324 case JVM_CONSTANT_Methodref: |
2321 case JVM_CONSTANT_Methodref: |
2325 case JVM_CONSTANT_NameAndType: // for invokedynamic |
2322 case JVM_CONSTANT_NameAndType: // for invokedynamic |
2326 return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2323 return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2332 JVM_END |
2329 JVM_END |
2333 |
2330 |
2334 |
2331 |
2335 JVM_ENTRY(const char*, JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2332 JVM_ENTRY(const char*, JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2336 JVMWrapper("JVM_GetCPFieldSignatureUTF"); |
2333 JVMWrapper("JVM_GetCPFieldSignatureUTF"); |
2337 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2334 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2338 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2335 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2339 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2336 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2340 switch (cp->tag_at(cp_index).value()) { |
2337 switch (cp->tag_at(cp_index).value()) { |
2341 case JVM_CONSTANT_Fieldref: |
2338 case JVM_CONSTANT_Fieldref: |
2342 return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2339 return cp->uncached_signature_ref_at(cp_index)->as_utf8(); |
2343 default: |
2340 default: |
2344 fatal("JVM_GetCPFieldSignatureUTF: illegal constant"); |
2341 fatal("JVM_GetCPFieldSignatureUTF: illegal constant"); |
2348 JVM_END |
2345 JVM_END |
2349 |
2346 |
2350 |
2347 |
2351 JVM_ENTRY(const char*, JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2348 JVM_ENTRY(const char*, JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2352 JVMWrapper("JVM_GetCPClassNameUTF"); |
2349 JVMWrapper("JVM_GetCPClassNameUTF"); |
2353 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2350 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2354 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2351 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2355 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2352 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2356 Symbol* classname = cp->klass_name_at(cp_index); |
2353 Symbol* classname = cp->klass_name_at(cp_index); |
2357 return classname->as_utf8(); |
2354 return classname->as_utf8(); |
2358 JVM_END |
2355 JVM_END |
2359 |
2356 |
2360 |
2357 |
2361 JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2358 JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2362 JVMWrapper("JVM_GetCPFieldClassNameUTF"); |
2359 JVMWrapper("JVM_GetCPFieldClassNameUTF"); |
2363 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2360 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2364 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2361 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2365 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2362 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2366 switch (cp->tag_at(cp_index).value()) { |
2363 switch (cp->tag_at(cp_index).value()) { |
2367 case JVM_CONSTANT_Fieldref: { |
2364 case JVM_CONSTANT_Fieldref: { |
2368 int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2365 int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2369 Symbol* classname = cp->klass_name_at(class_index); |
2366 Symbol* classname = cp->klass_name_at(class_index); |
2370 return classname->as_utf8(); |
2367 return classname->as_utf8(); |
2377 JVM_END |
2374 JVM_END |
2378 |
2375 |
2379 |
2376 |
2380 JVM_ENTRY(const char*, JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2377 JVM_ENTRY(const char*, JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2381 JVMWrapper("JVM_GetCPMethodClassNameUTF"); |
2378 JVMWrapper("JVM_GetCPMethodClassNameUTF"); |
2382 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2379 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2383 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2380 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2384 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2381 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2385 switch (cp->tag_at(cp_index).value()) { |
2382 switch (cp->tag_at(cp_index).value()) { |
2386 case JVM_CONSTANT_Methodref: |
2383 case JVM_CONSTANT_Methodref: |
2387 case JVM_CONSTANT_InterfaceMethodref: { |
2384 case JVM_CONSTANT_InterfaceMethodref: { |
2388 int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2385 int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2389 Symbol* classname = cp->klass_name_at(class_index); |
2386 Symbol* classname = cp->klass_name_at(class_index); |
2397 JVM_END |
2394 JVM_END |
2398 |
2395 |
2399 |
2396 |
2400 JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)) |
2397 JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)) |
2401 JVMWrapper("JVM_GetCPFieldModifiers"); |
2398 JVMWrapper("JVM_GetCPFieldModifiers"); |
2402 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2399 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2403 klassOop k_called = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(called_cls)); |
2400 Klass* k_called = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(called_cls)); |
2404 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2401 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2405 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2402 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2406 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2403 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2407 constantPoolOop cp_called = instanceKlass::cast(k_called)->constants(); |
2404 ConstantPool* cp_called = InstanceKlass::cast(k_called)->constants(); |
2408 switch (cp->tag_at(cp_index).value()) { |
2405 switch (cp->tag_at(cp_index).value()) { |
2409 case JVM_CONSTANT_Fieldref: { |
2406 case JVM_CONSTANT_Fieldref: { |
2410 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2407 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2411 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2408 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2412 for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) { |
2409 for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) { |
2424 JVM_END |
2421 JVM_END |
2425 |
2422 |
2426 |
2423 |
2427 JVM_QUICK_ENTRY(jint, JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)) |
2424 JVM_QUICK_ENTRY(jint, JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls)) |
2428 JVMWrapper("JVM_GetCPMethodModifiers"); |
2425 JVMWrapper("JVM_GetCPMethodModifiers"); |
2429 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2426 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2430 klassOop k_called = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(called_cls)); |
2427 Klass* k_called = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(called_cls)); |
2431 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2428 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2432 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2429 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2433 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2430 ConstantPool* cp = InstanceKlass::cast(k)->constants(); |
2434 switch (cp->tag_at(cp_index).value()) { |
2431 switch (cp->tag_at(cp_index).value()) { |
2435 case JVM_CONSTANT_Methodref: |
2432 case JVM_CONSTANT_Methodref: |
2436 case JVM_CONSTANT_InterfaceMethodref: { |
2433 case JVM_CONSTANT_InterfaceMethodref: { |
2437 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2434 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2438 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2435 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2439 objArrayOop methods = instanceKlass::cast(k_called)->methods(); |
2436 Array<Method*>* methods = InstanceKlass::cast(k_called)->methods(); |
2440 int methods_count = methods->length(); |
2437 int methods_count = methods->length(); |
2441 for (int i = 0; i < methods_count; i++) { |
2438 for (int i = 0; i < methods_count; i++) { |
2442 methodOop method = methodOop(methods->obj_at(i)); |
2439 Method* method = methods->at(i); |
2443 if (method->name() == name && method->signature() == signature) { |
2440 if (method->name() == name && method->signature() == signature) { |
2444 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
2441 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
2445 } |
2442 } |
2446 } |
2443 } |
2447 return -1; |
2444 return -1; |
2463 |
2460 |
2464 JVM_ENTRY(jboolean, JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)) |
2461 JVM_ENTRY(jboolean, JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2)) |
2465 JVMWrapper("JVM_IsSameClassPackage"); |
2462 JVMWrapper("JVM_IsSameClassPackage"); |
2466 oop class1_mirror = JNIHandles::resolve_non_null(class1); |
2463 oop class1_mirror = JNIHandles::resolve_non_null(class1); |
2467 oop class2_mirror = JNIHandles::resolve_non_null(class2); |
2464 oop class2_mirror = JNIHandles::resolve_non_null(class2); |
2468 klassOop klass1 = java_lang_Class::as_klassOop(class1_mirror); |
2465 Klass* klass1 = java_lang_Class::as_Klass(class1_mirror); |
2469 klassOop klass2 = java_lang_Class::as_klassOop(class2_mirror); |
2466 Klass* klass2 = java_lang_Class::as_Klass(class2_mirror); |
2470 return (jboolean) Reflection::is_same_class_package(klass1, klass2); |
2467 return (jboolean) Reflection::is_same_class_package(klass1, klass2); |
2471 JVM_END |
2468 JVM_END |
2472 |
2469 |
2473 |
2470 |
2474 // IO functions //////////////////////////////////////////////////////////////////////////////////////// |
2471 // IO functions //////////////////////////////////////////////////////////////////////////////////////// |
3047 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3044 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3048 // if a method in a class in a trusted loader is in a doPrivileged, return NULL |
3045 // if a method in a class in a trusted loader is in a doPrivileged, return NULL |
3049 bool trusted = is_trusted_frame(thread, &vfst); |
3046 bool trusted = is_trusted_frame(thread, &vfst); |
3050 if (trusted) return NULL; |
3047 if (trusted) return NULL; |
3051 |
3048 |
3052 methodOop m = vfst.method(); |
3049 Method* m = vfst.method(); |
3053 if (!m->is_native()) { |
3050 if (!m->is_native()) { |
3054 klassOop holder = m->method_holder(); |
3051 Klass* holder = m->method_holder(); |
3055 oop loader = instanceKlass::cast(holder)->class_loader(); |
3052 oop loader = InstanceKlass::cast(holder)->class_loader(); |
3056 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3053 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3057 return (jclass) JNIHandles::make_local(env, Klass::cast(holder)->java_mirror()); |
3054 return (jclass) JNIHandles::make_local(env, Klass::cast(holder)->java_mirror()); |
3058 } |
3055 } |
3059 } |
3056 } |
3060 } |
3057 } |
3070 |
3067 |
3071 // if a method in a class in a trusted loader is in a doPrivileged, return NULL |
3068 // if a method in a class in a trusted loader is in a doPrivileged, return NULL |
3072 bool trusted = is_trusted_frame(thread, &vfst); |
3069 bool trusted = is_trusted_frame(thread, &vfst); |
3073 if (trusted) return NULL; |
3070 if (trusted) return NULL; |
3074 |
3071 |
3075 methodOop m = vfst.method(); |
3072 Method* m = vfst.method(); |
3076 if (!m->is_native()) { |
3073 if (!m->is_native()) { |
3077 klassOop holder = m->method_holder(); |
3074 Klass* holder = m->method_holder(); |
3078 assert(holder->is_klass(), "just checking"); |
3075 assert(holder->is_klass(), "just checking"); |
3079 oop loader = instanceKlass::cast(holder)->class_loader(); |
3076 oop loader = InstanceKlass::cast(holder)->class_loader(); |
3080 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3077 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3081 return JNIHandles::make_local(env, loader); |
3078 return JNIHandles::make_local(env, loader); |
3082 } |
3079 } |
3083 } |
3080 } |
3084 } |
3081 } |
3106 int depth = 0; |
3103 int depth = 0; |
3107 |
3104 |
3108 for(vframeStream vfst(thread); !vfst.at_end(); vfst.security_get_caller_frame(1)) { |
3105 for(vframeStream vfst(thread); !vfst.at_end(); vfst.security_get_caller_frame(1)) { |
3109 // Native frames are not returned |
3106 // Native frames are not returned |
3110 if (!vfst.method()->is_native()) { |
3107 if (!vfst.method()->is_native()) { |
3111 klassOop holder = vfst.method()->method_holder(); |
3108 Klass* holder = vfst.method()->method_holder(); |
3112 assert(holder->is_klass(), "just checking"); |
3109 assert(holder->is_klass(), "just checking"); |
3113 depth++; |
3110 depth++; |
3114 KlassLink* l = new KlassLink(KlassHandle(thread, holder)); |
3111 KlassLink* l = new KlassLink(KlassHandle(thread, holder)); |
3115 if (first == NULL) { |
3112 if (first == NULL) { |
3116 first = last = l; |
3113 first = last = l; |
3149 |
3146 |
3150 int depth = 0; |
3147 int depth = 0; |
3151 |
3148 |
3152 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3149 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3153 if (!vfst.method()->is_native()) { |
3150 if (!vfst.method()->is_native()) { |
3154 klassOop holder = vfst.method()->method_holder(); |
3151 Klass* holder = vfst.method()->method_holder(); |
3155 assert(holder->is_klass(), "just checking"); |
3152 assert(holder->is_klass(), "just checking"); |
3156 if (instanceKlass::cast(holder)->name() == class_name_sym) { |
3153 if (InstanceKlass::cast(holder)->name() == class_name_sym) { |
3157 return depth; |
3154 return depth; |
3158 } |
3155 } |
3159 depth++; |
3156 depth++; |
3160 } |
3157 } |
3161 } |
3158 } |
3170 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3167 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3171 // if a method in a class in a trusted loader is in a doPrivileged, return -1 |
3168 // if a method in a class in a trusted loader is in a doPrivileged, return -1 |
3172 bool trusted = is_trusted_frame(thread, &vfst); |
3169 bool trusted = is_trusted_frame(thread, &vfst); |
3173 if (trusted) return -1; |
3170 if (trusted) return -1; |
3174 |
3171 |
3175 methodOop m = vfst.method(); |
3172 Method* m = vfst.method(); |
3176 if (!m->is_native()) { |
3173 if (!m->is_native()) { |
3177 klassOop holder = m->method_holder(); |
3174 Klass* holder = m->method_holder(); |
3178 assert(holder->is_klass(), "just checking"); |
3175 assert(holder->is_klass(), "just checking"); |
3179 oop loader = instanceKlass::cast(holder)->class_loader(); |
3176 oop loader = InstanceKlass::cast(holder)->class_loader(); |
3180 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3177 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3181 return depth; |
3178 return depth; |
3182 } |
3179 } |
3183 depth++; |
3180 depth++; |
3184 } |
3181 } |
3208 JVM_END |
3205 JVM_END |
3209 |
3206 |
3210 |
3207 |
3211 // ObjectInputStream /////////////////////////////////////////////////////////////// |
3208 // ObjectInputStream /////////////////////////////////////////////////////////////// |
3212 |
3209 |
3213 bool force_verify_field_access(klassOop current_class, klassOop field_class, AccessFlags access, bool classloader_only) { |
3210 bool force_verify_field_access(Klass* current_class, Klass* field_class, AccessFlags access, bool classloader_only) { |
3214 if (current_class == NULL) { |
3211 if (current_class == NULL) { |
3215 return true; |
3212 return true; |
3216 } |
3213 } |
3217 if ((current_class == field_class) || access.is_public()) { |
3214 if ((current_class == field_class) || access.is_public()) { |
3218 return true; |
3215 return true; |
3223 if (Klass::cast(current_class)->is_subclass_of(field_class)) { |
3220 if (Klass::cast(current_class)->is_subclass_of(field_class)) { |
3224 return true; |
3221 return true; |
3225 } |
3222 } |
3226 } |
3223 } |
3227 |
3224 |
3228 return (!access.is_private() && instanceKlass::cast(current_class)->is_same_class_package(field_class)); |
3225 return (!access.is_private() && InstanceKlass::cast(current_class)->is_same_class_package(field_class)); |
3229 } |
3226 } |
3230 |
3227 |
3231 |
3228 |
3232 // JVM_AllocateNewObject and JVM_AllocateNewArray are unused as of 1.4 |
3229 // JVM_AllocateNewObject and JVM_AllocateNewArray are unused as of 1.4 |
3233 JVM_ENTRY(jobject, JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)) |
3230 JVM_ENTRY(jobject, JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass)) |
3242 ResourceMark rm(THREAD); |
3239 ResourceMark rm(THREAD); |
3243 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3240 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3244 } |
3241 } |
3245 |
3242 |
3246 // Arrays not allowed here, must use JVM_AllocateNewArray |
3243 // Arrays not allowed here, must use JVM_AllocateNewArray |
3247 if (Klass::cast(java_lang_Class::as_klassOop(curr_mirror))->oop_is_javaArray() || |
3244 if (Klass::cast(java_lang_Class::as_Klass(curr_mirror))->oop_is_array() || |
3248 Klass::cast(java_lang_Class::as_klassOop(init_mirror))->oop_is_javaArray()) { |
3245 Klass::cast(java_lang_Class::as_Klass(init_mirror))->oop_is_array()) { |
3249 ResourceMark rm(THREAD); |
3246 ResourceMark rm(THREAD); |
3250 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3247 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3251 } |
3248 } |
3252 |
3249 |
3253 instanceKlassHandle curr_klass (THREAD, java_lang_Class::as_klassOop(curr_mirror)); |
3250 instanceKlassHandle curr_klass (THREAD, java_lang_Class::as_Klass(curr_mirror)); |
3254 instanceKlassHandle init_klass (THREAD, java_lang_Class::as_klassOop(init_mirror)); |
3251 instanceKlassHandle init_klass (THREAD, java_lang_Class::as_Klass(init_mirror)); |
3255 |
3252 |
3256 assert(curr_klass->is_subclass_of(init_klass()), "just checking"); |
3253 assert(curr_klass->is_subclass_of(init_klass()), "just checking"); |
3257 |
3254 |
3258 // Interfaces, abstract classes, and java.lang.Class classes cannot be instantiated directly. |
3255 // Interfaces, abstract classes, and java.lang.Class classes cannot be instantiated directly. |
3259 curr_klass->check_valid_for_instantiation(false, CHECK_NULL); |
3256 curr_klass->check_valid_for_instantiation(false, CHECK_NULL); |
3265 init_klass->find_method(vmSymbols::object_initializer_name(), |
3262 init_klass->find_method(vmSymbols::object_initializer_name(), |
3266 vmSymbols::void_method_signature())); |
3263 vmSymbols::void_method_signature())); |
3267 if (m.is_null()) { |
3264 if (m.is_null()) { |
3268 ResourceMark rm(THREAD); |
3265 ResourceMark rm(THREAD); |
3269 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), |
3266 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), |
3270 methodOopDesc::name_and_sig_as_C_string(Klass::cast(init_klass()), |
3267 Method::name_and_sig_as_C_string(Klass::cast(init_klass()), |
3271 vmSymbols::object_initializer_name(), |
3268 vmSymbols::object_initializer_name(), |
3272 vmSymbols::void_method_signature())); |
3269 vmSymbols::void_method_signature())); |
3273 } |
3270 } |
3274 |
3271 |
3275 if (curr_klass == init_klass && !m->is_public()) { |
3272 if (curr_klass == init_klass && !m->is_public()) { |
3298 oop mirror = JNIHandles::resolve_non_null(currClass); |
3295 oop mirror = JNIHandles::resolve_non_null(currClass); |
3299 |
3296 |
3300 if (java_lang_Class::is_primitive(mirror)) { |
3297 if (java_lang_Class::is_primitive(mirror)) { |
3301 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3298 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3302 } |
3299 } |
3303 klassOop k = java_lang_Class::as_klassOop(mirror); |
3300 Klass* k = java_lang_Class::as_Klass(mirror); |
3304 oop result; |
3301 oop result; |
3305 |
3302 |
3306 if (k->klass_part()->oop_is_typeArray()) { |
3303 if (k->oop_is_typeArray()) { |
3307 // typeArray |
3304 // typeArray |
3308 result = typeArrayKlass::cast(k)->allocate(length, CHECK_NULL); |
3305 result = typeArrayKlass::cast(k)->allocate(length, CHECK_NULL); |
3309 } else if (k->klass_part()->oop_is_objArray()) { |
3306 } else if (k->oop_is_objArray()) { |
3310 // objArray |
3307 // objArray |
3311 objArrayKlassHandle oak(THREAD, k); |
3308 objArrayKlass* oak = objArrayKlass::cast(k); |
3312 oak->initialize(CHECK_NULL); // make sure class is initialized (matches Classic VM behavior) |
3309 oak->initialize(CHECK_NULL); // make sure class is initialized (matches Classic VM behavior) |
3313 result = oak->allocate(length, CHECK_NULL); |
3310 result = oak->allocate(length, CHECK_NULL); |
3314 } else { |
3311 } else { |
3315 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3312 THROW_0(vmSymbols::java_lang_InvalidClassException()); |
3316 } |
3313 } |
3323 |
3320 |
3324 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) |
3321 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) |
3325 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3322 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3326 // UseNewReflection |
3323 // UseNewReflection |
3327 vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection |
3324 vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection |
3328 klassOop holder = vfst.method()->method_holder(); |
3325 Klass* holder = vfst.method()->method_holder(); |
3329 oop loader = instanceKlass::cast(holder)->class_loader(); |
3326 oop loader = InstanceKlass::cast(holder)->class_loader(); |
3330 if (loader != NULL) { |
3327 if (loader != NULL) { |
3331 return JNIHandles::make_local(env, loader); |
3328 return JNIHandles::make_local(env, loader); |
3332 } |
3329 } |
3333 } |
3330 } |
3334 return NULL; |
3331 return NULL; |
3366 if (curr_klass.is_null()) { |
3363 if (curr_klass.is_null()) { |
3367 for (vframeStream vfst(thread); |
3364 for (vframeStream vfst(thread); |
3368 !vfst.at_end() && loader == NULL; |
3365 !vfst.at_end() && loader == NULL; |
3369 vfst.next()) { |
3366 vfst.next()) { |
3370 if (!vfst.method()->is_native()) { |
3367 if (!vfst.method()->is_native()) { |
3371 klassOop holder = vfst.method()->method_holder(); |
3368 Klass* holder = vfst.method()->method_holder(); |
3372 loader = instanceKlass::cast(holder)->class_loader(); |
3369 loader = InstanceKlass::cast(holder)->class_loader(); |
3373 protection_domain = instanceKlass::cast(holder)->protection_domain(); |
3370 protection_domain = InstanceKlass::cast(holder)->protection_domain(); |
3374 } |
3371 } |
3375 } |
3372 } |
3376 } else { |
3373 } else { |
3377 klassOop curr_klass_oop = java_lang_Class::as_klassOop(curr_klass()); |
3374 Klass* curr_klass_oop = java_lang_Class::as_Klass(curr_klass()); |
3378 loader = instanceKlass::cast(curr_klass_oop)->class_loader(); |
3375 loader = InstanceKlass::cast(curr_klass_oop)->class_loader(); |
3379 protection_domain = instanceKlass::cast(curr_klass_oop)->protection_domain(); |
3376 protection_domain = InstanceKlass::cast(curr_klass_oop)->protection_domain(); |
3380 } |
3377 } |
3381 Handle h_loader(THREAD, loader); |
3378 Handle h_loader(THREAD, loader); |
3382 Handle h_prot (THREAD, protection_domain); |
3379 Handle h_prot (THREAD, protection_domain); |
3383 jclass result = find_class_from_class_loader(env, name, true, h_loader, h_prot, |
3380 jclass result = find_class_from_class_loader(env, name, true, h_loader, h_prot, |
3384 false, thread); |
3381 false, thread); |
3385 if (TraceClassResolution && result != NULL) { |
3382 if (TraceClassResolution && result != NULL) { |
3386 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); |
3383 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
3387 } |
3384 } |
3388 return result; |
3385 return result; |
3389 JVM_END |
3386 JVM_END |
3390 |
3387 |
3391 |
3388 |
3396 static inline arrayOop check_array(JNIEnv *env, jobject arr, bool type_array_only, TRAPS) { |
3393 static inline arrayOop check_array(JNIEnv *env, jobject arr, bool type_array_only, TRAPS) { |
3397 if (arr == NULL) { |
3394 if (arr == NULL) { |
3398 THROW_0(vmSymbols::java_lang_NullPointerException()); |
3395 THROW_0(vmSymbols::java_lang_NullPointerException()); |
3399 } |
3396 } |
3400 oop a = JNIHandles::resolve_non_null(arr); |
3397 oop a = JNIHandles::resolve_non_null(arr); |
3401 if (!a->is_javaArray() || (type_array_only && !a->is_typeArray())) { |
3398 if (!a->is_array() || (type_array_only && !a->is_typeArray())) { |
3402 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array"); |
3399 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Argument is not an array"); |
3403 } |
3400 } |
3404 return arrayOop(a); |
3401 return arrayOop(a); |
3405 } |
3402 } |
3406 |
3403 |
4017 |
4014 |
4018 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { |
4015 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { |
4019 // Security Note: |
4016 // Security Note: |
4020 // The Java level wrapper will perform the necessary security check allowing |
4017 // The Java level wrapper will perform the necessary security check allowing |
4021 // us to pass the NULL as the initiating class loader. |
4018 // us to pass the NULL as the initiating class loader. |
4022 klassOop klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
4019 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
4023 |
4020 |
4024 KlassHandle klass_handle(THREAD, klass); |
4021 KlassHandle klass_handle(THREAD, klass); |
4025 // Check if we should initialize the class |
4022 // Check if we should initialize the class |
4026 if (init && klass_handle->oop_is_instance()) { |
4023 if (init && klass_handle->oop_is_instance()) { |
4027 klass_handle->initialize(CHECK_NULL); |
4024 klass_handle->initialize(CHECK_NULL); |
4194 if (num_threads == 0) { |
4191 if (num_threads == 0) { |
4195 THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); |
4192 THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); |
4196 } |
4193 } |
4197 |
4194 |
4198 // check if threads is not an array of objects of Thread class |
4195 // check if threads is not an array of objects of Thread class |
4199 klassOop k = objArrayKlass::cast(ah->klass())->element_klass(); |
4196 Klass* k = objArrayKlass::cast(ah->klass())->element_klass(); |
4200 if (k != SystemDictionary::Thread_klass()) { |
4197 if (k != SystemDictionary::Thread_klass()) { |
4201 THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); |
4198 THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); |
4202 } |
4199 } |
4203 |
4200 |
4204 ResourceMark rm(THREAD); |
4201 ResourceMark rm(THREAD); |
4246 Handle mirror(THREAD, JNIHandles::resolve_non_null(ofClass)); |
4243 Handle mirror(THREAD, JNIHandles::resolve_non_null(ofClass)); |
4247 // Special handling for primitive objects |
4244 // Special handling for primitive objects |
4248 if (java_lang_Class::is_primitive(mirror())) { |
4245 if (java_lang_Class::is_primitive(mirror())) { |
4249 return NULL; |
4246 return NULL; |
4250 } |
4247 } |
4251 klassOop k = java_lang_Class::as_klassOop(mirror()); |
4248 Klass* k = java_lang_Class::as_Klass(mirror()); |
4252 if (!Klass::cast(k)->oop_is_instance()) { |
4249 if (!Klass::cast(k)->oop_is_instance()) { |
4253 return NULL; |
4250 return NULL; |
4254 } |
4251 } |
4255 instanceKlassHandle ik_h(THREAD, k); |
4252 instanceKlassHandle ik_h(THREAD, k); |
4256 int encl_method_class_idx = ik_h->enclosing_method_class_index(); |
4253 int encl_method_class_idx = ik_h->enclosing_method_class_index(); |
4257 if (encl_method_class_idx == 0) { |
4254 if (encl_method_class_idx == 0) { |
4258 return NULL; |
4255 return NULL; |
4259 } |
4256 } |
4260 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); |
4257 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); |
4261 objArrayHandle dest(THREAD, dest_o); |
4258 objArrayHandle dest(THREAD, dest_o); |
4262 klassOop enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); |
4259 Klass* enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); |
4263 dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror()); |
4260 dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror()); |
4264 int encl_method_method_idx = ik_h->enclosing_method_method_index(); |
4261 int encl_method_method_idx = ik_h->enclosing_method_method_index(); |
4265 if (encl_method_method_idx != 0) { |
4262 if (encl_method_method_idx != 0) { |
4266 Symbol* sym = ik_h->constants()->symbol_at( |
4263 Symbol* sym = ik_h->constants()->symbol_at( |
4267 extract_low_short_from_int( |
4264 extract_low_short_from_int( |