BCEL

BCEL, Bytecode Engineering Library, is a Java API which allows dynamic modification of .class files. BCEL can be used to add, remove, and modify fields and methods, as well as changing superclasses around.

Runedev
Runedev uses a BCEL based injector to modify the client at load time. Unlike some other macro clients, Runedev dynamically loads and modifies the RuneScape client. Some macro clients prepare a modified Runescape client and pack it with their macro. Other macro clients use reflection to quietly access important data, and some use color picking to analyze the Runescape client.

Runedev's BCEL injector loads a remote hook file from a server and iterates through the contents. As it progresses through, it sets certain classes as the superclasses to others. For example, org.rsbot.accessors.RSPlayer will becomes the superclass to the Runescape client equivelent. The injector also adds some accessor methods, including all of the ones found in Client.java. All of these methods are produced at runtime by the injector.

Sample bytecode
public Test{ JavaClass c = com.sun.org.apache.bcel.internal.Repository.lookupClass(this.getClass); for(Field f : c.getFields) System.out.println(f); for(Method m : c.getMethods){ System.out.println(m); System.out.println(m.getCode); } }

Becomes...

public void Code(max_stack = 2, max_locals = 6, code_length = 95) 0: aload_0 1: invokespecial java.lang.Object. V (10) 4: aload_0 5: invokevirtual java.lang.Object.getClass Ljava/lang/Class; (12) 8: invokestatic com.sun.org.apache.bcel.internal.Repository.lookupClass (Ljava/lang/Class;)Lcom/sun/org/apache/bcel/internal/classfile/JavaClass; (16) 11: astore_1 12: aload_1 13: invokevirtual com.sun.org.apache.bcel.internal.classfile.JavaClass.getFields [Lcom/sun/org/apache/bcel/internal/classfile/Field; (22) 16: dup 17: astore %5 19: arraylength 20: istore %4 22: iconst_0 23: istore_3 24: goto #42 27: aload %5 29: iload_3 30: aaload 31: astore_2 32: getstatic java.lang.System.out Ljava/io/PrintStream; (28) 35: aload_2 36: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V (34) 39: iinc %3 1 42: iload_3 43: iload %4 45: if_icmplt #27 48: aload_1 49: invokevirtual com.sun.org.apache.bcel.internal.classfile.JavaClass.getMethods [Lcom/sun/org/apache/bcel/internal/classfile/Method; (40) 52: dup 53: astore %5 55: arraylength 56: istore %4 58: iconst_0 59: istore_3 60: goto #88 63: aload %5 65: iload_3 66: aaload 67: astore_2 68: getstatic java.lang.System.out Ljava/io/PrintStream; (28) 71: aload_2 72: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V (34) 75: getstatic java.lang.System.out Ljava/io/PrintStream; (28) 78: aload_2 79: invokevirtual com.sun.org.apache.bcel.internal.classfile.Method.getCode Lcom/sun/org/apache/bcel/internal/classfile/Code; (44) 82: invokevirtual java.io.PrintStream.println (Ljava/lang/Object;)V (34) 85: iinc %3 1 88: iload_3 89: iload %4 91: if_icmplt #63 94: return