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

statement "assert (x) == y;" doesn't compile

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 1.4.0
    • 1.4.0
    • tools
    • beta
    • sparc
    • solaris_8
    • Verified

    Description

      The assertion statement in the following example program fails to compile on Merlin Beta b59:

      class Asserts {
          public static void main(String[] args) {
      assert (args.length & 1) == 0;
          }
      }

      [terrier] 84 % javac -source 1.4 Asserts.java
      Asserts.java:3: ';' expected
      assert (args.length & 1) == 0;
                                       ^
      Asserts.java:3: incompatible types
      found : int
      required: boolean
      assert (args.length & 1) == 0;
                                  ^
      2 errors

      I observed both of the following alternatives compile with no errors
      (and behave as expected):

      assert ((args.length & 1) == 0);
      assert 0 == (args.length & 1);

      Attachments

        Issue Links

          Activity

            People

              gafter Neal Gafter
              peterjones Peter Jones
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: