RFR [8051382] Optimize java.lang.reflect.Modifier.toString()

Martin Buchholz martinrb at google.com
Fri Jul 18 23:07:35 UTC 2014


Oh sorry, I missed that you had tightened the imports.

I took a quick look at StringJoiner.  It looks to me like this won't be an
optimization, because StringJoiner uses StringBuilder internally, and will
actually perform more total operations.  It looks to me like StringJoiner
itself could be optimized by storing the strings in an array and generating
the final String perfectly at the end when all the inputs are known, using
the private String constructor that takes a char[].


On Fri, Jul 18, 2014 at 3:57 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com>
wrote:

>  In the test I only replaced
>
> import java.lang.reflect.*;
>
> with
>
> import java.lang.reflect.Modifier;
>
> and added the new bugid to the @bug tag.
>
> Sincerely yours,
> Ivan
>
>
> On 19.07.2014 2:53, Martin Buchholz wrote:
>
> It looks like the test has a new import, but no actual new code that uses
> it.
>
>
> On Fri, Jul 18, 2014 at 3:39 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com
> > wrote:
>
>> Hello!
>>
>> StringBuilder can be replaced with StringJoiner, which will make the code
>> shorter and, probably, more efficient.
>> The existing regtest (java/lang/reflect/Modifier/toStringTest.java) can
>> be used to make sure nothing is broken.
>>
>> Would you please help review the fix?
>>
>> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8051382
>> WEBREV: http://cr.openjdk.java.net/~igerasim/8051382/0/webrev/
>>
>> Sincerely yours,
>> Ivan
>>
>
>
>



More information about the core-libs-dev mailing list