KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > reflect > ReflectAccess


1 /*
2  * @(#)ReflectAccess.java 1.12 04/01/28
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang.reflect;
9
10 import sun.reflect.MethodAccessor;
11 import sun.reflect.ConstructorAccessor;
12
13 /** Package-private class implementing the
14     sun.reflect.LangReflectAccess interface, allowing the java.lang
15     package to instantiate objects in this package. */

16
17 class ReflectAccess implements sun.reflect.LangReflectAccess {
18     public Field JavaDoc newField(Class JavaDoc declaringClass,
19                           String JavaDoc name,
20                           Class JavaDoc type,
21                           int modifiers,
22                           int slot,
23                           String JavaDoc signature,
24                           byte[] annotations)
25     {
26         return new Field JavaDoc(declaringClass,
27                          name,
28                          type,
29                          modifiers,
30                          slot,
31                          signature,
32                          annotations);
33     }
34
35     public Method JavaDoc newMethod(Class JavaDoc declaringClass,
36                             String JavaDoc name,
37                             Class JavaDoc[] parameterTypes,
38                             Class JavaDoc returnType,
39                             Class JavaDoc[] checkedExceptions,
40                             int modifiers,
41                             int slot,
42                             String JavaDoc signature,
43                             byte[] annotations,
44                             byte[] parameterAnnotations,
45                             byte[] annotationDefault)
46     {
47         return new Method JavaDoc(declaringClass,
48                           name,
49                           parameterTypes,
50                           returnType,
51                           checkedExceptions,
52                           modifiers,
53                           slot,
54                           signature,
55                           annotations,
56                           parameterAnnotations,
57                           annotationDefault);
58     }
59
60     public <T> Constructor JavaDoc<T> newConstructor(Class JavaDoc<T> declaringClass,
61                          Class JavaDoc[] parameterTypes,
62                          Class JavaDoc[] checkedExceptions,
63                          int modifiers,
64                          int slot,
65                                              String JavaDoc signature,
66                                              byte[] annotations,
67                                              byte[] parameterAnnotations)
68     {
69         return new Constructor JavaDoc<T>(declaringClass,
70                   parameterTypes,
71                   checkedExceptions,
72                   modifiers,
73                   slot,
74                                   signature,
75                                   annotations,
76                                   parameterAnnotations);
77     }
78
79     public MethodAccessor getMethodAccessor(Method JavaDoc m) {
80         return m.getMethodAccessor();
81     }
82
83     public void setMethodAccessor(Method JavaDoc m, MethodAccessor accessor) {
84         m.setMethodAccessor(accessor);
85     }
86
87     public ConstructorAccessor getConstructorAccessor(Constructor JavaDoc c) {
88         return c.getConstructorAccessor();
89     }
90
91     public void setConstructorAccessor(Constructor JavaDoc c,
92                                        ConstructorAccessor accessor)
93     {
94         c.setConstructorAccessor(accessor);
95     }
96
97     public int getConstructorSlot(Constructor JavaDoc c) {
98         return c.getSlot();
99     }
100
101     public String JavaDoc getConstructorSignature(Constructor JavaDoc c) {
102         return c.getSignature();
103     }
104
105     public byte[] getConstructorAnnotations(Constructor JavaDoc c) {
106         return c.getRawAnnotations();
107     }
108
109     public byte[] getConstructorParameterAnnotations(Constructor JavaDoc c) {
110         return c.getRawParameterAnnotations();
111     }
112
113     //
114
// Copying routines, needed to quickly fabricate new Field,
115
// Method, and Constructor objects from templates
116
//
117
public Method JavaDoc copyMethod(Method JavaDoc arg) {
118         return arg.copy();
119     }
120
121     public Field JavaDoc copyField(Field JavaDoc arg) {
122         return arg.copy();
123     }
124
125     public <T> Constructor JavaDoc<T> copyConstructor(Constructor JavaDoc<T> arg) {
126         return arg.copy();
127     }
128 }
129
Popular Tags