[Soot-list] Truncated class file
Eduardo S. Cordeiro
cordeiro at dcc.ufmg.br
Mon May 8 15:28:00 EDT 2006
I found that a method in the original class file (before transform),
which actually defined an interface, contains a"deprecated" attribute
instead of no code. Since it's a third-party jar file I don't know
whether it was compiled with java 1.5 compliance, but Jasmin actually
reports this during transformation, but I missed it before (sorry, my
mistake)...
Thanks everybody for the help
Patrick Lam wrote:
> Eduardo S. Cordeiro wrote:
>
>> Patrick,
>>
>> I've posted a zip file with the "truncated" class files to
>> www.dcc.ufmg.br/~cordeiro/trabalho/example.zip
>>
>> The code I use to remove methods is:
>> private void removeMethods(List methodsToRemove, SootClass clazz) {
>> Iterator i = methodsToRemove.iterator();
>> while (i.hasNext()) {
>> SootMethod method = (SootMethod) i.next();
>> clazz.removeMethod(method);
>> }
>> }
>>
>> And the code to replace a call target:
>> protected void removeInconsistentCalls(Body body) {
>> SootClass clazz = body.getMethod().getDeclaringClass();
>> Iterator stmtIt = body.getUnits().snapshotIterator();
>> while (stmtIt.hasNext()) {
>> Stmt stmt = (Stmt) stmtIt.next();
>>
>> // this matches a simple foo() as well as f = foo()
>> // stmt instanceof InvokeStmt misses the latter
>> // (I just had to comment on this issue after
>> // spending a full day of debugging to find it)
>> if (stmt.containsInvokeExpr()) {
>> InvokeExpr invkExpr = stmt.getInvokeExpr();
>> SootMethodRef calledMethodRef = invkExpr.getMethodRef();
>> if
>> (!clazz.declaresMethod(calledMethodRef.getSubSignature())) {
>> InlineMethod replNode =
>> (InlineMethod)
>> signaturesToNodes.get(calledMethodRef.getSubSignature().getString());
>> if (replNode != null) { // if
>> this method should really be replaced
>> // replacement is made even if calledMethod is
>> its own pivot (no harm done)
>> SootMethod replMethod =
>> colorPivots[replNode.getColor()].getMethod();
>>
>> invkExpr.setMethodRef(replMethod.makeRef());
>> }
>> }
>> }
>> }
>> }
>>
>> Ignoring the data structures used (colorPivots, InlineMethod,
>> signaturesToNodes), since they're correctly filled in previous steps,
>> are the Soot-related instructions correct?
>
>
> I can't see any mistake at first glance. I need to work on my thesis
> this afternoon, but I'll try to see if I can look at it a bit longer
> this evening.
>
> What if you didn't remove methods?
>
> pat
>
More information about the Soot-list
mailing list