[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Syntax error on token "assert" even though compliance is 1.4

Kevin Murphy a écrit :
I'm using Eclipse 3.0M7 on Mac OS X 10.2.8 (JVM 1.4.1).

Even though Properties/Java Compiler/Compliance and Classfiles/Compiler
Compliance Level is set to 1.4, assert statements are causing this error:


Syntax error on token "assert", assert expected

I tried various permutations on the Compliance tab to no effect.
To compile assert statements, you need:
- compliance set to 1.4
- source level set to 1.4
- target platform set to 1.4
- assert as an identifier set to error.

Compliance 1.4 means the compiler is behaving like javac 1.4. By default javac 1.4 is not compiling assert statements. You need to set explicitly the source level to 1.4 using -source 1.4. This is the same kind of settings in Eclipse.
--
Olivier