I encountered a strange error, which I believe is a bug. Here is a minimal case, please do not comment on the usefulness of the code :)
class Foo {
static public <X> int bar() { return 42; }
public int baz() {
return true ? 42 : (
Foo.<Void>bar() > 42 ? 41 : 43
)
;
}
}
Result:
err.java:7: illegal start of expression
Foo.<Void>bar() > 42 ? 41 : 43
^
I have tried SUN SDK javac 1.6.0_13 and 1.6.0_21.
The error goes away, when I either
So it looks like that if e is an expression, it is not always valid to write (e)?
The posted code compiles (and runs) just fine for me using Eclipse, but I can confirm that javac
fails to compile this. I suspect you've found a compiler bug in javac
.
It would probably be a good idea to report it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With