RFR: [8054714] Use StringJoiner where it makes the code cleaner

Claes Redestad claes.redestad at oracle.com
Sat Aug 9 00:44:26 UTC 2014

Looks good to me, if that matters...

Not sure if worth considering, but for simple cases like 
src/share/classes/java/util/PropertyPermission.java, you could return 
the possible constant values instead:

static String getActions(int mask) {
     switch (mask & 0x3) {
         case 1:
             return SecurityConstants.READ;
         case 2:
             return SecurityConstants.WRITE;
         case 3:
             return SecurityConstants.RW;
             return "";

Also, now that it's backed by a String[], some of these cases could be 
optimized if StringJoiner had a way to set/ensure capacity (what leaky 



On 2014-08-08 23:26, Ivan Gerasimov wrote:
> Hello everyone!
> This is a follower of the recently fixed [8051382] -- Optimize 
> java.lang.reflect.Modifier.toString().
> I found a dozen+ other places in jdk, where using the StringJoiner 
> makes the code shorter and cleaner.
> Would you please help review the fix?
> http://cr.openjdk.java.net/~igerasim/8054714/0/webrev/
> Sincerely yours,
> Ivan

More information about the core-libs-dev mailing list