public static ClassGen injectHackedCanvas(ClassGen _cg, ConstantPoolGen _cp, String clazz, String instance) { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(Constants.ACC_PUBLIC, new ObjectType("java.awt.Canvas"), Type.NO_ARGS, new String[] { }, "myGetCanvas", "client", il, _cp); InstructionFactory _factory = new InstructionFactory(_cg,_cp); InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); il.append(_factory.createFieldAccess(clazz, instance, new ObjectType("java.awt.Canvas"), Constants.GETFIELD)); InstructionHandle ih_4 = il.append(_factory.createReturn(Type.OBJECT)); method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); return _cg; }