jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholson, Jonathan O H" <joh...@essex.ac.uk>
Subject Invokation and return statement analysis with BCEL
Date Wed, 07 Mar 2007 14:33:09 GMT
Heya guys,

I'm doing a research project in formal methods, and I'm looking into
BCEl to be able to provide me with certain information about a given
class (there are benefits, from our point of view, to class inspection
over source code inspection that I need not go into).

I have managed to program a vast majority of the features we require
pretty quickly, and I am more than glad to see the programs dependency
on CFParse disappear. The method that does the analysis is in this
format:

foreach(JavaClass c : somearray)
{
  // Inspect the class
  InstructionList list = c.getInstructionList();
  foreach(Instruction i : list.getInstructions())
  {
    switch(i.getOpcode())
    {
      // do something when certain instructions are found
    }
  }
}

There is no modification of the classes as they are processed, and
information is basically dumped into a database (currently to the screen
while debugging) as its found

Problems:
1) When a ARETURN instruction is found, I need to know the identifier
and type of the object being returned. Return type is not enough, and
from what I can see all methods in Java bytecode return
java.lang.Object, so using getType() on the ARETURN instruction doesn't
help either.
2) When an InvokeInstruction is found, I need to know the identifiers of
each of the objects used as arguments for the invoked method.

I understand the Java VM is stack based, so at first I thought it would
be logical to maintain a stack of variables so by knowing how many
things are removed from the stack (for example 1 in the case of
ARETURN... I think...) I can find out what idents/types are being used.

However I just cant get it to work. I'm not familiar enough with every
bytecode instruction to be able to do it. I have been looking at the
CodeHTML class to see how it works, but right now I can't get my head
around the logic.

If someone could help, give me example/pseudo code if you've done
something similar, direct me to a package/library that can provide me
with this information, etc, I would be very grateful.

Thanks all
Regards

Mac

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Mime
View raw message