Migrate Java code to separate QL repo.

This commit is contained in:
Pavel Avgustinov
2018-08-30 10:48:05 +01:00
parent d957c151a6
commit 846c9d5860
2319 changed files with 134386 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
public class ReflectionTest {
public static class TestObject1 {
public TestObject1() { }
}
public static class TestObject2 {
public TestObject2() { }
}
public static class TestObject3 {
public TestObject3() { }
}
public static class TestObject4 {
public TestObject4() { }
}
public static class TestObject4a extends TestObject4 {
public TestObject4a() { }
}
public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
// Get class by name
Class.forName("ReflectionTest$TestObject1").newInstance();
// Use classloader
ReflectionTest.class.getClassLoader().loadClass("ReflectionTest$TestObject2").newInstance();
// Store in variable, load from that
Class<?> clazz = Class.forName("ReflectionTest$TestObject3");
clazz.newInstance();
/*
* We cannot determine the class by looking at a String literal, so we should look to the
* type - in this case Class<? extends TestObject4>. We should therefore identify both
* TestObject4 and TestObject4a as live.
*/
getClass4().newInstance();
}
public static Class<? extends TestObject4> getClass4() {
return TestObject4.class;
}
}