Bug 133803 - [1.5][compiler] Illegal cast from bounded wildcard allowed
Summary: [1.5][compiler] Illegal cast from bounded wildcard allowed
Status: VERIFIED DUPLICATE of bug 120088
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-29 05:07 EST by Markus Keller CLA
Modified: 2007-10-29 06:17 EDT (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 Markus Keller CLA 2006-03-29 05:07:06 EST
HEAD, followup to bug 131935.

This CU compiles with a (correct) error in javac 1.5 and 1.6, but Eclipse accepts it without error:

import java.lang.ref.*;

class Soft extends SoftReference<String> {
    Soft() { super(null); }
}

class Bug {
    void m(Reference<? extends Number> remove) {
        Soft soft= (Soft) remove;
    }
}

javac 1.6.0-beta2
C:\e\w\runtime-workspace\zz1.5\src\xy\Bug.java:11: inconvertible types
found   : java.lang.ref.Reference<capture#939 of ? extends java.lang.Number>
required: xy.Soft
        Soft soft= (Soft) remove;
                          ^
1 error
Comment 1 Philipe Mulet CLA 2006-03-31 08:17:12 EST
Strictly speaking our behavior is legite, since Reference<capture-of ? extends Number> is assimilated to Reference<U> (U being a fresh new type variable), and it is not provably distinct by the rules of JLS 4.5.

Comment 2 Philipe Mulet CLA 2006-03-31 08:19:39 EST
Added GenericTypeTest#test0959.
Comment 3 Philipe Mulet CLA 2006-03-31 08:23:51 EST

*** This bug has been marked as a duplicate of 120088 ***
Comment 4 Philipe Mulet CLA 2007-10-10 11:50:14 EDT
GenericTypeTest#test0959 got enabled.
Comment 5 Maxime Daniel CLA 2007-10-29 06:17:53 EDT
Verified for 3.4 M3 using build I20071029-0010.