Bug 308245

Summary: Valid code fails to compile in 3.6
Product: [Eclipse Project] JDT Reporter: Michael Valenta <Michael.Valenta>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, jarthana, martinae, Olivier_Thomann, pwebster, remy.suen
Version: 3.5   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression test none

Description Michael Valenta CLA 2010-04-06 13:36:24 EDT
I get the compile error "Missing code implementation in the compiler" for the following class. it appears that the use of a final variable in the if (a ? b : c) is causing problems. I am using build I20100312-1448. The code does compile properly when using 3.4.2.

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;


public class Test {

	public static void main(String[] args) {
		final List yourList = new ArrayList();
		final List myList = new ArrayList();
		new Comparator() {
			public int compare(Object o1, Object o2) {
				compare(yourList != null ? yourList : myList, yourList);
				return 0;
			}
		};
	}
}
Comment 1 Olivier Thomann CLA 2010-04-06 14:31:58 EDT
This is a consequence of the null analysis changes.
yourList is seen as always not null. so yourList != null is always true. So the generation of myList in the conditional expression is tagged as FAKE_USED and UNREACHABLE.
Once this is done, the emulated synthetic field is not created for myList and leads to the error you saw.
I have a fix under testing.
Thanks for the report.
Comment 2 Michael Valenta CLA 2010-04-06 16:35:15 EDT
In the original code I saw this in, yourList may have been null as it was the result of a method call so you may want to verify that case as well.
Comment 3 Olivier Thomann CLA 2010-04-07 08:47:00 EDT
Created attachment 164037 [details]
Proposed fix + regression test
Comment 4 Olivier Thomann CLA 2010-04-07 08:47:39 EDT
Released for 3.6M7.
org.eclipse.jdt.core.tests.compiler.regression.InnerEmulationTest#test173
org.eclipse.jdt.core.tests.compiler.regression.InnerEmulationTest#test174
Comment 5 Olivier Thomann CLA 2010-04-14 18:03:16 EDT
*** Bug 309237 has been marked as a duplicate of this bug. ***
Comment 6 Ayushman Jain CLA 2010-04-26 10:02:46 EDT
verified for 3.6M7 using build I20100424-2000.
Comment 7 Jay Arthanareeswaran CLA 2010-04-26 10:53:45 EDT
Verified.