src/share/vm/prims/jvm.cpp
Print this page
@@ -1796,11 +1796,20 @@
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) {
+ if (0 > num_params) {
+ // A -1 return value from method_parameters_length means there is no
+ // parameter data. Return null to indicate this to the reflection
+ // API.
+ return (jobjectArray)NULL;
+ } else {
+ // Otherwise, we return something up to reflection, even if it is
+ // a zero-length array. Why? Because in some cases this can
+ // trigger a MalformedParametersException.
+
// make sure all the symbols are properly formatted
for (int i = 0; i < num_params; i++) {
MethodParametersElement* params = mh->method_parameters_start();
int index = params[i].name_cp_index;
bounds_check(mh->constants(), index, CHECK_NULL);
@@ -1824,12 +1833,10 @@
oop param = Reflection::new_parameter(reflected_method, i, sym,
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 /////////////////////////////////////