PrivateAccess { public static <T> T callDefaultConstructor(Class<T> klass) throws Throwable{ if(klass == null){ throw new IllegalArgumentException("No specified class"); } Constructor<T> constructor; try { constructor = klass.getDeclaredConstructor(); } catch (NoSuchMethodException e) { String message = "Default constructor does not exist anymore"; if(shouldNotFailTest){ throw new FalsePositiveException(message); } else { throw new IllegalArgumentException(message); } } assert constructor != null; constructor.setAccessible(true); try { return constructor.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new FalsePositiveException("Failed to call the default constructor of "+klass.getName()+": "+e.toString()); } catch (InvocationTargetException e) { throw e.getTargetException(); } }  static void setShouldNotFailTest(boolean b); static void setVariable(Class<?> klass, T instance, String fieldName, Object value); static Object callDefaultConstructorOfTheClassUnderTest(); static T callDefaultConstructor(Class<T> klass); static Object callMethod(Class<T> klass, T instance, String methodName, Object[] inputs, Class<?>[] types); static Object callMethod(Class<T> klass, T instance, String methodName); static Object callMethod(Class<T> klass, T instance, String methodName, Object input, Class<?> type); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3,Object i4, Class<?> t4); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3,Object i4, Class<?> t4
            ,Object i5, Class<?> t5); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3,Object i4, Class<?> t4
            ,Object i5, Class<?> t5,Object i6, Class<?> t6); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3,Object i4, Class<?> t4
            ,Object i5, Class<?> t5,Object i6, Class<?> t6,Object i7, Class<?> t7); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3,Object i4, Class<?> t4
            ,Object i5, Class<?> t5,Object i6, Class<?> t6,Object i7, Class<?> t7,Object i8, Class<?> t8); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0, Class<?> t0, Object i1, Class<?> t1, Object i2, Class<?> t2,Object i3, Class<?> t3,Object i4, Class<?> t4
            ,Object i5, Class<?> t5,Object i6, Class<?> t6,Object i7, Class<?> t7,Object i8, Class<?> t8,Object i9, Class<?> t9); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13,Object i14, Class<?> t14
            ); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13,Object i14, Class<?> t14
            , Object i15, Class<?> t15); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13,Object i14, Class<?> t14
            , Object i15, Class<?> t15,Object i16, Class<?> t16); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13,Object i14, Class<?> t14
            , Object i15, Class<?> t15,Object i16, Class<?> t16,Object i17, Class<?> t17); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13,Object i14, Class<?> t14
            , Object i15, Class<?> t15,Object i16, Class<?> t16,Object i17, Class<?> t17,Object i18, Class<?> t18); static Object callMethod(Class<T> klass, T instance, String methodName
            , Object i0,  Class<?> t0, Object i1,  Class<?> t1, Object i2,  Class<?> t2, Object i3,  Class<?> t3, Object i4,  Class<?> t4
            , Object i5,  Class<?> t5, Object i6,  Class<?> t6, Object i7,  Class<?> t7, Object i8,  Class<?> t8, Object i9,  Class<?> t9
            , Object i10, Class<?> t10,Object i11, Class<?> t11,Object i12, Class<?> t12,Object i13, Class<?> t13,Object i14, Class<?> t14
            , Object i15, Class<?> t15,Object i16, Class<?> t16,Object i17, Class<?> t17,Object i18, Class<?> t18,Object i19, Class<?> t19); static Method getCallMethod(int nParameters);  }
@Test public void testPrivateConstructor() throws Throwable{ FooConstructor.counter = 0; PrivateAccess.callDefaultConstructor(FooConstructor.class); assertTrue(FooConstructor.counter > 0); }