hotspot/src/share/vm/runtime/reflection.cpp
changeset 33593 60764a78fa5c
parent 31615 e48d94b97b6c
child 33602 16053580a684
equal deleted inserted replaced
33579:01ade4446d96 33593:60764a78fa5c
   610       return k->java_mirror();
   610       return k->java_mirror();
   611   };
   611   };
   612 }
   612 }
   613 
   613 
   614 
   614 
   615 objArrayHandle Reflection::get_parameter_types(methodHandle method, int parameter_count, oop* return_type, TRAPS) {
   615 objArrayHandle Reflection::get_parameter_types(const methodHandle& method, int parameter_count, oop* return_type, TRAPS) {
   616   // Allocate array holding parameter types (java.lang.Class instances)
   616   // Allocate array holding parameter types (java.lang.Class instances)
   617   objArrayOop m = oopFactory::new_objArray(SystemDictionary::Class_klass(), parameter_count, CHECK_(objArrayHandle()));
   617   objArrayOop m = oopFactory::new_objArray(SystemDictionary::Class_klass(), parameter_count, CHECK_(objArrayHandle()));
   618   objArrayHandle mirrors (THREAD, m);
   618   objArrayHandle mirrors (THREAD, m);
   619   int index = 0;
   619   int index = 0;
   620   // Collect parameter types
   620   // Collect parameter types
   633     *return_type = get_mirror_from_signature(method, &ss, CHECK_(objArrayHandle()));
   633     *return_type = get_mirror_from_signature(method, &ss, CHECK_(objArrayHandle()));
   634   }
   634   }
   635   return mirrors;
   635   return mirrors;
   636 }
   636 }
   637 
   637 
   638 objArrayHandle Reflection::get_exception_types(methodHandle method, TRAPS) {
   638 objArrayHandle Reflection::get_exception_types(const methodHandle& method, TRAPS) {
   639   return method->resolved_checked_exceptions(THREAD);
   639   return method->resolved_checked_exceptions(THREAD);
   640 }
   640 }
   641 
   641 
   642 
   642 
   643 Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) {
   643 Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) {
   661   oop nt = result->java_mirror();
   661   oop nt = result->java_mirror();
   662   return Handle(THREAD, nt);
   662   return Handle(THREAD, nt);
   663 }
   663 }
   664 
   664 
   665 
   665 
   666 oop Reflection::new_method(methodHandle method, bool for_constant_pool_access, TRAPS) {
   666 oop Reflection::new_method(const methodHandle& method, bool for_constant_pool_access, TRAPS) {
   667   // Allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
   667   // Allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
   668   assert(!method()->is_initializer() ||
   668   assert(!method()->is_initializer() ||
   669          (for_constant_pool_access && method()->is_static()),
   669          (for_constant_pool_access && method()->is_static()),
   670          "should call new_constructor instead");
   670          "should call new_constructor instead");
   671   instanceKlassHandle holder (THREAD, method->method_holder());
   671   instanceKlassHandle holder (THREAD, method->method_holder());
   724   }
   724   }
   725   return mh();
   725   return mh();
   726 }
   726 }
   727 
   727 
   728 
   728 
   729 oop Reflection::new_constructor(methodHandle method, TRAPS) {
   729 oop Reflection::new_constructor(const methodHandle& method, TRAPS) {
   730   assert(method()->is_initializer(), "should call new_method instead");
   730   assert(method()->is_initializer(), "should call new_method instead");
   731 
   731 
   732   instanceKlassHandle  holder (THREAD, method->method_holder());
   732   instanceKlassHandle  holder (THREAD, method->method_holder());
   733   int slot = method->method_idnum();
   733   int slot = method->method_idnum();
   734 
   734 
   822   java_lang_reflect_Parameter::set_index(rh(), index);
   822   java_lang_reflect_Parameter::set_index(rh(), index);
   823   return rh();
   823   return rh();
   824 }
   824 }
   825 
   825 
   826 
   826 
   827 methodHandle Reflection::resolve_interface_call(instanceKlassHandle klass, methodHandle method,
   827 methodHandle Reflection::resolve_interface_call(instanceKlassHandle klass, const methodHandle& method,
   828                                                 KlassHandle recv_klass, Handle receiver, TRAPS) {
   828                                                 KlassHandle recv_klass, Handle receiver, TRAPS) {
   829   assert(!method.is_null() , "method should not be null");
   829   assert(!method.is_null() , "method should not be null");
   830 
   830 
   831   CallInfo info;
   831   CallInfo info;
   832   Symbol*  signature  = method->signature();
   832   Symbol*  signature  = method->signature();
   837                                        CHECK_(methodHandle()));
   837                                        CHECK_(methodHandle()));
   838   return info.selected_method();
   838   return info.selected_method();
   839 }
   839 }
   840 
   840 
   841 
   841 
   842 oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
   842 oop Reflection::invoke(instanceKlassHandle klass, const methodHandle& reflected_method,
   843                        Handle receiver, bool override, objArrayHandle ptypes,
   843                        Handle receiver, bool override, objArrayHandle ptypes,
   844                        BasicType rtype, objArrayHandle args, bool is_method_invoke, TRAPS) {
   844                        BasicType rtype, objArrayHandle args, bool is_method_invoke, TRAPS) {
   845   ResourceMark rm(THREAD);
   845   ResourceMark rm(THREAD);
   846 
   846 
   847   methodHandle method;      // actual method to invoke
   847   methodHandle method;      // actual method to invoke