Hi,
I want to use the concrete type of an outer class as the concrete type
of an inner class but if I do so, I get a warning ( in Eclipse, for some
sample code see below):
"The type parameter ConcreteType is hiding the type ConcreteType"
In other places in my code, in the class outerClass, the member "object"
of the InnerClass is not recognized as being of type ConcreteType, but
*only* as of type AbstractBaseClass, so I assume that warning actaully
means something ;-).
Is what I want possible and if so, what should be the right syntax?
Sample code:
public class OuterClass < ConcreteType extends AbstractBaseClass > {
// Next line gives the warning
class InnerClass < ConcreteType extends AbstractBaseClass > {
ConcreteType object;
}
}
TIA
Joost
Jaakko Kangasharju - 30 Nov 2005 11:11 GMT
> I want to use the concrete type of an outer class as the concrete type
> of an inner class but if I do so, I get a warning ( in Eclipse, for some
[quoted text clipped - 6 lines]
> }
> }
Shouldn't you just remove the type parameter from the inner class,
i.e.,
public class OuterClass < ConcreteType extends AbstractBaseClass > {
class InnerClass {
ConcreteType object;
}
}
Because if you want the types to be the same, obviously you need to
share the type. In your example you could use different classes as
parameters to OuterClass and InnerClass.

Signature
Jaakko Kangasharju, Helsinki Institute for Information Technology
Read excellent fantasy online
http://www.ethshar.com/thesprigganexperiment0.html
Joost Kraaijeveld - 30 Nov 2005 13:31 GMT
Hi Jaakko,
>>I want to use the concrete type of an outer class as the concrete type
>>of an inner class but if I do so, I get a warning ( in Eclipse, for some
[quoted text clipped - 19 lines]
> share the type. In your example you could use different classes as
> parameters to OuterClass and InnerClass.
Yes, that did it. Thanks for the answer.
Joost
Thomas Hawtin - 30 Nov 2005 12:40 GMT
Joost Kraaijeveld wrote::
> "The type parameter ConcreteType is hiding the type ConcreteType"
> public class OuterClass < ConcreteType extends AbstractBaseClass > {
> // Next line gives the warning
> class InnerClass < ConcreteType extends AbstractBaseClass > {
> ConcreteType object;
> }
> }
You are defining ConcreteType twice. If InnerClass were a static nested
class, then a different name would be preferable. As it is, you can just
write:
public class OuterClass <CONCRETE extends AbstractBaseClass> {
class InnerClass {
CONCRETE object;
}
}
class AbstractBaseClass {}
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/