01: package jaxx.reflect;
02:
03: import jaxx.compiler.JAXXCompiler;
04:
05: /** Mirrors the class <code>java.lang.ref.Method</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
06: * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
07: * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
08: * circular dependencies).
09: */
10: public class MethodDescriptor extends MemberDescriptor {
11: private String returnType;
12: private String[] parameterTypes;
13:
14: public MethodDescriptor(String name, int modifiers,
15: String returnType, String[] parameterTypes,
16: ClassLoader classLoader) {
17: super (name, modifiers, classLoader);
18: this .returnType = returnType;
19: this .parameterTypes = parameterTypes;
20: if (java.util.Arrays.asList(parameterTypes).contains(null)
21: && JAXXCompiler.STRICT_CHECKS)
22: throw new NullPointerException(name);
23: }
24:
25: public ClassDescriptor getReturnType() {
26: try {
27: return ClassDescriptorLoader.getClassDescriptor(returnType);
28: } catch (ClassNotFoundException e) {
29: throw new RuntimeException(e);
30: }
31: }
32:
33: public ClassDescriptor[] getParameterTypes() {
34: ClassDescriptor[] result = new ClassDescriptor[parameterTypes.length];
35: try {
36: for (int i = 0; i < result.length; i++)
37: result[i] = ClassDescriptorLoader.getClassDescriptor(
38: parameterTypes[i], getClassLoader());
39: return result;
40: } catch (ClassNotFoundException e) {
41: throw new RuntimeException(e);
42: }
43: }
44: }
|