mistupv / JavaSlicer

A program slicer for Java, based on the system dependence graph (SDG).
https://mist.dsic.upv.es/JavaSlicer/demo/
GNU Affero General Public License v3.0
52 stars 18 forks source link

Exception in thread "main" UnsolvedSymbolException{context='null', name='AbstractTestCase', cause='null'} #47

Open HickeyHsu opened 3 years ago

HickeyHsu commented 3 years ago

Exception in thread "main" UnsolvedSymbolException{context='null', name='AbstractTestCase', cause='null'} at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(JavaParserFacade.java:670) at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(JavaParserFacade.java:645) at com.github.javaparser.symbolsolver.JavaSymbolSolver.toResolvedType(JavaSymbolSolver.java:271) at com.github.javaparser.ast.type.ClassOrInterfaceType.resolve(ClassOrInterfaceType.java:301) at es.upv.mist.slicing.graphs.ClassGraph.lambda$18(ClassGraph.java:259) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at com.github.javaparser.ast.NodeList.forEach(NodeList.java:290) at es.upv.mist.slicing.graphs.ClassGraph.addClassEdges(ClassGraph.java:258) at es.upv.mist.slicing.graphs.ClassGraph$2.visit(ClassGraph.java:221) at es.upv.mist.slicing.graphs.ClassGraph$2.visit(ClassGraph.java:1) at com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.accept(ClassOrInterfaceDeclaration.java:100) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.lambda$visit$43(VoidVisitorAdapter.java:175) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at com.github.javaparser.ast.NodeList.forEach(NodeList.java:290) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:175) at com.github.javaparser.ast.CompilationUnit.accept(CompilationUnit.java:138) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:623) at com.github.javaparser.ast.NodeList.accept(NodeList.java:282) at es.upv.mist.slicing.graphs.ClassGraph.buildEdges(ClassGraph.java:214) at es.upv.mist.slicing.graphs.ClassGraph.build(ClassGraph.java:121) at es.upv.mist.slicing.graphs.sdg.SDG$Builder.createClassGraph(SDG.java:162) at es.upv.mist.slicing.graphs.sdg.SDG$Builder.build(SDG.java:119) at es.upv.mist.slicing.graphs.sdg.SDG.build(SDG.java:75) at es.upv.mist.slicing.cli.Slicer.slice(Slicer.java:245) at es.upv.mist.slicing.cli.Slicer.main(Slicer.java:301)

cargaji commented 3 years ago

Hi there! The UnsolvedSymbolException is related to missing some classes in part of the analysis. I'd suggest including the libraries' source code with -i <path> or the jars in the classpath (see the readme for an example). In the future we may support these cases without including libraries that you don't want to analyze, but the current design requires that all libraries be present.

If that doesn't solve your problem, I'd need to know more information, like the program and criterion you've inputed into the program.

diohabara commented 1 year ago

Hi @cargaji,

I'd suggest including the libraries' source code with -i or the jars in the classpath (see the readme for an example)

I have the same problem and did just like you instructed. However, the problem still persists. What am I doing wrong?

The target of static slicing is gwt/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiAbstractMethod.java from the project root, and the libraries it uses are in gwt-lib/ from the project root too.

 69k gwt-api-checker.jar
182k gwt-codeserver.jar
 45M gwt-dev.jar
 33k gwt-doctool.jar
277k gwt-servlet-deps.jar
9.9M gwt-servlet.jar
 15M gwt-user.jar
 35k requestfactory-apt-src.jar
 90k requestfactory-apt.jar
427k requestfactory-client+src.jar
100k requestfactory-client-src.jar
328k requestfactory-client.jar
1.1M requestfactory-server+src.jar
133k requestfactory-server-src.jar
1.0M requestfactory-server.jar

When I execute the following commands, I get the successive errors. How can I fix it?

with -cp

$ java -cp gwt-lib/gwt-api-checker.jar -jar sdg-cli/target/sdg-cli-1.3.0-jar-with-dependencies.jar -c gwt/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiAbstractMethod.java#147:ret 
Jun 20, 2023 4:45:41 PM es.upv.mist.slicing.cli.Slicer slice
INFO: Configuring JavaParser
Jun 20, 2023 4:45:41 PM es.upv.mist.slicing.cli.Slicer slice
INFO: Parsing files
Jun 20, 2023 4:45:41 PM es.upv.mist.slicing.cli.Slicer slice
INFO: Building the SDG
Exception in thread "main" UnsolvedSymbolException{context='null', name='ApiElement', cause='null'}
        at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(JavaParserFacade.java:643)
        at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(JavaParserFacade.java:618)
        at com.github.javaparser.symbolsolver.JavaSymbolSolver.toResolvedType(JavaSymbolSolver.java:281)
        at com.github.javaparser.ast.type.ClassOrInterfaceType.resolve(ClassOrInterfaceType.java:315)
        at es.upv.mist.slicing.graphs.ClassGraph.lambda$addClassEdges$13(ClassGraph.java:447)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at com.github.javaparser.ast.NodeList.forEach(NodeList.java:290)
        at es.upv.mist.slicing.graphs.ClassGraph.addClassEdges(ClassGraph.java:446)
        at es.upv.mist.slicing.graphs.ClassGraph$2.visit(ClassGraph.java:396)
        at es.upv.mist.slicing.graphs.ClassGraph$2.visit(ClassGraph.java:389)
        at com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.accept(ClassOrInterfaceDeclaration.java:98)
        at com.github.javaparser.ast.visitor.VoidVisitorAdapter.lambda$visit$43(VoidVisitorAdapter.java:175)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at com.github.javaparser.ast.NodeList.forEach(NodeList.java:290)
        at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:175)
        at com.github.javaparser.ast.CompilationUnit.accept(CompilationUnit.java:133)
        at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:630)
        at com.github.javaparser.ast.NodeList.accept(NodeList.java:282)
        at es.upv.mist.slicing.graphs.ClassGraph.buildEdges(ClassGraph.java:389)
        at es.upv.mist.slicing.graphs.ClassGraph.build(ClassGraph.java:289)
        at es.upv.mist.slicing.graphs.sdg.SDG$Builder.createClassGraph(SDG.java:176)
        at es.upv.mist.slicing.graphs.jsysdg.JSysDG$Builder.createClassGraph(JSysDG.java:49)
        at es.upv.mist.slicing.graphs.sdg.SDG$Builder.build(SDG.java:125)
        at es.upv.mist.slicing.graphs.jsysdg.JSysDG$Builder.build(JSysDG.java:44)
        at es.upv.mist.slicing.graphs.sdg.SDG.build(SDG.java:73)
        at es.upv.mist.slicing.cli.Slicer.slice(Slicer.java:208)
        at es.upv.mist.slicing.cli.Slicer.main(Slicer.java:286)

with -i

$ java -jar sdg-cli/target/sdg-cli-1.3.0-jar-with-dependencies.jar -c gwt/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiAbstractMethod.java#147:ret -i gwt-lib                     
Jun 20, 2023 4:46:40 PM es.upv.mist.slicing.cli.Slicer slice
INFO: Configuring JavaParser
Jun 20, 2023 4:46:40 PM es.upv.mist.slicing.cli.Slicer slice
INFO: Parsing files
Jun 20, 2023 4:46:40 PM es.upv.mist.slicing.cli.Slicer slice
INFO: Building the SDG
Exception in thread "main" UnsolvedSymbolException{context='null', name='ApiElement', cause='null'}
        at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(JavaParserFacade.java:643)
        at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(JavaParserFacade.java:618)
        at com.github.javaparser.symbolsolver.JavaSymbolSolver.toResolvedType(JavaSymbolSolver.java:281)
        at com.github.javaparser.ast.type.ClassOrInterfaceType.resolve(ClassOrInterfaceType.java:315)
        at es.upv.mist.slicing.graphs.ClassGraph.lambda$addClassEdges$13(ClassGraph.java:447)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at com.github.javaparser.ast.NodeList.forEach(NodeList.java:290)
        at es.upv.mist.slicing.graphs.ClassGraph.addClassEdges(ClassGraph.java:446)
        at es.upv.mist.slicing.graphs.ClassGraph$2.visit(ClassGraph.java:396)
        at es.upv.mist.slicing.graphs.ClassGraph$2.visit(ClassGraph.java:389)
        at com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.accept(ClassOrInterfaceDeclaration.java:98)
        at com.github.javaparser.ast.visitor.VoidVisitorAdapter.lambda$visit$43(VoidVisitorAdapter.java:175)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at com.github.javaparser.ast.NodeList.forEach(NodeList.java:290)
        at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:175)
        at com.github.javaparser.ast.CompilationUnit.accept(CompilationUnit.java:133)
        at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:630)
        at com.github.javaparser.ast.NodeList.accept(NodeList.java:282)
        at es.upv.mist.slicing.graphs.ClassGraph.buildEdges(ClassGraph.java:389)
        at es.upv.mist.slicing.graphs.ClassGraph.build(ClassGraph.java:289)
        at es.upv.mist.slicing.graphs.sdg.SDG$Builder.createClassGraph(SDG.java:176)
        at es.upv.mist.slicing.graphs.jsysdg.JSysDG$Builder.createClassGraph(JSysDG.java:49)
        at es.upv.mist.slicing.graphs.sdg.SDG$Builder.build(SDG.java:125)
        at es.upv.mist.slicing.graphs.jsysdg.JSysDG$Builder.build(JSysDG.java:44)
        at es.upv.mist.slicing.graphs.sdg.SDG.build(SDG.java:73)
        at es.upv.mist.slicing.cli.Slicer.slice(Slicer.java:208)
        at es.upv.mist.slicing.cli.Slicer.main(Slicer.java:286)

I also followed https://github.com/mistupv/JavaSlicer/issues/45#issuecomment-774057836 and set change this to false, but it's still not working.

cargaji commented 1 year ago

Hi @diohabara, I can confirm the bug locally. I have had some problems with the symbol solver we're using, to the point of having forked it and placed it as a module to fix a couple bugs. I'll try to figure out a patch, but it may take a week or two.

diohabara commented 1 year ago

@cargaji Thank you for the response! Please let me know if I have anything to help you.

diohabara commented 1 year ago

@cargaji

Hi, I just tried these commands to confirm that some commits were working well with third libraries.

mvn package -Dmaven.test.skip
java -cp gwt-lib/gwt-api-checker.jar -jar sdg-cli/target/sdg-cli-1.3.0-jar-with-dependencies.jar -c gwt/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiAbstractMethod.java#147:ret
java -jar sdg-cli/target/sdg-cli-1.3.0-jar-with-dependencies.jar -c gwt/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiAbstractMethod.java#147:ret -i gwt-lib

However, I couldn't find any good commits from given tags(https://github.com/mistupv/JavaSlicer/tags).

Do you happen to remember at what commit the feature was working correctly?

In my plan, if we know a initial good commit, we can try git bisect and detect the initial bad commit.

diohabara commented 12 months ago

@cargaji

I'm exeperimenting using this PR.

https://github.com/mistupv/JavaSlicer/pull/51