[Soot-list] Preferred method to obtain SootMethod from .class or .java file

Rick van Galen rick at rickvangalen.nl
Mon May 9 13:28:00 EDT 2011


Hello there,

I'm writing a simple application that requires me to extract some specific
types of instructions from a program's main function. To help me do this,
I'm using the Soot library to help me analyze the statements in the program
individually. Right now my implementation kind of hangs on the fact that the
Soot Lexer or Parser throws exceptions when I try to parse a .class or .java
file.

After browsing the source code, it seemed to me the way to obtain a
JimpleAST from which I could parse was to construct a JimpleAST object with
a DataInputStream on a FileInputStream that pointed to the file I required.
When I try to run my tool this way, an exception is thrown. The exception I
get is "Exception in thread "main" java.lang.RuntimeException: Lexer
exception occurred: soot.jimple.parser.lexer.LexerException: [1,1] Unknown
token: Ê" when parsing a .class file, which seems like some character
encoding mismatch (but it's the same whether I use a DataInputStream or
BufferedInputStream). When trying to parse a .java file I get "[1,1]
expecting: 'abstract', 'final', 'native', (...)".

My question is: what is the preferred method for obtaining a SootMethod of
the main function from a .class or .java file? Should I do something else
with the InputStream I give to the JimpleAST, do I need to try another way
entirely?

Apologies if this is a basic question, but the tutorials, documentation and
source code I found were not helpful. Many thanks in advance!

Rick van Galen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20110509/6449bf66/attachment.html 


More information about the Soot-list mailing list