Hello!

I am trying to write a program that finds and processes all invoke instructions
in a class file. My idea is to write something like this:

   public static void main(String[] args) throws Exception {
     ClassParser parser = new ClassParser(args[0]);
     JavaClass jclcass = parser.parse();
     Method[] amethod = jclcass.getMethods();
     for (int i = 0 ; i < amethod.length ; i++) {
       Code code = amethod[i].getCode();
       InstructionList instrlist = MAGIG(code);
       Instruction[] ainstr = instrlist.getInstructions();
       for (int j = 0 ; j < ainstr.length ; j++) {
         if (ainstr[j] instanceof InvokeInstruction) {
           ...
         }
       }
     }
   }

I have not been able to figure out how to write the method MAGIC()
which takes a Code instance and returns the set of instructions
(in the form of an InstructionList) contained in that byte code chunk.

I could try to copy the code found in Utility.codeToString() but before
I do that I would like to know if there is a better (== easier) way.

Thanks,

Lars


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to