Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

Smoking assertions?

Thread view: 
jupiter - 21 Dec 2006 21:57 GMT
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 - 21 Dec 2006 23:13 GMT
> 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
[quoted text clipped - 8 lines]
> 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 - 22 Dec 2006 00:02 GMT
>> With regard to assertions it appears that the compiler default
>> has
[quoted text clipped - 16 lines]
>
> 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 - 22 Dec 2006 04:26 GMT
> 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
[quoted text clipped - 8 lines]
> 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 - 22 Dec 2006 07:44 GMT
Hemal Pandya 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
[quoted text clipped - 19 lines]
>         ^
> 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 - 23 Dec 2006 03:28 GMT
> Hemal Pandya wrote:
>>> With regard to assertions it appears that the compiler default
[quoted text clipped - 36 lines]
> 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:
[quoted text clipped - 3 lines]
>
> phi

Very cool!  I'll be checking this out over the weekend.  What gave
you the inspiration to do the work?
jupiter - 23 Dec 2006 03:25 GMT
>> With regard to assertions it appears that the compiler default
>> has
[quoted text clipped - 14 lines]
>
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.