Files
openide/java/java-tests/testData/refactoring/extractMethodObject4Debugger/outs/methodWithPrimitiveParameter.out
T
Rustam Vishnyakovandintellij-monorepo-bot 123242c4b2 EditorConfig documentation test
GitOrigin-RevId: fd52ace3d7a32ecd02c2c5ab90e077967604c15e
2019-06-16 04:03:21 +03:00

44 lines
1.6 KiB
Plaintext

call text: int result = new Test(instance).invoke();
class:
static class Test {
private Object instance;
public Test(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);
}
}