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 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; } }
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); }
/** * 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); }
/** * Constructs a new class loader. */ public Loader() throws CannotCompileException, NotFoundException { super(); delegateLoadingOf("javassist.tools.reflect.Loader"); reflection = new Reflection(); ClassPool pool = ClassPool.getDefault(); addTranslator(pool, reflection); }
/** * 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(); }
public static void main(String[] args) throws Exception { if (args.length == 0) { help(System.err); return; } CompiledClass[] entries = new CompiledClass[args.length]; int n = parse(args, entries); if (n < 1) { System.err.println("bad parameter."); return; } processClasses(entries, n); }
/** * Loads a class with an instance of <code>Loader</code> * and calls <code>main()</code> in that class. * * @param args command line parameters. * <br> <code>args[0]</code> is the class name to be loaded. * <br> <code>args[1..n]</code> are parameters passed * to the target <code>main()</code>. */ public static void main(String[] args) throws Throwable { Loader cl = new Loader(); cl.run(args); }
/** * 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 static Object trapStatic(Object[] args, int identifier) throws Throwable { return _classobject.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 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; } }
/** * 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); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { baseobject = (Metalevel)in.readObject(); classmetaobject = baseobject._getClass(); methods = classmetaobject.getReflectiveMethods(); }
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); }
/** * 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(); }
public static Object trapStatic(Object[] args, int identifier) throws Throwable { return _classobject.trapMethodcall(identifier, args); }
/** * 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 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(); }