You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by DHANUSHIYADEVI December 2, 2024
I am new to SootUp and trying to GET method body from a Soot class, but I'm encountering a ClassCastException for certain classes, as shown below:
Set<JavaSootMethod> sootMethods = sootClass.getMethods();
for (JavaSootMethod sootMethod : sootMethods) {
System.out.println("Going to parse :: "+sootMethod.getSignature().toString());
if (sootMethod.hasBody()) {
Body body = sootMethod.getBody(); // Getting exception here
}
}
Caused by: java.lang.ClassCastException: class sootup.core.jimple.common.constant.StringConstant cannot be cast to class sootup.core.jimple.basic.Local (sootup.core.jimple.common.constant.StringConstant and sootup.core.jimple.basic.Local are in unnamed module of loader 'app')
at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.visit(TypePromotionVisitor.java:76)
at sootup.java.core.interceptors.typeresolving.TypeChecker.handleInvokeExpr(TypeChecker.java:300)
at sootup.java.core.interceptors.typeresolving.TypeChecker.caseAssignStmt(TypeChecker.java:220)
at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:201)
at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:59)
at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.getPromotedTyping(TypePromotionVisitor.java:47)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at sootup.java.core.interceptors.typeresolving.TypeResolver.resolve(TypeResolver.java:81)
at sootup.java.core.interceptors.TypeAssigner.interceptBody(TypeAssigner.java:42)
at sootup.java.bytecode.frontend.AsmMethodSource.resolveBody(AsmMethodSource.java:234)
... 8 more
Would greatly appreciate any confirmation or corrections, as I’m unsure why I’m getting a ClassCastException for only certain classes. Am I using the correct approach to retrieve the method body? I’m following the example provided in this link.
Thank you in advance for your time and assistance.
The text was updated successfully, but these errors were encountered:
I tried running the example:
1 parent pom file missing
2 SootUp version used is 1.1.2, please use latest version. Adjust imports according to the latest version
3 Output after applying DeadAssignmentEliminator is correct (removed assignment part)
Discussed in #1142
Originally posted by DHANUSHIYADEVI December 2, 2024
I am new to SootUp and trying to GET method body from a Soot class, but I'm encountering a ClassCastException for certain classes, as shown below:
Caused by: java.lang.ClassCastException: class sootup.core.jimple.common.constant.StringConstant cannot be cast to class sootup.core.jimple.basic.Local (sootup.core.jimple.common.constant.StringConstant and sootup.core.jimple.basic.Local are in unnamed module of loader 'app')
at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.visit(TypePromotionVisitor.java:76)
at sootup.java.core.interceptors.typeresolving.TypeChecker.handleInvokeExpr(TypeChecker.java:300)
at sootup.java.core.interceptors.typeresolving.TypeChecker.caseAssignStmt(TypeChecker.java:220)
at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:201)
at sootup.core.jimple.common.stmt.JAssignStmt.accept(JAssignStmt.java:59)
at sootup.java.core.interceptors.typeresolving.TypePromotionVisitor.getPromotedTyping(TypePromotionVisitor.java:47)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at sootup.java.core.interceptors.typeresolving.TypeResolver.resolve(TypeResolver.java:81)
at sootup.java.core.interceptors.TypeAssigner.interceptBody(TypeAssigner.java:42)
at sootup.java.bytecode.frontend.AsmMethodSource.resolveBody(AsmMethodSource.java:234)
... 8 more
Would greatly appreciate any confirmation or corrections, as I’m unsure why I’m getting a ClassCastException for only certain classes. Am I using the correct approach to retrieve the method body? I’m following the example provided in this link.
Thank you in advance for your time and assistance.
The text was updated successfully, but these errors were encountered: