Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334689 - [1.5][compiler] Compiler gives an unchecked cast warning for cast involving wildcards where Sun's compiler gives an error
Summary: [1.5][compiler] Compiler gives an unchecked cast warning for cast involving w...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-18 14:24 EST by Isaac Pacht CLA
Modified: 2018-11-07 18:40 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.