| 18 | import java.lang.annotation.Annotation; |
| 19 | |
| 20 | public class Method<T> extends AccessibleObject implements Member { |
| 21 | private final VMMethod vmMethod; |
| 22 | private boolean accessible; |
| 23 | |
| 24 | public Method(VMMethod vmMethod) { |
| 25 | this.vmMethod = vmMethod; |
| 26 | } |
| 27 | |
| 28 | public boolean equals(Object o) { |
| 29 | return o instanceof Method && ((Method) o).vmMethod == vmMethod; |
| 30 | } |
| 31 | |
| 32 | public boolean isAccessible() { |
| 33 | return accessible; |
| 34 | } |
| 35 | |
| 36 | public void setAccessible(boolean v) { |
| 37 | accessible = v; |
| 38 | } |
| 39 | |
| 40 | public static native VMMethod getCaller(); |
| 41 | |
| 42 | public Class<T> getDeclaringClass() { |
| 43 | return SystemClassLoader.getClass(vmMethod.class_); |
| 44 | } |
| 45 | |
| 46 | public int getModifiers() { |
| 47 | return vmMethod.flags; |
| 48 | } |
| 49 | |
| 50 | public String getName() { |
| 51 | return getName(vmMethod); |
| 52 | } |
| 53 | |
| 54 | public static String getName(VMMethod vmMethod) { |
| 55 | return Classes.makeString(vmMethod.name, 0, vmMethod.name.length - 1); |
| 56 | } |
| 57 | |
| 58 | private String getSpec() { |
| 59 | return getSpec(vmMethod); |
| 60 | } |
| 61 | |
| 62 | public static String getSpec(VMMethod vmMethod) { |
| 63 | return Classes.makeString(vmMethod.spec, 0, vmMethod.spec.length - 1); |
| 64 | } |
| 65 | |
| 66 | public Class[] getParameterTypes() { |
| 67 | return Classes.getParameterTypes(vmMethod); |
| 68 | } |
| 69 | |
| 70 | public Object invoke(Object instance, Object ... arguments) |
| 71 | throws InvocationTargetException, IllegalAccessException |
| 72 | { |
| 73 | if ((vmMethod.flags & Modifier.STATIC) != 0 |
| 74 | || Class.isInstance(vmMethod.class_, instance)) |
| 75 | { |
| 76 | if ((vmMethod.flags & Modifier.STATIC) != 0) { |
| 77 | instance = null; |
nothing calls this directly
no outgoing calls
no test coverage detected