summaryrefslogtreecommitdiff
path: root/test/200-reflection-errors/src/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/200-reflection-errors/src/Main.java')
-rw-r--r--test/200-reflection-errors/src/Main.java52
1 files changed, 0 insertions, 52 deletions
diff --git a/test/200-reflection-errors/src/Main.java b/test/200-reflection-errors/src/Main.java
deleted file mode 100644
index 86bbfd4d2b..0000000000
--- a/test/200-reflection-errors/src/Main.java
+++ /dev/null
@@ -1,52 +0,0 @@
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-public class Main {
- public static void main(String[] args) throws Exception {
- // Can't assign Integer to a String field.
- try {
- Field field = A.class.getField("b");
- field.set(new A(), 5);
- } catch (IllegalArgumentException expected) {
- System.out.println(expected.getMessage());
- }
-
- // Can't unbox null to a primitive.
- try {
- Field field = A.class.getField("i");
- field.set(new A(), null);
- } catch (IllegalArgumentException expected) {
- System.out.println(expected.getMessage());
- }
-
- // Can't unbox String to a primitive.
- try {
- Field field = A.class.getField("i");
- field.set(new A(), "hello, world!");
- } catch (IllegalArgumentException expected) {
- System.out.println(expected.getMessage());
- }
-
- // Can't pass an Integer as a String.
- try {
- Method m = A.class.getMethod("m", int.class, String.class);
- m.invoke(new A(), 2, 2);
- } catch (IllegalArgumentException expected) {
- System.out.println(expected.getMessage());
- }
-
- // Can't pass null as an int.
- try {
- Method m = A.class.getMethod("m", int.class, String.class);
- m.invoke(new A(), null, "");
- } catch (IllegalArgumentException expected) {
- System.out.println(expected.getMessage());
- }
- }
-}
-
-class A {
- public String b;
- public int i;
- public void m(int i, String s) {}
-}