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

result of ?: operator is not of the correct type.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 0.9
    • Fix Version/s: 1.0
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.0beta
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Not verified

      Description

      Rafael Bracho writes:

      Returning of Numeric Constants. There seems to be a weird
      interaction between attempting to return a numeric constant,
      especially zero, as a result of the ternary operator, when the
      function is declared as returning a 'short' or a 'byte'. The
      following class makes oakc warn us of a possible loss of precision:

          class test {
      short handicap() {
      short hcp = (short) (0.9 * (200.0 - average()));
      return (hcp > 0) ? hcp : 0;
      }
          }

      Casting zero to be a short in the return statement stops the warning.

        Attachments

          Activity

            People

            Assignee:
            ahoffsunw Arthur Hoff (Inactive)
            Reporter:
            ahoffsunw Arthur Hoff (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: