It's my lovable dumb self again.
So, I got an abstract parent class that has two protected constructors:
- one that takes a
DataInputStreamand aboolean - one that takes a
String
and a bunch of implementing child classes that extend this abstract class.
Each child class uses the constructor that takes a String, like so:
public ImplChildClass(String one, String two) {
super(one);
this.two = two;
}
All super standard. Now, I want to be able to construct an implementing class using the abstract classes constructor that takes the DataInputStream and boolean arguments. Google tells me I should be able to do
Constructor<? extends AbstractParentClass> constructor = ImplChildClass.getClass().getDeclaredConstructor(DataInputStream.class, boolean.class);
constructor.setAccessible(true);
constructor.newInstance(dataInputStream, true);
but I'm getting java.lang.NoSuchMethodException when I do that. So, what am I doing wrong?