[Soot-list] error parsing jimple file

Sergio Ferrero sferrero at ensoftcorp.com
Wed Jul 24 17:39:17 EDT 2013


I'm using Soot (develop branch) to generate jimple files out of an android
apk.
My goal is to open the jimple files in an editor in Eclipse. I'm extending
the JimpleEditor that comes in the Soot plugin for eclipse.

I'd like to extend the JimpleEditor capabilities and for that I need to
work with the Jimple IR, that is the java objects (SootClass, SootMethod,
etc) created by Walker.java.

I'm using the Jimple parser (soot.jimple.parser.parser.Parser) to create a
Jimple AST (classes in soot.jimple.parser.node) and then invoking
Walker.java to create the in-memory representation of the jimple file
(classes are in soot.jimple and soot.jimple.internal).

This is part of the code that I have:

InputStream stream = new FileInputStream(f);
Parser p = new Parser(new Lexer(new PushbackReader(new EscapedReader(
new BufferedReader(new InputStreamReader(stream))), 1024)));
Start sableAST = p.parse();
Walker w = new Walker(SootResolver.v());
sableAST.apply(w);
SootClass sootClass = w.getSootClass();


I found that Walker fails whenever it encounters a method call on an
Interface object.
Below, it's the method (Jimple code) in which Walker fails:

 public void add(java.util.List, java.lang.String)
{
  soot.test.InterfaceMethodCall this;
  java.util.List l;
  java.lang.String s;
  boolean temp$0;

  this := @this: soot.test.InterfaceMethodCall;
  l := @parameter0: java.util.List;
  s := @parameter1: java.lang.String;
  temp$0 = interfaceinvoke l.<java.util.List: boolean
add(java.lang.Object)>(s);
  return;
}


It fails when Walker visits the 'add' method invocation (stmt before the
return)
The exception is the following:

java.lang.RuntimeException: Trying to create interface invoke expression
for non-interface type: java.util.List Use JVirtualInvokeExpr or
JSpecialInvokeExpr instead!
 at
soot.jimple.internal.JInterfaceInvokeExpr.<init>(JInterfaceInvokeExpr.java:46)
at soot.jimple.Jimple.newInterfaceInvokeExpr(Jimple.java:474)
 at soot.jimple.parser.Walker.outANonstaticInvokeExpr(Walker.java...


I debugged the code and this seems to be related to the fact that the
SootClass created for java.util.List, which is the declaringClass for the
'add' method, does not yet have the modifiers properly set to indicate it
is an interface.
The SootClass for java.util.List is created in the
Walker.outAMethodSignature(AMethodSignature node) method but modifiers are
not set at that time.

It seems that java.util.List has to be resolved, so that modifiers are set,
before Walker.outANonstaticInvokeExpr() is called.
Or otherwise, should I make java.util.List a phantom class by calling the
the method.declaringClass().setPhantomClass() method before calling
Jimple.v().newInterfaceInvokeExpr(l, method, args) in
outANonstaticInvokeExpr(), so that the exception is not thrown?

Could you tell me what is the best way to fix this problem?

Thanks in advance,
Sergio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130724/9741d12f/attachment.html 


More information about the Soot-list mailing list