Bug 283306 - [1.5][compiler] Can't compile generics
Summary: [1.5][compiler] Can't compile generics
Status: VERIFIED DUPLICATE of bug 277643
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-13 08:28 EDT by droida38 CLA
Modified: 2009-08-04 04:31 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description droida38 CLA 2009-07-13 08:28:53 EDT
Build ID: Build id: 20090619-0625

Steps To Reproduce:
Eclipse 3.4, Netbeans 6.7, and javac (1.6) will compile this, but Eclipse 3.5 Galileo wont.


public class Test {
	
	public WWorkflow<? extends Workflow> getMainWorkflow(){
		return get(WWorkflow.class, null);
	}
	
	public <T, W extends WrapperLogic<? super T>> W get(Class<W> wrapperClass, T entity) {
		return null;
	}
}

public class Workflow {
}

public class WWorkflow<T extends Workflow> extends WrapperLogic<T> {
}

public abstract class WrapperLogic<WRAPPED> {
	private WRAPPED wrapped;
}

More information:
Comment 1 Stephan Herrmann CLA 2009-07-13 12:04:49 EDT
(In reply to comment #0)

Some observations: 
Deleting "super T" from the signature of get() makes this code 
fragment compilable.

The problem is initially caused by the fact that WWorkflow.class
has a raw type: it doesn't specify the parameter <T> of WWorkflow.
This seems to put the compiler into a different mode of type checking
(haven't looked into sources).

Compare this:

  class Clazz<T> { }

  WWorkflow<? extends Workflow> getMainWorkflow2(){
    return get(new Clazz<WWorkflow<Workflow>>(), null);
  }

  public <T, W extends WrapperLogic<? super T>> W get(Clazz<W> desc, T entity) {
    return null;
  }

The only difference is: using Clazz instead of Class we can create a value
of the exact deeply parameterized type. -> Compiles fine even with
the "super T" part.
Comment 2 Kent Johnson CLA 2009-07-20 12:37:33 EDT

*** This bug has been marked as a duplicate of bug 277643 ***
Comment 3 Srikanth Sankaran CLA 2009-08-04 04:31:28 EDT
Verified for 3.6M1