1 18 19 package org.objectweb.jac.core.rtti; 20 21 import java.lang.reflect.Method ; 22 import java.lang.reflect.Modifier ; 23 import org.objectweb.jac.util.ExtArrays; 24 25 public class MixinMethodItem extends MethodItem { 26 public MixinMethodItem(Method method, ClassItem parent) 27 throws InvalidDelegateException 28 { 29 super(method,parent); 30 if (!Modifier.isStatic(method.getModifiers())) 31 throw new InvalidDelegateException(delegate,"Mixin method is not static"); 32 if (!method.getParameterTypes()[0].isAssignableFrom((Class )parent.getDelegate())) 33 throw new InvalidDelegateException( 34 delegate,"1st parameter of mixin method should be "+parent.getName()); 35 paramTypes = (Class [])ExtArrays.subArray(method.getParameterTypes(),1); 36 } 37 38 42 public Object invoke(Object object, Object [] parameters) { 43 return invokeStatic(ExtArrays.add(0, object, parameters)); 44 } 45 46 Class [] paramTypes; 47 public Class [] getParameterTypes() { 48 return paramTypes; 49 } 50 51 public void setParameter(Object [] params, int i, Object value) { 52 params[i+1] = value; 53 } 54 public Object getParameter(Object [] params, int i) { 55 return params[i+1]; 56 } 57 } 58 | Popular Tags |