Bug 206123 - [1.5][compiler] Generics, type compatibility rules
Summary: [1.5][compiler] Generics, type compatibility rules
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-12 05:49 EDT by David Akehurst CLA
Modified: 2008-12-09 07:08 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Akehurst CLA 2007-10-12 05:49:29 EDT
Build ID: I20070625-1500

Steps To Reproduce:
package test;

public class Test {
	void test() {
		B b = new C();
		Class<? extends B> cb = C.class;
		
		YYY<C> y = new XXX();
		Class<? extends YYY<C>> cy = XXX.class;
		
		YYY<? extends B> yb = new XXX();
		Class<? extends YYY<? extends B>> ybc = XXX.class;
		
		Class<? extends YYY> ybb = yb.getClass();
		Class<? extends YYY<?>> ybb2 = yb.getClass();
		Class<? extends YYY<? extends B>> ybb3 = yb.getClass();
	}
	
}

class Obj {}
class B extends Obj {}
class C extends B {}

class ZZZ<T extends Obj> {}

class YYY<T extends B> extends ZZZ<T> {}

class XXX extends YYY<C> {}

More information:
This code also does not work with my sun jdk.

I feel that there is something wrong, not quite sure what.
I think that assignments to 'ybb2' and 'ybb3' should work,
but they don't.
Comment 1 Philipe Mulet CLA 2008-12-08 12:40:10 EST
This is the right behavior. We conform to the JLS, and match javac behavior.
The problem comes from the raw type in wildcard upper bound capture coming from #getClass() invocations.

Added GenericTypeTest#test1425
Comment 2 Jerome Lanneluc CLA 2008-12-09 07:08:28 EST
Verified for 3.5M4