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);
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);
- relates to
-
JDK-4492054 javadoc does not parse valid assert statements that javac accepts
-
- Closed
-