Bug 239439 - [1.5][compiler] Behavior change for binding for parameterized type
Summary: [1.5][compiler] Behavior change for binding for parameterized type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 241399 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-03 09:44 EDT by Alexandre FAU CLA
Modified: 2008-08-28 15:50 EDT (History)
5 users (show)

See Also:


Attachments
Proposed fix + regression tests for HEAD (6.31 KB, patch)
2008-07-23 13:43 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre FAU CLA 2008-07-03 09:44:31 EDT
Such code :
	XXList<Class> statements = null;
	
	public List<Class> compute() {
		statements = new ArrayList<Class>();		
		return statements;
	}
Don't compile, but with Eclipse 3.3 you can resolve the binding for "ArrayList<Class>". In 3.4 it's no more possible.
Comment 1 Alexandre FAU CLA 2008-07-03 09:47:01 EDT
How to reproduce :
Paste that code :

package tests.generics;

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

public class CapitalizeTest {
	
	XXList<Class> statements = null;
	
	public List<Class> compute() {
		statements = new ArrayList<Class>();		
		return statements;
	}
	
}
(the code does not compile but it's what I want)

Open ASTViews and select "ArrayList<Class>".
Look for the binding value of the "ParametrizedType".
With 3.3.1.1 you have a value and with 3.4 you have "null".
Comment 2 Olivier Thomann CLA 2008-07-08 12:17:59 EDT
Did you try to set the binding recovery ?
Comment 3 Philipe Mulet CLA 2008-07-08 12:26:35 EDT
3.3 did leak some "recovered" type bindings by mistake when binding recovery wasn't activated. This got addressed during 3.4, along with providing much more resilience near missing types. 

So in 3.4 you should not see recovered bindings, when recovery is off; and when it is on, you should find many more bindings available.
Comment 4 Alexandre FAU CLA 2008-07-09 08:12:25 EDT
Hello,

Ok, set recover binding to true solve that case.
But in a case like this :

public class AbstractClass {
        XXList<Class> statements = null;
}

public class CapitalizeTest extends AbstractClass {
        public List<Class> compute() {
                statements = new ArrayList<Class>();            
                return statements;
        }
}

The binding for "ArrayList<Class>" is not resolved ...
(of course my use case is more complexe : a plugin that apply many ast transformation on CompilationUnit)

Comment 5 Olivier Thomann CLA 2008-07-21 14:24:12 EDT
Do you have the import for java.util.ArrayList in your last example as you do in the first one? or it is not there on purpose ?
Comment 6 Alexandre FAU CLA 2008-07-23 12:27:43 EDT
The import for java.util.ArrayList is present in my sample.
I just forget to write it.
Comment 7 Olivier Thomann CLA 2008-07-23 13:25:38 EDT
The problem doesn't directly come from the DOM support.
The compiler doesn't even try to resolve the right hand side of the assignment as the resolution of the left hand side (statements) fails with an AbortMethod exception through an invalid type error report. The id of the type is not known so it goes into the "needImplementation(...)" call that aborts the type resolution.
Updating title accordingly.
Once the compiler can fully resolve the assignment, the DOM binding should be able to reflect this.
Comment 8 Olivier Thomann CLA 2008-07-23 13:42:30 EDT
Looking at the issue, I don't see how setting the binding recovery fixed the test case in comment 1.
I think I have a fix for this one.
Comment 9 Olivier Thomann CLA 2008-07-23 13:43:31 EDT
Created attachment 108236 [details]
Proposed fix + regression tests for HEAD

This might deserve a backport to 3.4.1.
Comment 10 Kent Johnson CLA 2008-07-23 13:58:18 EDT
The change looks straight forward to me.
Comment 11 Olivier Thomann CLA 2008-07-24 08:42:33 EDT
*** Bug 241399 has been marked as a duplicate of this bug. ***
Comment 12 Olivier Thomann CLA 2008-07-24 08:50:11 EDT
Released for 3.5M1.
Philippe, this should be a candidate for 3.4.1.
Comment 13 Olivier Thomann CLA 2008-07-24 08:53:19 EDT
Added regression tests:
org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0316
org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0317
Comment 14 Olivier Thomann CLA 2008-07-24 09:04:07 EDT
Added regression test org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1367
Comment 15 Philipe Mulet CLA 2008-07-25 10:29:16 EDT
Ok for 3.4.1.
Comment 16 Olivier Thomann CLA 2008-07-28 10:30:50 EDT
Backported to 3.4 maintenance stream.
Regression tests:
org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0315
org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0316
org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1367
Comment 17 Kent Johnson CLA 2008-08-06 12:41:34 EDT
Verified for 3.5M1 using I20080805-1307
Comment 18 Jerome Lanneluc CLA 2008-08-28 15:50:03 EDT
Verified for 3.4.1 using M20080827-2000