use soot API analysis java source code error
BACMiao opened this issue · 4 comments
Hello, I use your project to learn the soot framework. I directly git clone your code and use the commands ./gradlew run --args="HelloSoot"
'to execute, but the following error occurs every time. The java version I use is 1.8.0_241. what should I do, thank you very much!
Exception in thread "main" java.lang.Error: Error: Failed to load java.lang.CharSequence.
at soot.JastAddJ.PathPart.getCompilationUnit(PathPart.java:109)
at soot.JastAddJ.Program.getCompilationUnit(Program.java:844)
at soot.JastAddJ.Program.getLibCompilationUnit_compute(Program.java:1517)
at soot.JastAddJ.Program.getLibCompilationUnit(Program.java:1500)
at soot.JastAddJ.Program.lookupLibType_compute(Program.java:1465)
at soot.JastAddJ.Program.lookupLibType(Program.java:1433)
at soot.JastAddJ.Program.lookupType_compute(Program.java:1412)
at soot.JastAddJ.Program.lookupType(Program.java:1393)
at soot.JastAddJ.Program.Define_TypeDecl_lookupType(Program.java:1981)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.ASTNode.Define_TypeDecl_lookupType(ASTNode.java:1657)
at soot.JastAddJ.Expr.lookupType(Expr.java:1186)
at soot.JastAddJ.TypeAccess.decls_compute(TypeAccess.java:425)
at soot.JastAddJ.TypeAccess.decls(TypeAccess.java:414)
at soot.JastAddJ.TypeAccess.refined_TypeScopePropagation_TypeAccess_decl(TypeAccess.java:387)
at soot.JastAddJ.TypeAccess.decl_compute(TypeAccess.java:460)
at soot.JastAddJ.TypeAccess.decl(TypeAccess.java:452)
at soot.JastAddJ.TypeAccess.type_compute(TypeAccess.java:590)
at soot.JastAddJ.TypeAccess.type(TypeAccess.java:583)
at soot.JastAddJ.ParameterDeclaration.type_compute(ParameterDeclaration.java:479)
at soot.JastAddJ.ParameterDeclaration.type(ParameterDeclaration.java:472)
at soot.JastAddJ.MethodDecl.signature_compute(MethodDecl.java:1503)
at soot.JastAddJ.MethodDecl.signature(MethodDecl.java:1488)
at soot.JastAddJ.TypeDecl.localMethodsSignatureMap_compute(TypeDecl.java:2683)
at soot.JastAddJ.TypeDecl.localMethodsSignatureMap(TypeDecl.java:2669)
at soot.JastAddJ.ClassDecl.methodsSignatureMap_compute(ClassDecl.java:1102)
at soot.JastAddJ.ClassDecl.methodsSignatureMap(ClassDecl.java:1094)
at soot.JastAddJ.TypeDecl$2.<init>(TypeDecl.java:513)
at soot.JastAddJ.TypeDecl.methodsIterator(TypeDecl.java:512)
at soot.JastAddJ.TypeDecl.methodsNameMap_compute(TypeDecl.java:2619)
at soot.JastAddJ.TypeDecl.methodsNameMap(TypeDecl.java:2608)
at soot.JastAddJ.TypeDecl.memberMethods(TypeDecl.java:2578)
at soot.JastAddJ.AbstractDot.Define_Collection_lookupMethod(AbstractDot.java:766)
at soot.JastAddJ.Expr.lookupMethod(Expr.java:1032)
at soot.JastAddJ.MethodAccess.decls_compute(MethodAccess.java:1094)
at soot.JastAddJ.MethodAccess.decls(MethodAccess.java:1086)
at soot.JastAddJ.MethodAccess.decl_compute(MethodAccess.java:1128)
at soot.JastAddJ.MethodAccess.decl(MethodAccess.java:1120)
at soot.JastAddJ.MethodAccess.nameCheck(MethodAccess.java:206)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1283)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.ASTNode.collectErrors(ASTNode.java:1292)
at soot.JastAddJ.CompilationUnit.errorCheck(CompilationUnit.java:178)
at soot.JastAddInitialResolver.formAst(JastAddInitialResolver.java:67)
at soot.JavaClassSource.resolve(JavaClassSource.java:66)
at soot.SootResolver.bringToHierarchyUnchecked(SootResolver.java:240)
at soot.SootResolver.bringToHierarchy(SootResolver.java:214)
at soot.SootResolver.bringToSignatures(SootResolver.java:279)
at soot.SootResolver.processResolveWorklist(SootResolver.java:172)
at soot.SootResolver.resolveClass(SootResolver.java:134)
at soot.Scene.loadClass(Scene.java:942)
at soot.Scene.loadClassAndSupport(Scene.java:927)
at dev.navids.soottutorial.hellosoot.HelloSoot.setupSoot(HelloSoot.java:26)
at dev.navids.soottutorial.hellosoot.HelloSoot.main(HelloSoot.java:33)
at dev.navids.soottutorial.Main.main(Main.java:18)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 20492
at soot.JastAddJ.BytecodeParser.parseThisClass(BytecodeParser.java:437)
at soot.JastAddJ.BytecodeParser.parseTypeDecl(BytecodeParser.java:413)
at soot.JastAddJ.BytecodeParser.parse(BytecodeParser.java:331)
at soot.JastAddJ.BytecodeParser.read(BytecodeParser.java:27)
at soot.JastAddJ.PathPart.getCompilationUnit(PathPart.java:87)
... 70 more
The error will disappear if I remove the statement of System.out.println("FizzBuzz");
Did you run ./gradlew check
initially? This command (or cd demo && ./compile.sh && cd -
) compiles the Java files in the demo
directory. The java files in the demo
directory should be compiled with Java 8. It seems the problem that you face is related to these issues in official Soot repository (1,2,3).
Thank you for your answer, I am very grateful to you.
Did you run
./gradlew check
initially? This command (orcd demo && ./compile.sh && cd -
) compiles the Java files in thedemo
directory. The java files in thedemo
directory should be compiled with Java 8. It seems the problem that you face is related to these issues in official Soot repository (1,2,3).
Thank you.
It works for me, I use java version "1.8.0_261".