Hi all, I'm trying to insert some code in the constructor of certain classes. The code should be getting the current singleton instance of a class 'MySingleton' and call a method 'myMethod' on this instance. My code is as follows :
InstructionList il = mg.getInstructionList(); il.insert(factory.createInvoke("MySingleTon", "getInstance", new ObjectType("MySingleton"), Type.NO_ARGS, Constants.INVOKESTATIC)); il.insert(InstructionFactory.createLoad(Type.OBJECT, 0)); il.insert(factory.createInvoke("java.lang.Object", "getClass", new ObjectType("java.lang.Class"), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(factory.createInvoke("java.lang.Class", "getName", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(InstructionConstants.ACONST_NULL); il.insert(factory.createInvoke("MySingleton", "myMethod", Type.VOID, new Type[] { Type.STRING, new ObjectType("MyObject") }, Constants.INVOKEVIRTUAL)); mg.setInstructionList(il); mg.setMaxStack(); When I decompile the patched class the method to which I inserted the code has dissapeared and the following line is added in place : // JavaClassFileOutputException: Stack underflow Does anybody has an idea of what I'm doing wrong? Can you provide me a code sample doing something like I want to achieve? Kind regards, Johan, --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]