Bug 264774

Summary: assert(false); can be compiled and run, but no AssertFailedException appears during execution
Product: [Eclipse Project] JDT Reporter: jenny li <jjli>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: darin.eclipse, jjli, Olivier_Thomann, srikanth_sankaran
Version: 3.3.2   
Target Milestone: 3.6 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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