Smoking assertions?

Discussion in 'Java' started by jupiter, Dec 21, 2006.

  1. jupiter

    jupiter Guest

    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?
     
    jupiter, Dec 21, 2006
    #1
    1. Advertising

  2. jupiter

    Daniel Pitts Guest

    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$"
     
    Daniel Pitts, Dec 21, 2006
    #2
    1. Advertising

  3. jupiter

    jupiter Guest

    "Daniel Pitts" <> wrote in message
    news:...
    >
    > 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.
     
    jupiter, Dec 22, 2006
    #3
  4. jupiter

    Hemal Pandya Guest

    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
     
    Hemal Pandya, Dec 22, 2006
    #4
  5. jupiter

    Phi Guest

    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
     
    Phi, Dec 22, 2006
    #5
  6. jupiter

    jupiter Guest

    "Hemal Pandya" <> wrote in message
    news:...
    >
    > 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, Dec 23, 2006
    #6
  7. jupiter

    jupiter Guest

    "Phi" <> wrote in message
    news:60231$458b8cee$544a50d5$...
    > 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?
     
    jupiter, Dec 23, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vhdlcohen
    Replies:
    0
    Views:
    1,072
    vhdlcohen
    Dec 1, 2004
  2. anupam
    Replies:
    2
    Views:
    932
  3. idog
    Replies:
    2
    Views:
    320
    John Saunders
    Nov 14, 2003
  4. Replies:
    0
    Views:
    334
  5. Daniel Berger

    Smoking out C extension mistakes

    Daniel Berger, Jan 10, 2006, in forum: Ruby
    Replies:
    2
    Views:
    76
Loading...

Share This Page