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

javac does not accept semantically valid == test

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 5.0, 6
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      boolean b = (3 == (Object)null);
        compiles because javac performs a boxing conversion followed by a
        widening reference conversion. This isn't currently a valid combination
        under casting conversion (as required by 15.21.3) but 6526446 will
        expand casting conversion and it will become valid.

      However, this does not compile, and should:

      boolean b = ((Object)null == 3); // incomparable types: java.lang.Object and int

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                abuckley Alex Buckley
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: