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

13.4.9: Avoid use of Boolean constructor in example

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: specification
    • Labels:

      Description

      JLS 13.4.9 has the following:

      ==========
      We note, but do not recommend, that if a field of primitive type of an
      interface may change, its value may be expressed idiomatically as in:
          ...
          boolean debug = new Boolean(true).booleanValue();
          ...
      ==========

      This is not incorrect, but it uses the Boolean constructor, which is usually unnecessary and whose use is discouraged. I believe that all that's necessary here is to get a boolean value from an expression that's not a compile-time constant, so the following should be sufficient:

          boolean debug = Boolean.valueOf(true).booleanValue();

      Perhaps the JLS 13.4.9 example could be changed to use this instead.

        Attachments

          Activity

            People

            • Assignee:
              abuckley Alex Buckley
              Reporter:
              smarks Stuart Marks
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: