I have a very basic class: --------------- public class MyClass{ public static LinkedList classesLoaded; public static void addClass(Object o){ Class c = o.getClass(); classesLoaded.add(c); } } ---------------- I have another class which adds statements to class constructor (when the class is charged by the JVM).
My class implements ClassFileTransformer and I use the transform method to do the modification on each class which is loaded. I just want to add this java code to class constructor : MyClass.addClass(this); MyClass.addClass = a static invocation of the addClass method (this) = the class which the JVM is loading. This way I can save a list of class (of my application) which are loaded by the JVM because every constructor add an object in the classesLoaded LinkedList. I suppose, I must use the class InstructionFactory to genetate the byte code, but I have some problems. This is what i made but it does not work: InstructionList il = new InstructionList(); InstructionFactory ifact = new InstructionFactory(constantPoolGen); il.append(ifact.createThis()); //I think i must push This on the stack but i do not know il.append(ifact.createInvoke("MyClass","addClass",Type.VOID, new Type[]{Type.OBJECT}, Constants.INVOKESTATIC)); it work when I write : il.append(new PUSH(constantPoolGen,javaClass.getClassName())); il.append(instructionFactory.createInvoke("MyClass", "addClass", Type.VOID, new Type[] { Type.OBJECT }, Constants.INVOKESTATIC)); but in the latter version I send a String object to the addClass method. It is not what I want. -- View this message in context: http://www.nabble.com/misunderstanding-of-InstructionFactory-tp24037858p24037858.html Sent from the BCEL - User mailing list archive at Nabble.com.