Refactor part of core.legacy to core.networking

This commit is contained in:
2016-07-11 22:54:24 +01:00
parent 0a000884e0
commit 7868c742a5
42 changed files with 531 additions and 27 deletions

View File

@@ -0,0 +1,54 @@
package test;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public class Test {
public static void main(String[] args) {
try {
new Test().start();
} catch (Throwable e) {
e.printStackTrace();
}
}
private void start() throws Throwable {
input((Object) new A());
input((Object) new B());
input((Object) new String[] {"a", "b"});
}
public void input(Object object) throws Throwable {
System.out.println("Object");
MethodType methodType = MethodType.methodType(void.class, object.getClass());
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle methodHandle = lookup.findVirtual(getClass(), "input", methodType);
try {
methodHandle.invoke(this, object);
} catch (NoSuchMethodException e) {
e.printStackTrace();
System.exit(1);
}
}
public void input(A object) {
System.out.println("A");
}
public void input(B object) {
System.out.println("B");
}
public void input(String[] object) {
System.out.println("String[]");
}
public class A {
}
public class B {
}
}