Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8200364

Remove unnecessary boxing via primitive wrapper valueOf(String) methods

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 11
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b08

      Description

      A colleague used findbugs to find these small fixes to useless boxing:

      diff --git a/src/java.base/share/classes/java/text/ChoiceFormat.java b/src/java.base/share/classes/java/text/ChoiceFormat.java
      --- a/src/java.base/share/classes/java/text/ChoiceFormat.java
      +++ b/src/java.base/share/classes/java/text/ChoiceFormat.java
      @@ -212,7 +212,7 @@
                       } else if (tempBuffer.equals("-\u221E")) {
                           startValue = Double.NEGATIVE_INFINITY;
                       } else {
      - startValue = Double.valueOf(tempBuffer);
      + startValue = Double.parseDouble(tempBuffer);
                       }
       
                       if (ch == '<' && startValue != Double.POSITIVE_INFINITY &&
      diff --git a/src/java.logging/share/classes/java/util/logging/Logger.java b/src/java.logging/share/classes/java/util/logging/Logger.java
      --- a/src/java.logging/share/classes/java/util/logging/Logger.java
      +++ b/src/java.logging/share/classes/java/util/logging/Logger.java
      @@ -640,7 +640,7 @@
                           return System.getProperty(key);
                       }
                   });
      - return Boolean.valueOf(s);
      + return Boolean.parseBoolean(s);
               }
           }
       

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              martin Martin Buchholz
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: