call text: int result = new Test(instance).invoke(); class: public class GeneratedEvaluationClass { private Object instance; public GeneratedEvaluationClass(Object instance) { this.instance = instance; } public static int callMethod1(Object object, int arg) { try { Class klass = Class.forName("WithReflectionAccess"); java.lang.reflect.Method member = null; int interfaceNumber = -1; Class[] interfaces = null; while (member == null) { try { member = klass.getDeclaredMethod("method", int.class); } catch (ReflectiveOperationException e) { if (interfaceNumber == -1) { interfaces = klass.getInterfaces(); interfaceNumber = 0; } if (interfaceNumber < interfaces.length) { klass = interfaces[interfaceNumber]; interfaceNumber += 1; } else { klass = klass.getSuperclass(); if (klass == null) throw e; interfaceNumber = -1; } } } member.setAccessible(true); return (int) member.invoke(object, arg); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } public int invoke() { return callMethod1(instance, 42); } }