Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334689

Summary: [1.5][compiler] Compiler gives an unchecked cast warning for cast involving wildcards where Sun's compiler gives an error
Product: [Eclipse Project] JDT Reporter: Isaac Pacht <isaacp3>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.5.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Isaac Pacht CLA 2011-01-18 14:24:57 EST
Build Identifier: M20100211-1343

The Eclipse compiler reports a warning ("Type safety: Unchecked cast from ArrayList<Interface> to ArrayList<? extends Implementation>") when compiling the code shown below.  The Sun and IBM compilers report an error in this case.  It would seem that it is correct to give an error, since the source type is not a raw type, this is not a valid unchecked conversion.

Reproducible: Always

Steps to Reproduce:
1. Create a java project

2. Create a class with the following contents

import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Object x = (ArrayList<? extends Implementation>) new ArrayList<Interface>();
	}
}

interface Interface {
}

class Implementation implements Interface {
}


3. Note that the compiler reports a warning on the cast, not an error
Comment 1 Olivier Thomann CLA 2011-01-18 14:28:59 EST
Srikanth, please investigate.
Comment 2 Eclipse Genie CLA 2018-11-07 18:40:27 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.