Strange Generics Error

I'm seeing some strange behavior in IDEA, and I'm not sure if the problem is with IDEA, the Java compiler or both. This code compiles fine in IDEA and from the JDK using ant. It shows as an error in IDEA and Eclipse and won't compile in Eclipse. I don't know enough about generics to know who is right.

Of course, I know one answer is to just don't do this... but this is based on a problem in a third-party library. I don't have control over it.

abstract class GrandParent { public abstract void paint(T object); } class Parent extends GrandParent { @Override public void paint(T component) { } } class Child1 extends Parent]]> {
}

// this highlights as an error in IDEA, but compiles fine:
class Child2 extends Parent {
}

The error shows on Child2. Idea thinks the class should be abstract or implement the method public void paint(Object object).

Any thoughts?

3 comments
Comment actions Permalink

Idea's generic support is pretty good and it's based on actually reading
what the specs say - I, on the other hand, haven't read the specs, but
intuitively your code should compile since T is constrained at the
Parent level.

I would say that the fact it doesn't compile in Idea is either an Idea
bug or a bug in the generics spec.

R

0
Comment actions Permalink

Yep, this is IDEA bug.

0
Comment actions Permalink

...that is fixed in Selena branch.

0

Please sign in to leave a comment.