Review Request JDK-8186050: StackFrame should provide the method signature

mandy chung mandy.chung at oracle.com
Mon Aug 28 22:57:28 UTC 2017


Method signature is missing in the StackFrame API. This proposes to add 
StackFrame::getMethodDescriptor method to return the method descriptor 
in a stack frame.

Webrev at:
http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.00/index.html

There are a couple options how to present the method signature in the 
API level:
1. Class<?>[] getParameterTypes() and Class<?> getReturnTypes() similiar 
to what java.lang.reflect.Method has.
2. java.lang.invoke.MethodType
3. a String representation (i) comma-separated list of the method's 
formal parameter types (ii) bytecode method descriptor as specified in JVMS

Returning Class<?> instance should require to add a new StackWalker 
option to access to the parameter types and return type for option #1 
and #2. StackFrame::getDeclaringClass requires the stack walker to have 
the RETAIN_CLASS_REFERENCE capability.

Option #2 returning MethodType is handy while java.lang would reference 
a type in java.lang.invoke.

Option #3 requires the caller to parse the return string and call 
Class.forName to get the Class<?> instance. OTOH 
MethodType::fromMethodDescriptorString​ method that returns MethodType 
from a bytecode method descriptor string.

Method signature is for information for typical cases. Getting Class<?> 
for the parameter types and return type would be a niche case. I think 
returning the method descriptor string is a good option - keep the API 
simple and can use MethodType::fromMethodDescriptorString​ to get back 
the types if needed.

thanks
Mandy


More information about the core-libs-dev mailing list