Bug 264774 - assert(false); can be compiled and run, but no AssertFailedException appears during execution
Summary: assert(false); can be compiled and run, but no AssertFailedException appears ...
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-12 16:02 EST by jenny li CLA
Modified: 2010-01-25 01:09 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jenny li CLA 2009-02-12 16:02:46 EST
Build ID: M20080221-1800

Steps To Reproduce:
1.Add "assert(false);" anywhere in a program.
2.The code with this line is compiled properly without an error or warning.
3.Execution of this line of code using "run junit" doesn't throw AssertFailedException.



More information:
"assert" was highlighted as a keyword during code editing, but it seems to be treated as Junit assert during execution. "assert(false);" shouldn't pass compilation at the first place.
Comment 1 Darin Wright CLA 2009-02-12 21:19:26 EST
Moving to JDT
Comment 2 Olivier Thomann CLA 2009-02-13 08:49:33 EST
Are you running with the VM argument "-ea" ?
Assertion are disabled by default.

The JUnit assertion check would be assertTrue(false);

When you are using an assert statement, you need to enable assertion at runtime.
Comment 3 Olivier Thomann CLA 2009-12-15 10:35:44 EST
Closing as INVALID.
-ea needs to be added as a VM argument as assertions are disabled by default.
Comment 4 Srikanth Sankaran CLA 2010-01-25 01:09:44 EST
Verified for 3.6M5