Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » assert, 3.0 M5
assert, 3.0 M5 [message #124534] Thu, 04 December 2003 13:04 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 (1/1) [message #124578 is a reply to message #124534] Thu, 04 December 2003 15:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomann.ca.ibm.comNOSPAM

  • Attachment: settings.png
    (Size: 16.26KB, Downloaded 98 times)
Re: assert, 3.0 M5 - settings.png (0/1) [message #124590 is a reply to message #124566] Thu, 04 December 2003 15:46 Go to previous message
Eclipse UserFriend
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
Previous Topic:Source format
Next Topic:Project Nature change notification
Goto Forum:
  


Current Time: Wed Jul 23 18:06:19 EDT 2025

Powered by FUDForum. Page generated in 0.04144 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top