Community
Participate
Working Groups
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2) Build Identifier: M20090917-0800 See attached test cases Reproducible: Always Steps to Reproduce: 1. Compile test case. You can see 3 false warnings if the compiler setting "Redundant null check" is on.
Created attachment 152308 [details] Contains test case
(In reply to comment #1) > Created an attachment (id=152308) [details] > Contains test case In your test case, the redundant null check warning on the if statement after the assert statement is perfectly ok. If "args" is null, the assert statement should throw an AssertException. The if statement is only reached in case "args" is not null, hence the check is indeed redundant! Please correct me if i'm wrong.
(In reply to comment #2) This is true only if assertions are enabled, but I have to guarantee a deterministic behavior of the method test2 also in the case of disabled assertions (In productive environments they are mostly disabled). Asserts can prove the presence of a specific error condition, but they can never furnish proof for the absence of specific errors. But considering that this question is already discussed lengthy in Bug 234549, Bug 198044, Bug 173725 please ignore test2.
Created attachment 152575 [details] proposed fix v0.5 + regression test Regarding the wrong warning in test1 above, fix for unchecked exceptions was done in bug 130359, but for checked exceptions we were still discarding the null info from inside the try loop. Because of this the wrong warning was raised. This fix includes the null info of the try block.
I prefer the behavior with the patch. +1.
Released for 3.6M4. Regression tests added in: org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0535_try_finally org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0567_try_catch_checked_exception org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0568_try_catch_checked_exception
Verified for 3.6M4 using Build id: I20091207-1800