Assume I obtained a Class object by loading a class dynamically using Class.forName("Foo"). Foo is abstract in this case, so I cannot call newInstance() on it. (How) is it possible to declare a concrete subclass of Foo?
Assume I obtained a Class object by loading a class dynamically using Class.forName(Foo) .
Share
You declare it as not abstract e.g.
In short, just because you loaded the class dynamically doesn’t mean the rules change 😉
If you don’t have Foo available at compile time, you still need to have a sub-class of this class which is concrete to create it. To do this you have two options.
I suspect the first option is what you need because unless there is a subclass provided for you, you still need to generate the code for the abstract methods.