RFR: JDK-8222151: refactoring: enhancements to java.lang.Class::methodToString and java.lang.Class::getTypeName

Joe Darcy joe.darcy at oracle.com
Thu Apr 11 20:48:43 UTC 2019


Hi Vicente,

That version is better. If one doesn't mind the ?: operator, something 
like the following is possible:

return getName() + '.' + name +
(argTypes == null || argTypes.length == 0) ?
"()":
   Arrays.stream(argTypes)
   .map(c -> c == null ? "null" : c.getName())
   .collect(Collectors.joining(",", "(", ")"));

HTH,

-Joe

On 4/11/2019 1:30 PM, Vicente Romero wrote:
> Hi Joe,
>
> Thanks for the review please, I have modified the webrev [1]
>
> [1] http://cr.openjdk.java.net/~vromero/8222151/webrev.01/
>
> On 4/11/19 1:26 PM, Joseph D. Darcy wrote:
>> Hi Vicente,
>>
>> For methodToString, factoring out computing the common
>>
>>     getName() + '.' + name
>>
>> prefix might be preferable, but otherwise the patch looks fine.
>>
>> Thanks,
>>
>> -Joe
>>
>> On 4/11/2019 10:22 AM, Vicente Romero wrote:
>>> Please review the enhancements to java.lang.Class proposed by Sergei 
>>> Tsypanov see discussion at [1]. The bug can be found at [2] and the 
>>> fix at [3]. This enhancement is removing uses of StringBuilder in:
>>>     ::toGenericString
>>>     ::methodToString, and
>>>     ::getTypeName
>>>
>>> Thanks,
>>> Vicente
>>>
>>> [1] 
>>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-March/059110.html
>>> [2] https://bugs.openjdk.java.net/browse/JDK-8222151
>>> [3] http://cr.openjdk.java.net/~vromero/8222151/webrev.00/
>>
>


More information about the core-libs-dev mailing list