Smoking assertions?  
Author Message
jupiter





PostPosted: 2006-12-22 5:57:00 Top

java-programmer, Smoking assertions? With regard to assertions it appears that the compiler default has
changed from 1.4 to 1.5. The 1.5 default compiles as-if "-source
1.5" instead of the old 1.4 way "-source 1.3".

All well and good but 1.5 doesn't appear to let me compile with
"-source 1.3" to have an identifier named "assert". Apparently you
could do this with 1.4. If I try to 1.5 compile with "-source 1.3"
it returns the error that "assert is a keyword, try compiling
with -source 1.4, blah blah".

Does anybody know if this is correct and why they removed the
ability to compile as 1.3?


 
Daniel Pitts





PostPosted: 2006-12-22 7:13:00 Top

java-programmer >> Smoking assertions?
jupiter wrote:
> With regard to assertions it appears that the compiler default has
> changed from 1.4 to 1.5. The 1.5 default compiles as-if "-source
> 1.5" instead of the old 1.4 way "-source 1.3".
>
> All well and good but 1.5 doesn't appear to let me compile with
> "-source 1.3" to have an identifier named "assert". Apparently you
> could do this with 1.4. If I try to 1.5 compile with "-source 1.3"
> it returns the error that "assert is a keyword, try compiling
> with -source 1.4, blah blah".
>
> Does anybody know if this is correct and why they removed the
> ability to compile as 1.3?

I have no idea, but I have a suggestion...

Search/ReplaceAll "assert" with "assert$"

 
jupiter





PostPosted: 2006-12-22 8:02:00 Top

java-programmer >> Smoking assertions?
"Daniel Pitts" <email***@***.com> wrote in message
news:email***@***.com...
>
> jupiter wrote:
>> With regard to assertions it appears that the compiler default
>> has
>> changed from 1.4 to 1.5. The 1.5 default compiles as-if
>> "-source
>> 1.5" instead of the old 1.4 way "-source 1.3".
>>
>> All well and good but 1.5 doesn't appear to let me compile with
>> "-source 1.3" to have an identifier named "assert". Apparently
>> you
>> could do this with 1.4. If I try to 1.5 compile with "-source
>> 1.3"
>> it returns the error that "assert is a keyword, try compiling
>> with -source 1.4, blah blah".
>>
>> Does anybody know if this is correct and why they removed the
>> ability to compile as 1.3?
>
> I have no idea, but I have a suggestion...
>
> Search/ReplaceAll "assert" with "assert$"
>

Hehehe, good one, but where is your sense of adventure?

I'm trying to figure it out because of a case of "certification
test paranoia". Nobody in their right mind would ever need to use
"assert" as an identifier, which is why my paranoia is telling me
it's almost guaranteed to be on the test.







 
 
Hemal Pandya





PostPosted: 2006-12-22 12:26:00 Top

java-programmer >> Smoking assertions?
jupiter wrote:
> With regard to assertions it appears that the compiler default has
> changed from 1.4 to 1.5. The 1.5 default compiles as-if "-source
> 1.5" instead of the old 1.4 way "-source 1.3".
>
> All well and good but 1.5 doesn't appear to let me compile with
> "-source 1.3" to have an identifier named "assert". Apparently you
> could do this with 1.4. If I try to 1.5 compile with "-source 1.3"
> it returns the error that "assert is a keyword, try compiling
> with -source 1.4, blah blah".
>
> Does anybody know if this is correct and why they removed the
> ability to compile as 1.3?

I get only a warning with 1.5.0_09:

~/java/java5> /usr/local/java/jdk1.5.0_09/bin/javac -source 1.3
NoAssert.java
NoAssert.java:5: warning: as of release 1.4, 'assert' is a keyword, and
may not be used as an identifier
(try -source 1.4 or higher to use 'assert' as a keyword)
int assert = 9;
^
1 warning

 
 
Phi





PostPosted: 2006-12-22 15:45:00 Top

java-programmer >> Smoking assertions? Hemal Pandya wrote:
> jupiter wrote:
>> With regard to assertions it appears that the compiler default has
>> changed from 1.4 to 1.5. The 1.5 default compiles as-if "-source
>> 1.5" instead of the old 1.4 way "-source 1.3".
>>
>> All well and good but 1.5 doesn't appear to let me compile with
>> "-source 1.3" to have an identifier named "assert". Apparently you
>> could do this with 1.4. If I try to 1.5 compile with "-source 1.3"
>> it returns the error that "assert is a keyword, try compiling
>> with -source 1.4, blah blah".
>>
>> Does anybody know if this is correct and why they removed the
>> ability to compile as 1.3?
>
> I get only a warning with 1.5.0_09:
>
> ~/java/java5> /usr/local/java/jdk1.5.0_09/bin/javac -source 1.3
> NoAssert.java
> NoAssert.java:5: warning: as of release 1.4, 'assert' is a keyword, and
> may not be used as an identifier
> (try -source 1.4 or higher to use 'assert' as a keyword)
> int assert = 9;
> ^
> 1 warning
>

I get warings and errors for the following class:

class Test {int assert;}

Comiling with javac -version 1.6.0
leads to "invalid source release", when I use [-source 1.0, 1.1 and
earlier ;-)]
leads to "compiler warnings", when I use [-source 1.2 and 1.3]
leads to "compiler errors", when I use [-source 1.4, 1.5 and 1.6]

By the way: For the java certification, have a look at the new
"Mock-Exam" I wrote for my students:
http://www.santis.ch/training/java/jcp/selftester/

Greetings and good luck for the Java Certification exam

phi
 
 
jupiter





PostPosted: 2006-12-23 11:25:00 Top

java-programmer >> Smoking assertions?
"Hemal Pandya" <email***@***.com> wrote in message
news:email***@***.com...
>
> jupiter wrote:
>> With regard to assertions it appears that the compiler default
>> has
>> changed from 1.4 to 1.5. The 1.5 default compiles as-if
>> "-source
>> 1.5" instead of the old 1.4 way "-source 1.3".
>>
>> All well and good but 1.5 doesn't appear to let me compile with
>> "-source 1.3" to have an identifier named "assert". Apparently
>> you
>> could do this with 1.4. If I try to 1.5 compile with "-source
>> 1.3"
>> it returns the error that "assert is a keyword, try compiling
>> with -source 1.4, blah blah".
>>
>> Does anybody know if this is correct and why they removed the
>> ability to compile as 1.3?
>
> I get only a warning with 1.5.0_09:
>

I get it: I was trying to use identifer=assert plus assert
keywords. No can do; can do one but not both.

So, "javac -source 1.3 AssertIdentifier.java" with an "assert"
identifier will compile with only a warning. That is correct and
expected, I believe. That is the same as (purportedly) 1.4.

Good, that makes me feel better. The world is a good and stable
place again.

Thanks, Hemal.


 
 
jupiter





PostPosted: 2006-12-23 11:29:00 Top

java-programmer >> Smoking assertions?
"Phi" <email***@***.com> wrote in message
news:60231$458b8cee$544a50d5$email***@***.com...
> Hemal Pandya wrote:
>> jupiter wrote:
>>> With regard to assertions it appears that the compiler default
>>> has
>>> changed from 1.4 to 1.5. The 1.5 default compiles as-if
>>> "-source
>>> 1.5" instead of the old 1.4 way "-source 1.3".
>>>
>>> All well and good but 1.5 doesn't appear to let me compile with
>>> "-source 1.3" to have an identifier named "assert". Apparently
>>> you
>>> could do this with 1.4. If I try to 1.5 compile with "-source
>>> 1.3"
>>> it returns the error that "assert is a keyword, try compiling
>>> with -source 1.4, blah blah".
>>>
>>> Does anybody know if this is correct and why they removed the
>>> ability to compile as 1.3?
>>
>> I get only a warning with 1.5.0_09:
>>
>> ~/java/java5> /usr/local/java/jdk1.5.0_09/bin/javac -source 1.3
>> NoAssert.java
>> NoAssert.java:5: warning: as of release 1.4, 'assert' is a
>> keyword, and
>> may not be used as an identifier
>> (try -source 1.4 or higher to use 'assert' as a keyword)
>> int assert = 9;
>> ^
>> 1 warning
>>
>
> I get warings and errors for the following class:
>
> class Test {int assert;}
>
> Comiling with javac -version 1.6.0
> leads to "invalid source release", when I use [-source 1.0, 1.1
> and
> earlier ;-)]
> leads to "compiler warnings", when I use [-source 1.2 and 1.3]
> leads to "compiler errors", when I use [-source 1.4, 1.5 and 1.6]
>

Hi, Phi, and I think that is all correct behavior. With -source
1.4 you cannot use "assert" as an identifer.

The problem I was creating was tyring to use an assert identifier
*plus* assert keywords in the same class. One or the other, with
the correct command line, is OK, but not both together.

Makes sense. My faux pas.




> By the way: For the java certification, have a look at the new
> "Mock-Exam" I wrote for my students:
> http://www.santis.ch/training/java/jcp/selftester/
>
> Greetings and good luck for the Java Certification exam
>
> phi

Very cool! I'll be checking this out over the weekend. What gave
you the inspiration to do the work?