2 Answers
2

You are able to inherit from a supertype that has generic type parameters. For instance:

public class MyList<T> extends AbstractList<T>

(or even give the parameters bounds, e.g.):

public class MyStringList extends AbstractList<String>

You are not able to define a class that has a wildcard supertype. Such a concept doesn't make any sense in Java (and I'm not convinced it has much value in the abstract). In your MonitoredDevice example, I'm not even sure what functionality you expect there.

Because of erasure this is simply not possible at a fundamental level of the way Java works. Each class must have a superclass - what is the superclass of MonitoredDevice? What methods are available on a MonitoredDevice object? You wouldn't be able to call any inherited methods on this class as the compiler could not guarantee such methods exist, nor could the bytecode represent such calls.

I suspect that what you are trying to do could be better achieved with dynamic proxies.

Edit: OK, after reading the article fully I can see what the motivation behind such a declaration would be. But after reading the article fully, you also realise that this isn't supported by Java at present. The fundamental reason why is due to erasure; such a technique would never be possible under the current mechanics, and the article goes into a lot more detail of what specifically prevents this from working.

It makes sense to me. I would simply like to be able to dynamically specify the parent type of the class; and it seems as though I should be able to do it using generics. But, I am by no means an advanced Java programmer and do not know the low-level details of the Java language. I will look into dynamic proxies. Thanks. EDIT: Wrote this comment before your last edit. ;)
–
Stephen WatkinsJan 4 '10 at 16:44

From that error message it sounds like you're trying to extend from the type parameter itself, which you cannot do because the type is erased at runtime. If this isn't what you're trying to do, please post your code.