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

javac does not accept semantically valid == test

    XMLWordPrintable

Details

    • generic
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: