So I am attempting to create a class which uses a generic which extends an abstract class. Ex.
public abstract class Template<C extends Abstract>
However, I need to instantiate this 'C' within my class. I figured I might be able to do this:
C s = (C) ((C)new Object()).getClass().getConstructor(Known.class,AnotherKnown.class).newInstance(objectOfKnownType,objectOfAnotherKnownType);
So my question is basically whether this is possible. I feel like the
((C) new Object()).getClass()
might give me some problems.
What if i changed it to:
C a;
C s = (C) (a.getClass().getConstructor( ... ).newInstance( ... ));