hotspot/src/share/vm/prims/jvm.cpp
changeset 15102 0a86564e5f61
parent 15097 9db149412e0e
child 15194 a35093d73168
child 15217 af9400e71d87
--- a/hotspot/src/share/vm/prims/jvm.cpp	Mon Jan 07 15:32:51 2013 -0500
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Tue Jan 08 14:01:36 2013 -0500
@@ -1515,7 +1515,7 @@
 JVM_END
 
 
-static Method* jvm_get_method_common(jobject method, TRAPS) {
+static Method* jvm_get_method_common(jobject method) {
   // some of this code was adapted from from jni_FromReflectedMethod
 
   oop reflected = JNIHandles::resolve_non_null(method);
@@ -1533,8 +1533,7 @@
   }
   Klass* k = java_lang_Class::as_Klass(mirror);
 
-  KlassHandle kh(THREAD, k);
-  Method* m = InstanceKlass::cast(kh())->method_with_idnum(slot);
+  Method* m = InstanceKlass::cast(k)->method_with_idnum(slot);
   if (m == NULL) {
     assert(false, "cannot find method");
     return NULL;  // robustness
@@ -1548,7 +1547,7 @@
   JVMWrapper("JVM_GetMethodAnnotations");
 
   // method is a handle to a java.lang.reflect.Method object
-  Method* m = jvm_get_method_common(method, CHECK_NULL);
+  Method* m = jvm_get_method_common(method);
   return (jbyteArray) JNIHandles::make_local(env,
     Annotations::make_java_array(m->annotations(), THREAD));
 JVM_END
@@ -1558,7 +1557,7 @@
   JVMWrapper("JVM_GetMethodDefaultAnnotationValue");
 
   // method is a handle to a java.lang.reflect.Method object
-  Method* m = jvm_get_method_common(method, CHECK_NULL);
+  Method* m = jvm_get_method_common(method);
   return (jbyteArray) JNIHandles::make_local(env,
     Annotations::make_java_array(m->annotation_default(), THREAD));
 JVM_END
@@ -1568,7 +1567,7 @@
   JVMWrapper("JVM_GetMethodParameterAnnotations");
 
   // method is a handle to a java.lang.reflect.Method object
-  Method* m = jvm_get_method_common(method, CHECK_NULL);
+  Method* m = jvm_get_method_common(method);
   return (jbyteArray) JNIHandles::make_local(env,
     Annotations::make_java_array(m->parameter_annotations(), THREAD));
 JVM_END
@@ -1590,6 +1589,32 @@
   return NULL;
 JVM_END
 
+JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method))
+{
+  JVMWrapper("JVM_GetMethodParameters");
+  // method is a handle to a java.lang.reflect.Method object
+  Method* method_ptr = jvm_get_method_common(method);
+  methodHandle mh (THREAD, method_ptr);
+  Handle reflected_method (THREAD, JNIHandles::resolve_non_null(method));
+  const int num_params = mh->method_parameters_length();
+
+  if(0 != num_params) {
+    objArrayOop result_oop = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL);
+    objArrayHandle result (THREAD, result_oop);
+
+    for(int i = 0; i < num_params; i++) {
+      MethodParametersElement* params = mh->method_parameters_start();
+      Symbol* const sym = mh->constants()->symbol_at(params[i].name_cp_index);
+      oop param = Reflection::new_parameter(reflected_method, i, sym,
+                                            params[i].flags, CHECK_NULL);
+      result->obj_at_put(i, param);
+    }
+    return (jobjectArray)JNIHandles::make_local(env, result());
+  } else {
+    return (jobjectArray)NULL;
+  }
+}
+JVM_END
 
 // New (JDK 1.4) reflection implementation /////////////////////////////////////