Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define entry point for JUnit4 and do across files analysis #1156

Open
xxwxxwen opened this issue Nov 21, 2022 · 0 comments
Open

define entry point for JUnit4 and do across files analysis #1156

xxwxxwen opened this issue Nov 21, 2022 · 0 comments

Comments

@xxwxxwen
Copy link

When I try to add JUnit4 entrypoint support #669 ,I failed to build call graph for the java class without main method. I'm not sure how to make call graph in a directory across multiple files #648 and analyze the source file(.java) dir of java programs #573.

How can we define our own entry point for JUnit4,and how to do across files analysis?

This is my code:
scope = new JavaSourceAnalysisScope(); scope.addSourceFileToScope(JavaSourceAnalysisScope.SOURCE,new File(path),".java");
scope.addClassFileToScope(ClassLoaderReference.Application,new File(path));
scope.addToScope(ClassLoaderReference.Application,new SourceDirectoryTreeModule(new File(path));
cha = ClassHierarchyFactory.make(scope,new ECJClassLoaderFactory(scope.getExclusions()));

Iterable entryPoints = findMethod1();
AnalysisOptions options = new AnalysisOptions(scope, entryPoints);
//options.setEntrypoints(entryPoints);

And this is the error.
Class Hierarchy construction failed
com.ibm.wala.ipa.cha.ClassHierarchyException: failed to load root <Primordial,Ljava/lang/Object> of class hierarchy
com.ibm.wala.ipa.cha.ClassHierarchyException: failed to load root <Primordial,Ljava/lang/Object> of class hierarchy
at com.ibm.wala.ipa.cha.ClassHierarchy.(ClassHierarchy.java)
at com.ibm.wala.ipa.cha.ClassHierarchy.(ClassHierarchy.java)
atcom.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java)
atcom.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java)
atcom.ibm.wala.cast.java.client.JavaSourceAnalysisEngine.buildClassHierarchy(JavaSourceAnalysisEngine.java)
atcom.ibm.wala.client.AbstractAnalysisEngine.defaultCallGraphBuilder(AbstractAnalysisEngine.java)
atcom.ibm.wala.client.AbstractAnalysisEngine.buildDefaultCallGraph(AbstractAnalysisEngine.java)
java.lang.IllegalArgumentException: cha is null
at com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(Util.java)
atcom.ibm.wala.cast.java.client.JavaSourceAnalysisEngine.makeDefaultEntrypoints(JavaSourceAnalysisEngine.java)
atcom.ibm.wala.client.AbstractAnalysisEngine.defaultCallGraphBuilder(AbstractAnalysisEngine.java)
atcom.ibm.wala.client.AbstractAnalysisEngine.buildDefaultCallGraph(AbstractAnalysisEngine.java)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant