assert, 3.0 M5 [message #124534] |
Thu, 04 December 2003 13:04  |
Eclipse User |
|
|
|
I know that assert is a keyword in JDK 1.4, and that there are options to
control how it gets handled.
I have a line of code (that I didn't write), that reads
assert(false);
compiler compliance is set to JDK 1.4.
In 3.0 M5, I get an error that "The method assert(boolean) is undefined...".
In 2.1.2, this statement compiles without problem. A vendor has told me
that "the compiler will ignore the parentheses". However, clearly in
Eclipse 3.0 M5 does not. As far as I can tell, the the Java spec doesn't
support this syntax.
Would someone more "in the know" comment and provide me some ammo for
dealing with this vendor? Or should a be filing a bug against 3.0 M5.
Thanks
David
|
|
|
Re: assert, 3.0 M5 - settings.png (0/1) [message #124566 is a reply to message #124534] |
Thu, 04 December 2003 15:43   |
Eclipse User |
|
|
|
Originally posted by: olivier_thomann.ca.ibm.comNOSPAM
Le Thu, 04 Dec 2003 13:04:45 -0500, David Corbin <dcorbin@ieee.org> a
écrit :
>I know that assert is a keyword in JDK 1.4, and that there are options to
>control how it gets handled.
>
>I have a line of code (that I didn't write), that reads
>
>assert(false);
>
>compiler compliance is set to JDK 1.4.
This is not enough. You need to change the source level (equivalent to
-source option in javac). By default javac 1.4 doesn't support the
assertion. You need to enable it with -source 1.4.
So if you go to Preferences>Java>Compiler>Compliance and Classfiles>
Uncheck use default compliance settings and put the values 1.4 for the
source level, 1.4 for the target and error for assert as identifier.
See my attached screenshot.
>In 3.0 M5, I get an error that "The method assert(boolean) is undefined...".
Indeed, if assert is considered as an identifier, then this is
understood as a method invocation.
>In 2.1.2, this statement compiles without problem. A vendor has told me
>that "the compiler will ignore the parentheses". However, clearly in
>Eclipse 3.0 M5 does not. As far as I can tell, the the Java spec doesn't
>support this syntax.
The compiler doesn't care about parentheses around an expression. Yes,
the JLS supports this syntax. It is a parentesized expression and the
inner expression is a false literal.
>Would someone more "in the know" comment and provide me some ammo for
>dealing with this vendor? Or should a be filing a bug against 3.0 M5.
With the settings I specified above, it should work.
--
Olivier
|
|
|
|
Re: assert, 3.0 M5 - settings.png (0/1) [message #124590 is a reply to message #124566] |
Thu, 04 December 2003 15:46  |
Eclipse User |
|
|
|
Many thanks. I feel so lame for not recognizing the "boolean expression"
thing. Rough week.
David
Olivier Thomann wrote:
> Le Thu, 04 Dec 2003 13:04:45 -0500, David Corbin <dcorbin@ieee.org> a
> écrit :
>>I know that assert is a keyword in JDK 1.4, and that there are options to
>>control how it gets handled.
>>
>>I have a line of code (that I didn't write), that reads
>>
>>assert(false);
>>
>>compiler compliance is set to JDK 1.4.
> This is not enough. You need to change the source level (equivalent to
> -source option in javac). By default javac 1.4 doesn't support the
> assertion. You need to enable it with -source 1.4.
>
> So if you go to Preferences>Java>Compiler>Compliance and Classfiles>
> Uncheck use default compliance settings and put the values 1.4 for the
> source level, 1.4 for the target and error for assert as identifier.
>
> See my attached screenshot.
>
>>In 3.0 M5, I get an error that "The method assert(boolean) is
>>undefined...".
> Indeed, if assert is considered as an identifier, then this is
> understood as a method invocation.
>
>>In 2.1.2, this statement compiles without problem. A vendor has told me
>>that "the compiler will ignore the parentheses". However, clearly in
>>Eclipse 3.0 M5 does not. As far as I can tell, the the Java spec doesn't
>>support this syntax.
> The compiler doesn't care about parentheses around an expression. Yes,
> the JLS supports this syntax. It is a parentesized expression and the
> inner expression is a false literal.
>
>>Would someone more "in the know" comment and provide me some ammo for
>>dealing with this vendor? Or should a be filing a bug against 3.0 M5.
> With the settings I specified above, it should work.
> --
> Olivier
|
|
|
Powered by
FUDForum. Page generated in 0.04144 seconds