RFR 8214971 : Replace use of string.equals("") with isEmpty()

Hannes Wallnöfer hannes.wallnoefer at oracle.com
Fri Dec 7 09:24:45 UTC 2018


Hi Roger,

There are quite a few occurrences of the reverse calling pattern "".equals(str) in core libs.

This is a bit more tricky because it allows str to be null, but when used following a null/not-null check it could be replaced with isEmpty() as well.

I wonder if these should be included in the patch?

Hannes


> Am 06.12.2018 um 21:04 schrieb Roger Riggs <Roger.Riggs at oracle.com>:
> 
> Please review changing string.equals("") to string.isEmpty().
> isEmpty is preferred, performs better and is easier to optimize.
> 
> The change is a literal substitution in all files and only in these modules:
> 
>   java.base
>   java.logging
>   java.management
>   java.management.rmi
>   java.naming
>   java.net.http
>   java.prefs
>   java.rmi
>   java.scripting
>   java.sql
>   java.sql.rowset
>   java.xml
>   jdk.jartool
>   jdk.javadoc
>   jdk.jcmd
>   jdk.jconsole
>   jdk.management.agent
>   jdk.naming.dns
>   jdk.rmic
> 
> 
> Webrev:
> http://cr.openjdk.java.net/~rriggs/webrev-string-isempty-8214971-1/
> 
> Issue:
>   https://bugs.openjdk.java.net/browse/JDK-8214971
> 
> Thanks, Roger



More information about the core-libs-dev mailing list