private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { javaClass = getClassObject(in.readUTF()); constructors = javaClass.getConstructors(); methods = null; }
/** * Is invoked when <code>static</code> fields of the base-level * class are read and the runtime system intercepts it. * This method simply returns the value of the field. * * <p>Every subclass of this class should redefine this method. */ public Object trapFieldRead(String name) { Class jc = getJavaClass(); try { return jc.getField(name).get(null); } catch (NoSuchFieldException e) { throw new RuntimeException(e.toString()); } catch (IllegalAccessException e) { throw new RuntimeException(e.toString()); } }
throws NoSuchMethodException Method[] mthds = getReflectiveMethods(); for (int i = 0; i < mthds.length; i++) { if (mthds[i] == null) if (getMethodName(i).equals(originalName) && Arrays.equals(argTypes, mthds[i].getParameterTypes())) return i;
/** * 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]; }
public Object trap(Object[] args, int identifier) throws Throwable { Metaobject mobj; mobj = _metaobject; if (mobj == null) return ClassMetaobject.invoke(this, identifier, args); else return mobj.trapMethodcall(identifier, args); }
public static Object trapRead(Object[] args, String name) { if (args[0] == null) return _classobject.trapFieldRead(name); else return ((Metalevel)args[0])._getMetaobject().trapFieldRead(name); }
public static Object trapStatic(Object[] args, int identifier) throws Throwable { return _classobject.trapMethodcall(identifier, args); }
public static Object trapWrite(Object[] args, String name) { Metalevel base = (Metalevel)args[0]; if (base == null) _classobject.trapFieldWrite(name, args[1]); else base._getMetaobject().trapFieldWrite(name, args[1]); return null; } }
/** * 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(); }
public Object trap(Object[] args, int identifier) throws Throwable { Metaobject mobj; mobj = _metaobject; if (mobj == null) return ClassMetaobject.invoke(this, identifier, args); return mobj.trapMethodcall(identifier, args); }
public static Object trapRead(Object[] args, String name) { if (args[0] == null) return _classobject.trapFieldRead(name); return ((Metalevel)args[0])._getMetaobject().trapFieldRead(name); }
public static Object trapStatic(Object[] args, int identifier) throws Throwable { return _classobject.trapMethodcall(identifier, args); }
public static Object trapWrite(Object[] args, String name) { Metalevel base = (Metalevel)args[0]; if (base == null) _classobject.trapFieldWrite(name, args[1]); else base._getMetaobject().trapFieldWrite(name, args[1]); return null; } }
throws NoSuchMethodException Method[] mthds = getReflectiveMethods(); for (int i = 0; i < mthds.length; i++) { if (mthds[i] == null) if (getMethodName(i).equals(originalName) && Arrays.equals(argTypes, mthds[i].getParameterTypes())) return i;
/** * Is invoked when <code>static</code> fields of the base-level * class are modified and the runtime system intercepts it. * This method simply sets the field to the given value. * * <p>Every subclass of this class should redefine this method. */ public void trapFieldWrite(String name, Object value) { Class jc = getJavaClass(); try { jc.getField(name).set(null, value); } catch (NoSuchFieldException e) { throw new RuntimeException(e.toString()); } catch (IllegalAccessException e) { throw new RuntimeException(e.toString()); } }
/** * 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(); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { javaClass = getClassObject(in.readUTF()); constructors = javaClass.getConstructors(); methods = null; }
public Object trap(Object[] args, int identifier) throws Throwable { Metaobject mobj; mobj = _metaobject; if (mobj == null) return ClassMetaobject.invoke(this, identifier, args); else return mobj.trapMethodcall(identifier, args); }
public static Object trapRead(Object[] args, String name) { if (args[0] == null) return _classobject.trapFieldRead(name); else return ((Metalevel)args[0])._getMetaobject().trapFieldRead(name); }
public static Object trapStatic(Object[] args, int identifier) throws Throwable { return _classobject.trapMethodcall(identifier, args); }