1 29 30 package com.caucho.bytecode; 31 32 import java.lang.reflect.Method ; 33 import java.lang.reflect.Modifier ; 34 import java.lang.reflect.ParameterizedType ; 35 import java.lang.reflect.Type ; 36 37 40 public class JMethodWrapper extends JMethod { 41 private JClassLoader _loader; 42 43 private Method _method; 44 45 public JMethodWrapper(Method method, JClassLoader loader) 46 { 47 if (loader == null) 48 throw new NullPointerException (); 49 50 _method = method; 51 _loader = loader; 52 } 53 54 57 public String getName() 58 { 59 return _method.getName(); 60 } 61 62 65 public boolean isStatic() 66 { 67 return Modifier.isStatic(_method.getModifiers()); 68 } 69 70 73 public boolean isPrivate() 74 { 75 return Modifier.isPrivate(_method.getModifiers()); 76 } 77 78 81 public boolean isPublic() 82 { 83 return Modifier.isPublic(_method.getModifiers()); 84 } 85 86 89 public boolean isFinal() 90 { 91 return Modifier.isFinal(_method.getModifiers()); 92 } 93 94 97 public boolean isAbstract() 98 { 99 return Modifier.isAbstract(_method.getModifiers()); 100 } 101 102 105 public JClass getDeclaringClass() 106 { 107 return _loader.forName(_method.getDeclaringClass().getName()); 108 } 109 110 113 public JClass getReturnType() 114 { 115 return _loader.forName(_method.getReturnType().getName()); 116 } 117 118 121 public JType getGenericReturnType() 122 { 123 try { 124 Type retType = _method.getGenericReturnType(); 125 126 if (retType instanceof Class ) 127 return _loader.forName(((Class ) retType).getName()); 128 else 129 return new JTypeWrapper(_loader, (ParameterizedType ) retType); 130 } catch (NoSuchMethodError e) { 131 return getReturnType(); 132 } 133 134 } 135 136 139 public JClass []getParameterTypes() 140 { 141 Class []types = _method.getParameterTypes(); 142 143 JClass []jTypes = new JClass[types.length]; 144 145 for (int i = 0; i < types.length; i++) { 146 jTypes[i] = _loader.forName(types[i].getName()); 147 } 148 149 return jTypes; 150 } 151 152 155 public JClass []getExceptionTypes() 156 { 157 Class []types = _method.getExceptionTypes(); 158 159 JClass []jTypes = new JClass[types.length]; 160 161 for (int i = 0; i < types.length; i++) { 162 jTypes[i] = _loader.forName(types[i].getName()); 163 } 164 165 return jTypes; 166 } 167 168 171 public JAnnotation []getDeclaredAnnotations() 172 { 173 return new JAnnotation[0]; 174 } 175 } 176 | Popular Tags |