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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 1.4.0
    • Affects Version/s: 1.4.0
    • Component/s: tools
    • beta
    • sparc
    • solaris_8
    • Verified

      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);

            Assignee:
            Neal Gafter (Inactive)
            Reporter:
            Peter Jones (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: