<AWT Dev> [OpenJDK 2D-Dev] [13] Review Request: 8223237 Replace use of string.equals("") with isEmpty() in java.desktop

Philip Race philip.race at oracle.com
Sat May 4 05:37:53 UTC 2019


I am not sure how important this clean up is but since you've done it ..

replacing "".equals(foo) wth foo.isEmpty(()
isn't equivalent but the cases I saw where you did are either
foo == null || [!]foo.isEmpty()
eg :
-        if (fontName == null || "".equals(fontName)) {
+        if (fontName == null || fontName.isEmpty()) {
or
foo != null && [!]foo.isEmpty()

eg:
-        if(text != null && !text.equals("")) {
+        if(text != null && !text.isEmpty()) {

so these should be fine. Although for the line above since
you are touching it I'd like "if(" turned into "if ("

Here's another one

-                            if(!keyword.equals("")&&  !value.equals("")) {
+                            if(!keyword.isEmpty()&&  !value.isEmpty()) {


With those updates,  +1

-phil

On 5/2/19, 5:01 AM, Sergey Bylokhov wrote:
> Hello.
> Please review the fix for JDK 13.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8223237
> Fix: http://cr.openjdk.java.net/~serb/8223237/webrev.00
>
> This change is an equivalent of JDK-8214971[1] but for the 
> java.desktop module.
>  - The string.equals("") replaced by the string.isEmpty() in all cases
>  - The "".equals(string) replaced by the string.isEmpty() when string 
> is non-null
> [1] https://bugs.openjdk.java.net/browse/JDK-8214971
>
>
> In one case I dropped string.equals("") as unneeded:
> http://cr.openjdk.java.net/~serb/8223237/webrev.00/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolTipUI.java.udiff.html 
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20190503/d554c3b7/attachment.html>


More information about the awt-dev mailing list