Re: misunderstanding of InstructionFactory
Abdullah Odeh Al-Zaghameem <[email protected]> Wed, 1 Jul 2009 10:24:40 -0700 (PDT)
| Newsgroups | gmane.comp.jakarta.bcel.user |
|---|---|
| Message-ID | <[email protected]> |
--0-2002478891-1246469080=:56795 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi, =A0 You=A0do not=A0mentioned the type of your problem. Is it a Runtime Exceptio= n or you just didn't get the expected results?. If the second=A0option is t= he case, then you my=A0inject=A0your code at the end of the constructor whi= ch, as I can=A0guess, fall after the RETURN instruction. =A0 If the first option is the case, then AUCH!!, no way to see in dark man, be= cause your code is corrct (the one with ifact.createThis(), but try Instruc= tionFactory.createThis();) ).=A0 Best Regards, =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D A b d u l l a h=A0=A0 O.=A0 A l - Z a g h a m e e m Technical University of=A0 Berlin Germany --- On Mon, 6/15/09, casertap <[email protected]> wrote: From: casertap <[email protected]> Subject: misunderstanding of InstructionFactory To: [email protected] Date: Monday, June 15, 2009, 7:22 PM I have a very basic class: --------------- public class MyClass{ =A0=A0=A0 public static LinkedList<Class> classesLoaded; =A0=A0=A0 public static void addClass(Object o){ =A0=A0=A0 =A0=A0=A0 Class c =3D o.getClass(); =A0=A0=A0 =A0=A0=A0 classesLoaded.add(c); =A0=A0=A0 } } ---------------- 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 =3D a static invocation of the addClass method (this) =3D 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 =3D new InstructionList(); InstructionFactory ifact =3D 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. --=20 View this message in context: http://www.nabble.com/misunderstanding-of-Ins= tructionFactory-tp24037858p24037858.html Sent from the BCEL - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] =0A=0A=0A --0-2002478891-1246469080=:56795--