Hi Shyam,
I think compiling a .java source file containing assert as keyword or
identifier using -source option is not considered as enabling or disabling
the assertion. It is simply the way to tell the compiler how do you want
your assert should be treated like. Whether you want it to be treated like
identifier, or keyword and of course
NOT both together.
When you compile your source code where "assert" has been used as identifier
(name of variable, method name, class name or so), you must tell compiler
that I want my source code to be taken compatible to
Java 1.3; that allows
you to compile your code with warning though.
When you have used assert as keyword, you tell the compiler to treat your
assert as keyword, and of course the switch -source 1.4 and -source 1.5
demand your code must not use assert as identifier.
If you see the cases, you can't use assert as identifier and keyword in a source file together.
Enabling/Disabling Simply means whether you want your assert
(keyword) to be workable at run time or not. By default its OFF.
Enabling or Disabling never mean to be issue of compiling source file.
You do not enable assertion using -source switch while compiling, it is only
the way to tell the compiler, according to what version your code should be
treated like.
Thanks,