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

Unify ParseLong Methods to Throw NPE

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      For the Long class, in one instance of the parseLong method, a NumberFormatException is thrown for a null input value, but in another instance, a NullPointerException is thrown.

      https://github.com/openjdk/jdk/blob/d0f3cc92bc97aa517d622ac57d22f820fba0684b/src/java.base/share/classes/java/lang/Long.java#L684-L686

      https://github.com/openjdk/jdk/blob/d0f3cc92bc97aa517d622ac57d22f820fba0684b/src/java.base/share/classes/java/lang/Long.java#L765

      Please unify these methods so that they both throw NPE on a null input value. With JDK-8261290, the message for NumberFormatException was improved to be more clear that this is a null value, not a string of "null" characters (thanks), but the NPE would be preferable here.

      Please consider unifying all of the Number classes. For example:

      https://github.com/openjdk/jdk/blob/d0f3cc92bc97aa517d622ac57d22f820fba0684b/src/java.base/share/classes/java/lang/Integer.java#L630


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: