/** * Returns the <code>java.lang.reflect.Method</code> object representing * the method specified by <code>identifier</code>. * * <p>Note that the actual method returned will be have an altered, * reflective name i.e. <code>_m_2_..</code>. * * @param identifier the identifier index * given to <code>trapMethodcall()</code> etc. * @see Metaobject#trapMethodcall(int,Object[]) * @see #trapMethodcall(int,Object[]) */ public final Method getMethod(int identifier) { return getReflectiveMethods()[identifier]; }
/** * Returns an array of <code>Class</code> objects representing the * formal parameter types of the method specified * by <code>identifier</code>. */ public final Class[] getParameterTypes(int identifier) { return getReflectiveMethods()[identifier].getParameterTypes(); }
/** * Returns a <code>Class</code> objects representing the * return type of the method specified by <code>identifier</code>. */ public final Class getReturnType(int identifier) { return getReflectiveMethods()[identifier].getReturnType(); }
/** * Returns the <code>java.lang.reflect.Method</code> object representing * the method specified by <code>identifier</code>. * * <p>Note that the actual method returned will be have an altered, * reflective name i.e. <code>_m_2_..</code>. * * @param identifier the identifier index * given to <code>trapMethodcall()</code> etc. * @see Metaobject#trapMethodcall(int,Object[]) * @see #trapMethodcall(int,Object[]) */ public final Method getMethod(int identifier) { return getReflectiveMethods()[identifier]; }
/** * Returns the name of the method specified * by <code>identifier</code>. */ public final String getMethodName(int identifier) { String mname = getReflectiveMethods()[identifier].getName(); int j = ClassMetaobject.methodPrefixLen; for (;;) { char c = mname.charAt(j++); if (c < '0' || '9' < c) break; } return mname.substring(j); }
/** * Returns an array of <code>Class</code> objects representing the * formal parameter types of the method specified * by <code>identifier</code>. */ public final Class<?>[] getParameterTypes(int identifier) { return getReflectiveMethods()[identifier].getParameterTypes(); }
/** * Returns a <code>Class</code> objects representing the * return type of the method specified by <code>identifier</code>. */ public final Class<?> getReturnType(int identifier) { return getReflectiveMethods()[identifier].getReturnType(); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { baseobject = (Metalevel)in.readObject(); classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); }
/** * Constructs a <code>Metaobject</code>. The metaobject is * constructed before the constructor is called on the base-level * object. * * @param self the object that this metaobject is associated with. * @param args the parameters passed to the constructor of * <code>self</code>. */ public Metaobject(Object self, Object[] args) { baseobject = (Metalevel)self; classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); }
/** * Returns the name of the method specified * by <code>identifier</code>. */ public final String getMethodName(int identifier) { String mname = getReflectiveMethods()[identifier].getName(); int j = ClassMetaobject.methodPrefixLen; for (;;) { char c = mname.charAt(j++); if (c < '0' || '9' < c) break; } return mname.substring(j); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { baseobject = (Metalevel)in.readObject(); classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); }
/** * Is invoked when <code>static</code> methods of the base-level * class are called and the runtime system intercepts it. * This method simply executes the intercepted method invocation * with the original parameters and returns the resulting value. * * <p>Every subclass of this class should redefine this method. */ public Object trapMethodcall(int identifier, Object[] args) throws Throwable { try { Method[] m = getReflectiveMethods(); return m[identifier].invoke(null, args); } catch (java.lang.reflect.InvocationTargetException e) { throw e.getTargetException(); } catch (java.lang.IllegalAccessException e) { throw new CannotInvokeException(e); } }
/** * Constructs a <code>Metaobject</code>. The metaobject is * constructed before the constructor is called on the base-level * object. * * @param self the object that this metaobject is associated with. * @param args the parameters passed to the constructor of * <code>self</code>. */ public Metaobject(Object self, Object[] args) { baseobject = (Metalevel)self; classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); }
throws NoSuchMethodException Method[] mthds = getReflectiveMethods(); for (int i = 0; i < mthds.length; i++) { if (mthds[i] == null)
/** * Changes the object controlled by this metaobject. * * @param self the object */ public final void setObject(Object self) { baseobject = (Metalevel)self; classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); // call _setMetaobject() after the metaobject is settled. baseobject._setMetaobject(this); }
/** * Is invoked when <code>static</code> methods of the base-level * class are called and the runtime system intercepts it. * This method simply executes the intercepted method invocation * with the original parameters and returns the resulting value. * * <p>Every subclass of this class should redefine this method. */ public Object trapMethodcall(int identifier, Object[] args) throws Throwable { try { Method[] m = getReflectiveMethods(); return m[identifier].invoke(null, args); } catch (java.lang.reflect.InvocationTargetException e) { throw e.getTargetException(); } catch (java.lang.IllegalAccessException e) { throw new CannotInvokeException(e); } }
throws NoSuchMethodException Method[] mthds = getReflectiveMethods(); for (int i = 0; i < mthds.length; i++) { if (mthds[i] == null)
/** * Changes the object controlled by this metaobject. * * @param self the object */ public final void setObject(Object self) { baseobject = (Metalevel)self; classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); // call _setMetaobject() after the metaobject is settled. baseobject._setMetaobject(this); }
/** * Returns an array of <code>Class</code> objects representing the * formal parameter types of the method specified * by <code>identifier</code>. */ public final Class[] getParameterTypes(int identifier) { return getReflectiveMethods()[identifier].getParameterTypes(); }
/** * Returns a <code>Class</code> objects representing the * return type of the method specified by <code>identifier</code>. */ public final Class getReturnType(int identifier) { return getReflectiveMethods()[identifier].getReturnType(); }