According to the Orcale Java7 Guide :
- source mode 1.3 (default) - the compiler accepts programs that use assert as an identifier, but issue warnings. In this mode, programs are not allowed to use the assert statement.
- source mode 1.4 - the compiler generates an error message if the program uses assert as an identifier. In this mode, programs are allowed to use the assert statement.
I wrote a class like this:
package mm; public class ClassTest { public static void main(String[] arg) { int assert = 1; System.out.println(assert); } }
It should compile fine if Oracle info is right (1.3 is the default source mode). But I got such errors:
$ javac -version
javac 1.7.0_04
$ javac -d bin src / mm / *
src \ mm \ ClassTest.java: 5: error: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier
int assert = 1;
^
(use -source 1.3 or lower to use 'assert' as an identifier)
src \ mm \ ClassTest.java: 6: error: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier
System.out.println (assert);
^
(use -source 1.3 or lower to use 'assert' as an identifier)
2 errors
I manually added -source 1.3 , and it issued warnings, but compiled them in order. It seems that the Oracle information is incorrect and 1.3 is not the default initial mode. Which one then?
waste source share