@Test public void testMethodFallback() throws IOException { final Hack.HackedMethod1<Integer, Simple, IOException, Unchecked, Unchecked, Void> foo_wrong = Hack.into(Simple.class).method("foo").throwing(IOException.class).returning(int.class).fallbackReturning(-1).withParam(Void.class); assertTrue(foo_wrong.isAbsent()); assertEquals(-1, (int) foo_wrong.invoke().on(new Simple(0))); final Hack.HackedMethod1<Integer, Simple, Unchecked, Unchecked, Unchecked, Void> foo_absent = Hack.into(Simple.class).method("foo").returning(int.class).fallbackReturning(-1).withParam(Void.class); assertTrue(foo_absent.isAbsent()); assertEquals(-1, (int) foo_absent.invoke().on(new Simple(0))); }
public static HackedObject into(final Object source) { return new HackedMirrorObject(source); }
Hack { public static HackedObject into(final Object source) { return new HackedMirrorObject(source); } }
Hack { public static HackedObject into(final Object source) { return new HackedMirrorObject(source); } private  Hack(); }
Hack { public static HackedObject into(final Object source) { return new HackedMirrorObject(source); } private  Hack(); static HackedObject into(final Object source); static R mirrorStaticMethod(final String tag, final R fallback, final Object... args); static void verifyAllMirrorsIn(final Class<?> enclosing); static HackedClass<T> into(final @NonNull Class<T> clazz); static HackedClass<T> into(final String class_name); @SuppressWarnings("unchecked") static Hack.HackedClass<C> onlyIf(final boolean condition, final Hacking<Hack.HackedClass<C>> hacking); static ConditionalHack onlyIf(final boolean condition); static AssertionFailureHandler setAssertionFailureHandler(final @Nullable AssertionFailureHandler handler); }
Hack { public static HackedObject into(final Object source) { return new HackedMirrorObject(source); } private  Hack(); static HackedObject into(final Object source); static R mirrorStaticMethod(final String tag, final R fallback, final Object... args); static void verifyAllMirrorsIn(final Class<?> enclosing); static HackedClass<T> into(final @NonNull Class<T> clazz); static HackedClass<T> into(final String class_name); @SuppressWarnings("unchecked") static Hack.HackedClass<C> onlyIf(final boolean condition, final Hacking<Hack.HackedClass<C>> hacking); static ConditionalHack onlyIf(final boolean condition); static AssertionFailureHandler setAssertionFailureHandler(final @Nullable AssertionFailureHandler handler); static Class<?> ANY_TYPE; }