1 35 package org.codehaus.groovy.runtime; 36 37 import groovy.lang.MetaMethod; 38 39 49 public class NewStaticMetaMethod extends MetaMethod { 50 51 private static final Class [] EMPTY_TYPE_ARRAY = {}; 52 53 private MetaMethod metaMethod; 54 private Class [] logicalParameterTypes; 55 56 public NewStaticMetaMethod(MetaMethod metaMethod) { 57 super(metaMethod); 58 this.metaMethod = metaMethod; 59 Class [] realParameterTypes = metaMethod.getParameterTypes(); 60 int size = realParameterTypes.length; 61 if (size <= 1) { 62 logicalParameterTypes = EMPTY_TYPE_ARRAY; 63 } 64 else { 65 logicalParameterTypes = new Class [--size]; 66 System.arraycopy(realParameterTypes, 1, logicalParameterTypes, 0, size); 67 } 68 } 69 70 public Class getDeclaringClass() { 71 return getBytecodeParameterTypes()[0]; 72 } 73 74 public boolean isStatic() { 75 return true; 76 } 77 78 public int getModifiers() { 79 return super.getModifiers(); 80 } 81 82 public Class [] getParameterTypes() { 83 return logicalParameterTypes; 84 } 85 86 public Class [] getBytecodeParameterTypes() { 87 return super.getParameterTypes(); 88 } 89 90 public Object invoke(Object object, Object [] arguments) throws Exception { 91 int size = arguments.length; 92 Object [] newArguments = new Object [size + 1]; 93 System.arraycopy(arguments, 0, newArguments, 1, size); 94 newArguments[0] = null; 95 return metaMethod.invoke(null, newArguments); 96 } 97 } 98 | Popular Tags |