RFR: 8215281: Use String.isEmpty() where applicable in java.base

Claes Redestad claes.redestad at oracle.com
Wed Dec 12 17:06:24 UTC 2018



On 2018-12-12 17:54, Daniel Fuchs wrote:
> Hi Claes,
> 
> It might read even better if things like:
> 
> +        resultString = !specarg.isEmpty() ? specarg.intern(): opt;
> 
> were changed into:
> 
> +        resultString = specarg.isEmpty() ? opt : specarg.intern();
> 
> best regards,

I only found this pattern in this file, so incremental
diff will look like the below. I will update in place due hugeness of
webrev.

Thanks!

/Claes

diff -r 732b03e40349 
src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java 
Wed Dec 12 17:41:46 2018 +0100
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java 
Wed Dec 12 18:03:57 2018 +0100
@@ -641,10 +641,10 @@
                      String specarg = spec.substring(sidx);
                      switch (specop) {
                      case '.':  // terminate the option sequence
-                        resultString = !specarg.isEmpty() ? 
specarg.intern(): opt;
+                        resultString = specarg.isEmpty() ? opt : 
specarg.intern();
                          break doArgs;
                      case '?':  // abort the option sequence
-                        resultString = !specarg.isEmpty() ? 
specarg.intern(): arg;
+                        resultString = specarg.isEmpty() ? arg : 
specarg.intern();
                          isError = true;
                          break eachSpec;
                      case '@':  // change the effective opt name
@@ -655,7 +655,7 @@
                          val = "";
                          break;
                      case '!':  // negation option
-                        String negopt = !specarg.isEmpty() ? 
specarg.intern(): opt;
+                        String negopt = specarg.isEmpty() ? opt : 
specarg.intern();
                          properties.remove(negopt);
                          properties.put(negopt, null);  // leave 
placeholder
                          didAction = true;



More information about the security-dev mailing list