Community
Participate
Working Groups
I don't know who is at fault here but the code below is fine with Sun javac (1.5.0.16 and 1.6.0.10) but no go in JDT on I20081029-1823. public class Test { protected void transform() { final float error; assert false : error; } } ECJ complains that error is uninitialized. I think javac is wrong here since the JVM will try to create a throwable with 'error' in the message somewhere but will fail because it is not initialized. But what do I know about Java compilers? :)
Scratch the above, I was trying to make a more compact test case and failed. Try this one. public class Test { protected void transform(boolean srcPts) { final float error; assert !(srcPts && (error = maxError()) > 0) : error; } private float maxError() { return 0; } }
This is indeed our bug (for comment 1). The code should essentially be the same as: float foo1(boolean srcPts) { final float error2; if (!(srcPts && (error2 = maxError()) > 0)) { } else { return error2; } return 0; } where ECJ correctly accepts the code as correct.
Created attachment 119813 [details] Proposed patch
Added AssertionTest#test017
Released for 3.5M4. Fixed
Verified for 3.5M4 using I20081211-0100