01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.harmony.lang.reflect;
18:
19: import java.lang.reflect.Constructor;
20: import java.lang.reflect.Field;
21: import java.lang.reflect.Method;
22:
23: /**
24: * @author Evgueni Brevnov, Roman S. Bushmanov
25: * @version $Revision: 1.1.6.4 $
26: */
27: public class Reflection {
28:
29: private static ReflectAccessor reflectAccessor;
30:
31: public static void setReflectAccessor(ReflectAccessor accessor) {
32: reflectAccessor = accessor;
33: }
34:
35: public static <T> Constructor<T> copyConstructor(Constructor<T> c) {
36: return reflectAccessor.copyConstructor(c);
37: }
38:
39: @SuppressWarnings("unchecked")
40: public static <T> Constructor<T>[] copyConstructors(
41: Constructor<T>[] cs) {
42: Constructor<T>[] ret = new Constructor[cs.length];
43: for (int i = 0; i < cs.length; i++) {
44: ret[i] = reflectAccessor.copyConstructor(cs[i]);
45: }
46: return ret;
47: }
48:
49: public static Field copyField(Field f) {
50: return reflectAccessor.copyField(f);
51: }
52:
53: public static Field[] copyFields(Field[] fs) {
54: Field[] ret = new Field[fs.length];
55: for (int i = 0; i < fs.length; i++) {
56: ret[i] = reflectAccessor.copyField(fs[i]);
57: }
58: return ret;
59: }
60:
61: public static Method copyMethod(Method m) {
62: return reflectAccessor.copyMethod(m);
63: }
64:
65: public static Method[] copyMethods(Method[] ms) {
66: Method[] ret = new Method[ms.length];
67: for (int i = 0; i < ret.length; i++) {
68: ret[i] = reflectAccessor.copyMethod(ms[i]);
69: }
70: return ret;
71: }
72:
73: public static void checkMemberAccess(Class callerClass,
74: Class declarinClass, Class runtimeClass, int memberModifiers)
75: throws IllegalAccessException {
76: reflectAccessor.checkMemberAccess(callerClass, declarinClass,
77: runtimeClass, memberModifiers);
78: }
79:
80: public static Method[] mergePublicMethods(Method[] declared,
81: Method[] super Public, Method[][] intf, int estimate) {
82: return reflectAccessor.mergePublicMethods(declared,
83: superPublic, intf, estimate);
84: }
85: }
|