Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to assert?
How to assert? [message #202957] Mon, 09 May 2005 10:35 Go to next message
Eclipse UserFriend
Whenever I try to use assertions I always only get compile errors:
e.g.:
Severity Description Resource In Folder Location Creation Time
2 Syntax error on token "assert", assert expected <java file name,
package, etc. here>

???

Default JRE is a 1.4.2 SDK, Compiler compliance level is set to 1.4.

What else does one need to allow assertions in the source code? Why is
this not working?

This is on eclipse 3.0.1 on WinXP.

Michael
assertions don't compile - what am I missing? [message #203265 is a reply to message #202957] Thu, 12 May 2005 06:18 Go to previous messageGo to next message
Eclipse UserFriend
Folks - is this such a complicated question that I don't get an answer
here?

Isn't ANYBODY using assertions? If so, did that person have to enable or
configure anything special to get it working?
I can't believe that I should be the only one, where eclipse refuses to
accept assertions. After all that's a standard Java keyword...

I am completely puzzled why my eclipse 3.0.1 refuses to compile event
the simplest assertion statements, like "assert false;" with an error
message as listed in my original append.

Any help or hint would be appreciated!

Michael



"Michael Moser" <mmo@zurich.ibm.com> wrote in message
news:d5nsuj$73b$1@news.eclipse.org...
> Whenever I try to use assertions I always only get compile errors:
> e.g.:
> Severity Description Resource In Folder Location Creation Time
> 2 Syntax error on token "assert", assert expected <java file name,
> package, etc. here>
>
> ???
>
> Default JRE is a 1.4.2 SDK, Compiler compliance level is set to 1.4.
>
> What else does one need to allow assertions in the source code? Why is
> this not working?
>
> This is on eclipse 3.0.1 on WinXP.
>
> Michael
Re: How to assert? [message #203287 is a reply to message #202957] Thu, 12 May 2005 07:07 Go to previous messageGo to next message
Eclipse UserFriend
you also need to set source and classfile version to 1.4 (default is
1.2/1.3).

-tom

Michael Moser wrote:
> Whenever I try to use assertions I always only get compile errors:
> e.g.:
> Severity Description Resource In Folder Location Creation Time
> 2 Syntax error on token "assert", assert expected <java file name,
> package, etc. here>
>
> ???
>
> Default JRE is a 1.4.2 SDK, Compiler compliance level is set to 1.4.
>
> What else does one need to allow assertions in the source code? Why is
> this not working?
>
> This is on eclipse 3.0.1 on WinXP.
>
> Michael
Re: assertions don't compile - what am I missing? [message #203327 is a reply to message #203265] Thu, 12 May 2005 13:23 Go to previous messageGo to next message
Eclipse UserFriend
i held off replying because it seemed too trivial. I was waiting for your "Found it, never
mind" message. :)

just set the source and classfile compliance to 1.4 and you're done.

/adam

Michael Moser wrote:
> Folks - is this such a complicated question that I don't get an answer
> here?
>
> Isn't ANYBODY using assertions? If so, did that person have to enable or
> configure anything special to get it working?
> I can't believe that I should be the only one, where eclipse refuses to
> accept assertions. After all that's a standard Java keyword...
>
> I am completely puzzled why my eclipse 3.0.1 refuses to compile event
> the simplest assertion statements, like "assert false;" with an error
> message as listed in my original append.
>
> Any help or hint would be appreciated!
>
> Michael
>
>
>
> "Michael Moser" <mmo@zurich.ibm.com> wrote in message
> news:d5nsuj$73b$1@news.eclipse.org...
>
>> Whenever I try to use assertions I always only get compile errors:
>> e.g.:
>> Severity Description Resource In Folder Location Creation Time
>> 2 Syntax error on token "assert", assert expected <java file name,
>> package, etc. here>
>>
>> ???
>>
>> Default JRE is a 1.4.2 SDK, Compiler compliance level is set to 1.4.
>>
>> What else does one need to allow assertions in the source code? Why is
>> this not working?
>>
>> This is on eclipse 3.0.1 on WinXP.
>>
>> Michael
>
>
Re: How to assert? [message #203380 is a reply to message #203287] Fri, 13 May 2005 04:27 Go to previous messageGo to next message
Eclipse UserFriend
Bingo - THAT was the point! I had selected "Compiler compliance level
1.4" but had also checked the "use default compliance settings" checkbox
(and then not paid any further attention to the grayed out settings that
indicate that "Compiler compliance level 1.4" actually means class 1.2
and source 1.3 compatibility and not 1.4 as one (or at least me) would
expect). A bit misleading...

Adjusting that manually - as suggested - did the trick!

Thanks and sorry for this "stupid" question.
Michael


"Tom Eicher" <eclipse@tom.eicher.name> wrote in message
news:d5vdtm$qdn$1@news.eclipse.org...
> you also need to set source and classfile version to 1.4 (default is
> 1.2/1.3).
>
> -tom
>
> Michael Moser wrote:
>> Whenever I try to use assertions I always only get compile errors:
>> e.g.:
>> Severity Description Resource In Folder Location Creation Time
>> 2 Syntax error on token "assert", assert expected <java file name,
>> package, etc. here>
>>
>> ???
>>
>> Default JRE is a 1.4.2 SDK, Compiler compliance level is set to 1.4.
>>
>> What else does one need to allow assertions in the source code? Why
>> is this not working?
>>
>> This is on eclipse 3.0.1 on WinXP.
>>
>> Michael
Re: assertions don't compile - what am I missing? [message #203388 is a reply to message #203327] Fri, 13 May 2005 04:28 Go to previous message
Eclipse UserFriend
Fixed - see my other append. Thanks nevertheless!
Michael

"Adam Kiezun" <akiezun@mit.edu> wrote in message
news:4283910F.60407@mit.edu...
>i held off replying because it seemed too trivial. I was waiting for
>your "Found it, never mind" message. :)
>
> just set the source and classfile compliance to 1.4 and you're done.
>
> /adam
>
> Michael Moser wrote:
>> Folks - is this such a complicated question that I don't get an
>> answer here?
>>
>> Isn't ANYBODY using assertions? If so, did that person have to enable
>> or configure anything special to get it working?
>> I can't believe that I should be the only one, where eclipse refuses
>> to accept assertions. After all that's a standard Java keyword...
>>
>> I am completely puzzled why my eclipse 3.0.1 refuses to compile event
>> the simplest assertion statements, like "assert false;" with an error
>> message as listed in my original append.
>>
>> Any help or hint would be appreciated!
>>
>> Michael
>>
>>
>>
>> "Michael Moser" <mmo@zurich.ibm.com> wrote in message
>> news:d5nsuj$73b$1@news.eclipse.org...
>>
>>> Whenever I try to use assertions I always only get compile errors:
>>> e.g.:
>>> Severity Description Resource In Folder Location Creation Time
>>> 2 Syntax error on token "assert", assert expected <java file name,
>>> package, etc. here>
>>>
>>> ???
>>>
>>> Default JRE is a 1.4.2 SDK, Compiler compliance level is set to 1.4.
>>>
>>> What else does one need to allow assertions in the source code? Why
>>> is this not working?
>>>
>>> This is on eclipse 3.0.1 on WinXP.
>>>
>>> Michael
>>
Previous Topic:Programatically disabling the Java Builder
Next Topic:How to find a Java element?
Goto Forum:
  


Current Time: Sun Jun 08 13:02:26 EDT 2025

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

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

Back to the top