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

mandy chung mandy.chung at oracle.com
Fri Sep 1 16:40:24 UTC 2017



On 9/1/17 2:57 AM, forax at univ-mlv.fr wrote:
> Hi Mandy,
> good for me.
>
> in Basic.java, in methodTypes(), instead of using a new HashMap, you can use Map.of().
Yes will fix it before push.

Mandy
> cheers,
> Rémi
>
> ----- Mail original -----
>> De: "mandy chung" <mandy.chung at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>
>> Cc: "core-libs-dev" <core-libs-dev at openjdk.java.net>
>> Envoyé: Vendredi 1 Septembre 2017 07:39:54
>> Objet: Re: Review Request JDK-8186050: StackFrame should provide the method signature
>> Updated webrev:
>> http://cr.openjdk.java.net/~mchung/jdk10/webrevs/8186050/webrev.01/index.html
>>
>> This introduces two new methods, StackFrame::getMethodType and
>> StackFrame::getDescriptor.
>>
>> Mandy
>>
>> On 8/30/17 12:25 AM, Remi Forax wrote:
>>> Hi Mandy,
>>> thanks for taking care of this.
>>>
>>> In my opinion, we should provide both getMethodType() and getDescriptor(),
>>> getDescriptor() is handy for logging (finding the right overload when line
>>> numbers are not present) and getMethodType() is the one you whant if you want
>>> to inspect the runtime view of the stack frames (and by example interact with
>>> java.lang.invoke). For me, it's the same reason that give us
>>> getDeclaringClass() and getClassName() in the current API.
>>>
>>> So getDescriptor() can be called with no restriction but getMethodType()
>>> requires RETAIN_CLASS_REFERENCE.
>>>
>>> regards,
>>> Rémi
>>>
>>> ----- Mail original -----
>>>> De: "mandy chung" <mandy.chung at oracle.com>
>>>> À: "core-libs-dev" <core-libs-dev at openjdk.java.net>
>>>> Envoyé: Mardi 29 Août 2017 00:57:28
>>>> Objet: Review Request JDK-8186050: StackFrame should provide the method
>>>> signature
>>>> 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