|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| package edu.rice.cs.plt.reflect; |
|
36 |
| |
|
37 |
| import java.lang.reflect.InvocationTargetException; |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| public abstract class ReflectException extends Exception { |
|
48 |
| |
|
49 |
35
| protected ReflectException(Throwable cause) { super(cause); }
|
|
50 |
| public abstract <T> T apply(ReflectExceptionVisitor<T> v); |
|
51 |
| |
|
52 |
| |
|
53 |
| public static class ClassNotFoundReflectException extends ReflectException { |
|
54 |
5
| public ClassNotFoundReflectException(ClassNotFoundException e) { super(e); }
|
|
55 |
10
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
56 |
10
| return v.forClassNotFound((ClassNotFoundException) getCause());
|
|
57 |
| } |
|
58 |
| } |
|
59 |
| |
|
60 |
| |
|
61 |
| public static class NoSuchFieldReflectException extends ReflectException { |
|
62 |
3
| public NoSuchFieldReflectException(NoSuchFieldException e) { super(e); }
|
|
63 |
6
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
64 |
6
| return v.forNoSuchField((NoSuchFieldException) getCause());
|
|
65 |
| } |
|
66 |
| } |
|
67 |
| |
|
68 |
| |
|
69 |
| public static class NoSuchMethodReflectException extends ReflectException { |
|
70 |
11
| public NoSuchMethodReflectException(NoSuchMethodException e) { super(e); }
|
|
71 |
22
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
72 |
22
| return v.forNoSuchMethod((NoSuchMethodException) getCause());
|
|
73 |
| } |
|
74 |
| } |
|
75 |
| |
|
76 |
| |
|
77 |
| public static class NullPointerReflectException extends ReflectException { |
|
78 |
4
| public NullPointerReflectException(NullPointerException e) { super(e); }
|
|
79 |
8
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
80 |
8
| return v.forNullPointer((NullPointerException) getCause());
|
|
81 |
| } |
|
82 |
| } |
|
83 |
| |
|
84 |
| |
|
85 |
| public static class IllegalArgumentReflectException extends ReflectException { |
|
86 |
3
| public IllegalArgumentReflectException(IllegalArgumentException e) { super(e); }
|
|
87 |
6
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
88 |
6
| return v.forIllegalArgument((IllegalArgumentException) getCause());
|
|
89 |
| } |
|
90 |
| } |
|
91 |
| |
|
92 |
| |
|
93 |
| public static class ClassCastReflectException extends ReflectException { |
|
94 |
4
| public ClassCastReflectException(ClassCastException e) { super(e); }
|
|
95 |
8
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
96 |
8
| return v.forClassCast((ClassCastException) getCause());
|
|
97 |
| } |
|
98 |
| } |
|
99 |
| |
|
100 |
| |
|
101 |
| public static class InvocationTargetReflectException extends ReflectException { |
|
102 |
2
| public InvocationTargetReflectException(InvocationTargetException e) { super(e); }
|
|
103 |
4
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
104 |
4
| return v.forInvocationTarget((InvocationTargetException) getCause());
|
|
105 |
| } |
|
106 |
| } |
|
107 |
| |
|
108 |
| |
|
109 |
| public static class InstantiationReflectException extends ReflectException { |
|
110 |
1
| public InstantiationReflectException(InstantiationException e) { super(e); }
|
|
111 |
2
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
112 |
2
| return v.forInstantiation((InstantiationException) getCause());
|
|
113 |
| } |
|
114 |
| } |
|
115 |
| |
|
116 |
| |
|
117 |
| public static class IllegalAccessReflectException extends ReflectException { |
|
118 |
2
| public IllegalAccessReflectException(IllegalAccessException e) { super(e); }
|
|
119 |
4
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
120 |
4
| return v.forIllegalAccess((IllegalAccessException) getCause());
|
|
121 |
| } |
|
122 |
| } |
|
123 |
| |
|
124 |
| |
|
125 |
| public static class SecurityReflectException extends ReflectException { |
|
126 |
0
| public SecurityReflectException(SecurityException e) { super(e); }
|
|
127 |
0
| public <T> T apply(ReflectExceptionVisitor<T> v) {
|
|
128 |
0
| return v.forSecurity((SecurityException) getCause());
|
|
129 |
| } |
|
130 |
| } |
|
131 |
| |
|
132 |
| } |