@Test public void shouldCreateBaseClassInstanceEvenWithSubclassNewInstance() throws NoSuchMethodException { final NonConstructableBaseClassWithField instance = NonConstructableBaseClassWithField.newInstance(NonConstructableBaseClassWithField.class, 5); assertThat(valueOf(instance.getFieldA()), is(5)); }
public static NonConstructableSubClass newInstance() throws NoSuchMethodException { return NonConstructableBaseClassWithField.newInstance(NonConstructableSubClass.class, 5); }
NonConstructableSubClass extends NonConstructableBaseClassWithField { public static NonConstructableSubClass newInstance() throws NoSuchMethodException { return NonConstructableBaseClassWithField.newInstance(NonConstructableSubClass.class, 5); } }
NonConstructableSubClass extends NonConstructableBaseClassWithField { public static NonConstructableSubClass newInstance() throws NoSuchMethodException { return NonConstructableBaseClassWithField.newInstance(NonConstructableSubClass.class, 5); } NonConstructableSubClass(int argA, int argB, int argC);  NonConstructableSubClass(int argA); }
NonConstructableSubClass extends NonConstructableBaseClassWithField { public static NonConstructableSubClass newInstance() throws NoSuchMethodException { return NonConstructableBaseClassWithField.newInstance(NonConstructableSubClass.class, 5); } NonConstructableSubClass(int argA, int argB, int argC);  NonConstructableSubClass(int argA); static NonConstructableSubClass newInstance(); static NonConstructableSubClass newInstance(int argA); static NonConstructableSubClass newInstance(int argA, int argB, int argC); int getFieldB(); int getFieldC(); }
NonConstructableSubClass extends NonConstructableBaseClassWithField { public static NonConstructableSubClass newInstance() throws NoSuchMethodException { return NonConstructableBaseClassWithField.newInstance(NonConstructableSubClass.class, 5); } NonConstructableSubClass(int argA, int argB, int argC);  NonConstructableSubClass(int argA); static NonConstructableSubClass newInstance(); static NonConstructableSubClass newInstance(int argA); static NonConstructableSubClass newInstance(int argA, int argB, int argC); int getFieldB(); int getFieldC();  }