wala / WALA

T.J. Watson Libraries for Analysis, with frontends for Java, Android, and JavaScript, and may common static program analyses
http://github.com/wala/WALA
Eclipse Public License 2.0
762 stars 223 forks source link

A bug about the class hierarchy #1376

Open kitty-1998 opened 8 months ago

kitty-1998 commented 8 months ago

I use Wala to construct a call graph via CHA algorithm, but the call graph is empty (without nodes and edges). After an investgation, I find it may be caused by an incomplete class hierarchy.

Input file

The jar file is from Maven: https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.11.0

Wala setup

AnalysisScope scope = AnalysisScopeReader.instance.makeJavaBinaryAnalysisScope("Path/to/jar", walaExclusionFile);
scope.addToScope(javaScope);  // JDK jar
IClassHierarchy hierarchy = ClassHierarchyFactory.makeWithRoot(scope);
Iterable<Entrypoint> entryPoints = generateEntryPoints(hierarchy); // We involve many entry methods in this library, but the generateEntryPoints is too long to show here 
AnalysisOptions options = new AnalysisOptions(scope, entryPoints);
CallGraph cg = new CHACallGraph(hierarchy);
try {
    ((CHACallGraph) cg).init(entryPoints);
} catch (CancelException e) {
    throw new RuntimeException(e);
}

How to reproduce

Analyze the jar file with the setup above.

Expected behavior

Finish analysis with correct graph.

Stacktrace

There is no exception, but the hierarchy didn't contain any class in the jar to be analyzed. See the figuare below, I debugged the program, but found no ok-http related classes in the hierarchy. image

msridhar commented 5 months ago

@kitty-1998 I'm really sorry for my slow response here. If this is still an issue for you, can you confirm that with your same driver code you are able to successfully construct a CHA call graph for other jar files? In other words, is this an issue specifically with the okhttp jar? Thanks and sorry again for the delay.