Bug 87000 - [1.5] Generic method problem
Summary: [1.5] Generic method problem
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 M6   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-02 11:07 EST by Constantine Plotnikov CLA
Modified: 2005-03-03 16:12 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 Constantine Plotnikov CLA 2005-03-02 11:07:00 EST
I'm using eclipse-SDK-3.1M5a-win32.zip. I have encountered strange problem with
using generics. When generic class has a generic method then the method loses
genericity if generic class is used as non generic. In sample below m1 does not
compile and m2 compiles.

Note: Javac has the same problem. So I'm not sure if this is a bug or feature.

The following are shown in Problems view:

Severity	Description	Resource	In Folder	Location	Creation 
1	Type safety: The method willBe(Class) belongs to the raw type Test.B.
References to generic type Test.B<C> should be parameterized	Test.java
test/test	line 16	
2	Type mismatch: cannot convert from Test.I1 to Test.I2	Test.java	test/test	line 16	

--------- begin of test/Test.java --------------

package test;

public class Test {
	static class B<C> {
		public <T extends I1> T willBe(Class<T> c) {
			return (T)null;
		}
	}
	interface I1  {
	}
	interface I2  extends I1 {
	}
	
	public static void m1(String[] args) {
		B b = new B();
		I2 v = b.willBe(I2.class);
	}
	public static void m2(String[] args) {
		B<Void> b = new B<Void>();
		I2 v = b.willBe(I2.class);
	}

}
----------- end of test/Test.java ------------
Comment 1 Philipe Mulet CLA 2005-03-03 02:35:20 EST
Only static generic methods remain generic when used on a raw type.
Comment 2 Philipe Mulet CLA 2005-03-03 16:12:20 EST
Please refer to JLS[3] 4.8.
Closing