Review request for: JDK-8004728 Add hotspot support for parameter reflection

Stefan Karlsson stefan.karlsson at oracle.com
Wed Dec 12 05:30:20 PST 2012


Hi Eric,

This is not a full review, but I have a comment regarding one part of 
the code.

http://oklahoma.us.oracle.com/~cphillim/webrev/8004728/src/share/vm/prims/jvm.cpp.udiff.html

+JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method))
+{
+  JVMWrapper("JVM_GetMethodParameters");
+
+  // method is a handle to a java.lang.reflect.Method object
+  Method* const m = jvm_get_method_common(method, CHECK_NULL);
+  const u4 num_params = m->method_parameters_length();
+  objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL);  // <-- GC can run here
+  objArrayHandle result (THREAD, r);
+  MethodParametersElement* params = m->method_parameters_start();
+  Handle executable (THREAD, JNIHandles::resolve_non_null(method));
+
+  for(u4 i = 0; i < num_params; i++) {
+    Symbol* sym = m->constants()->symbol_at(params[i].name_cp_index);
+    oop param = Reflection::new_parameter(executable, i, sym,
+                                          params[i].flags, CHECK_NULL);// <-- GC can run here
+    result->obj_at_put(i, param);
+  }
+  return (jobjectArray)JNIHandles::make_local(env, result());
+}
+JVM_END

Because of the way we deallocate methods after a class redefinition, you 
have to use methodHandles instead of Method*s whenever we might block 
for a GC.

See bug: http://bugs.sun.com/view_bug.do?bug_id=8004815

SefanK

On 12/12/2012 12:18 AM, Eric McCorkle wrote:
> Apologies if this has already come across the list; it appears that it
> didn't get through for some reason.
>
> Please review the implementation of the following new feature:
> https://jbs.oracle.com/bugs/browse/JDK-8004728
>
>
> The open webrev is here:
> http://oklahoma.us.oracle.com/~cphillim/webrev/8004728/
>
>
> Summary:
>
> This is the VM side of the implementation of method parameter
> reflection.  The implementation has been tested by building and running
> regression tests with javac hardwired to produce classfiles containing
> MethodParameters attributes.
>
> It will be further tested as part of the testing for the Reflection API
> side of the implementation of this feature.
>
> The specification of the feature is attached to the new feature request
> above.
>
>
> Thanks,
> Eric



More information about the hotspot-dev mailing list