8058322: Zero name_index item of MethodParameters attribute cause MalformedParameterException
authoremc
Mon, 10 Nov 2014 19:37:32 -0500
changeset 27613 f4773c0d8717
parent 27612 7201412afbd0
child 27614 c48433d6a6b0
8058322: Zero name_index item of MethodParameters attribute cause MalformedParameterException Summary: Allow hotspot to report null for 0 parameter_name index in MethodParameters attribute Reviewed-by: coleenp, dholmes
hotspot/src/share/vm/runtime/reflection.cpp
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Mon Nov 10 16:45:46 2014 -0500
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Mon Nov 10 19:37:32 2014 -0500
@@ -806,17 +806,16 @@
 
 oop Reflection::new_parameter(Handle method, int index, Symbol* sym,
                               int flags, TRAPS) {
-  Handle name;
 
-  // A null symbol here translates to the empty string
+  Handle rh = java_lang_reflect_Parameter::create(CHECK_NULL);
+
   if(NULL != sym) {
-    name = java_lang_String::create_from_symbol(sym, CHECK_NULL);
+    Handle name = java_lang_String::create_from_symbol(sym, CHECK_NULL);
+    java_lang_reflect_Parameter::set_name(rh(), name());
   } else {
-    name = java_lang_String::create_from_str("", CHECK_NULL);
+    java_lang_reflect_Parameter::set_name(rh(), NULL);
   }
 
-  Handle rh = java_lang_reflect_Parameter::create(CHECK_NULL);
-  java_lang_reflect_Parameter::set_name(rh(), name());
   java_lang_reflect_Parameter::set_modifiers(rh(), flags);
   java_lang_reflect_Parameter::set_executable(rh(), method());
   java_lang_reflect_Parameter::set_index(rh(), index);