1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.services.reflect.ReflectMethod |
4 | |
5 | Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.services.reflect; |
22 | |
23 | import org.apache.derby.iapi.services.loader.GeneratedMethod; |
24 | |
25 | import org.apache.derby.iapi.error.StandardException; |
26 | |
27 | import java.lang.reflect.Method; |
28 | import java.lang.reflect.InvocationTargetException; |
29 | |
30 | class ReflectMethod implements GeneratedMethod { |
31 | |
32 | private final Method realMethod; |
33 | |
34 | ReflectMethod(Method m) { |
35 | super(); |
36 | realMethod = m; |
37 | } |
38 | |
39 | public Object invoke(Object ref) |
40 | throws StandardException { |
41 | |
42 | Throwable t; |
43 | |
44 | try { |
45 | return realMethod.invoke(ref, null); |
46 | |
47 | } catch (IllegalAccessException iae) { |
48 | |
49 | t = iae; |
50 | |
51 | } catch (IllegalArgumentException iae2) { |
52 | |
53 | t = iae2; |
54 | |
55 | } catch (InvocationTargetException ite) { |
56 | |
57 | t = ite.getTargetException(); |
58 | if (t instanceof StandardException) |
59 | throw (StandardException) t; |
60 | } |
61 | |
62 | throw StandardException.unexpectedUserException(t); |
63 | } |
64 | |
65 | |
66 | } |