Bug 119395 - [1.5][compiler] wildcard capture and unnecessary cast warning
Summary: [1.5][compiler] wildcard capture and unnecessary cast warning
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-06 07:01 EST by Noel Grandin CLA
Modified: 2006-02-28 07:06 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noel Grandin CLA 2005-12-06 07:01:39 EST
package noel.bugs;

import java.util.HashMap;
import java.util.Map;

/**
 * Without the cast on the relevant line, the SUN compiler (JDK1.5.0_06) will flag an error.
 * 
 * With the cast, Eclipse issues a warning that the cast is unnecessary. But as far as I can
 * tell, the cast really is necessary.
 */
public class EclipseGenericsBug {

	public static class DatabaseObject {
	}
	
	public static class ObjectFormUI<T extends DatabaseObject>  {
	}
	
	private static final Map<Class<? extends DatabaseObject>, Class<? extends ObjectFormUI>> uiMap 
		= new HashMap<Class<? extends DatabaseObject>, Class<? extends ObjectFormUI>>();
	
	private EclipseGenericsBug() {
	}
	
	public static <T extends DatabaseObject> Class<? extends ObjectFormUI<T>> getUI(Class<T> persistentClass) {
		// >>>>>> THIS LINE IS THE CRITICAL ONE <<<<<<<
		return (Class<? extends ObjectFormUI<T>>) uiMap.get(persistentClass);
		// >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<
	}

}
Comment 1 Philipe Mulet CLA 2006-02-28 07:04:49 EST
Works fine now. We resolved some extraneous unnecessary cast diagnostics in presence of unchecked conversions.

Added GenericTypeTest#test875
Comment 2 Philipe Mulet CLA 2006-02-28 07:06:00 EST
Also added GenericTypeTest#test876