8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException

Allow hotspot to store and report zero-length MethodParameters attribute data

Reviewed-by: coleenp, jiangli
This commit is contained in:
Eric McCorkle 2014-11-10 16:45:46 -05:00
parent 5ccaf44879
commit bbd7b058d1
4 changed files with 28 additions and 10 deletions

View file

@ -1657,7 +1657,17 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method))
Handle reflected_method (THREAD, JNIHandles::resolve_non_null(method));
const int num_params = mh->method_parameters_length();
if (0 != num_params) {
if (num_params < 0) {
// A -1 return value from method_parameters_length means there is no
// parameter data. Return null to indicate this to the reflection
// API.
assert(num_params == -1, "num_params should be -1 if it is less than zero");
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();
@ -1685,8 +1695,6 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method))
result->obj_at_put(i, param);
}
return (jobjectArray)JNIHandles::make_local(env, result());
} else {
return (jobjectArray)NULL;
}
}
JVM_END