I have something like this going on in my Java program:
void f(Object o) {
g(o);
}
<T extends MySuperClass & MyInterface> void g(T x) {
...;
}
How can I cast o so that this works? There seems to be no way to specify both a base class and an interface in variable declarations without using generics. I don't think generics will work here, because o is being created dynamically using reflection, so its actual class is not known at compile time.
(Yeah, I know this is a weird thing to want to do. But I actually do need functionality from both the superclass and the interface. I guess I could do all of the type checking at runtime with instanceof, but that just seems so Java 1.4...)