Closed Eashurox closed 4 months ago
You are missing the relevant ECJ jars in your classpath. I just updated WALA-start to the latest WALA version (1.6.4). You can run the SourceDirCallGraph
by cloning that repo and then running something like:
./gradlew -PmainClass=com.ibm.wala.examples.drivers.SourceDirCallGraph run --args="-sourceDir /tmp/srcTest -mainClass LFoo"
You must run on a JDK 17 JVM for things to work. If you want to run outside of Maven and Gradle, it will be a bit painful. I suggest running the above ./gradlew
command with --debug
and it will print out the full classpath used, which you can use to figure out which jars you need for the classpath. But, generally, life will be easier if you run via some build system like Maven or Gradle.
I will go ahead and close this but please let us know if you need more help.
Hi @msridhar, Thank You for your quick response.
I have clone the repo and run the above given cmd from the WALA-start repo. I am still getting an error which is as follows:
`> Task :run FAILED
[-sourceDir, /Users/eashaan/eclipse-workspace/CGTest1/src/example_analysis, -mainClass, LCGTest]
Exception in thread "main" com.ibm.wala.ipa.cha.ClassHierarchyException: factory.getLoader failed
at com.ibm.wala.ipa.cha.ClassHierarchy.
FAILURE: Build failed with an exception.
Process 'command '/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1`
Build is successful using ./gradlew compileJava
. But there is warning: Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
I am attaching the debug log, I am unable to understand why factory.getLoader failed
?
P.S I am attaching the log file, when I added --debug option during the run. Can you please help me to figure this out? gradle_debug_log.txt
@Eashurox this looks to me to be an issue with the source frontend and missing code, which can unfortunately cause it to crash. We've had issues like this for a while. See https://github.com/wala/WALA/issues/99 for further discussion. To confirm, maybe you can try analyze a simple test class with an empty main method. If that goes through, the problem is elsewhere.
Hi, I wanted to use WALA for creating a call graph for a whole package or a Java project. I am referring to
WALA-start/src/main/java/com/ibm/wala/examples/drivers/SourceDirCallGraph.java
When I am running the
CGDirectory.java
-> (same as)SourceDirCallGraph.java
, I am receiving the following errors:Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor at com.ibm.wala.cast.java.translator.jdt.ecj.ECJSourceLoaderImpl.getTranslator(ECJSourceLoaderImpl.java:62) at com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.loadAllSources(JavaSourceLoaderImpl.java:601) at com.ibm.wala.classLoader.ClassLoaderImpl.init(ClassLoaderImpl.java:506) at com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.init(JavaSourceLoaderImpl.java:612) at com.ibm.wala.cast.java.translator.jdt.ecj.ECJClassLoaderFactory.makeNewClassLoader(ECJClassLoaderFactory.java:31) at com.ibm.wala.classLoader.ClassLoaderFactoryImpl.getLoader(ClassLoaderFactoryImpl.java:63) at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:271) at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:204) at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:87) at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:73) at directory_analysis.CGDirectory.doit(CGDirectory.java:117) at directory_analysis.CGDirectory.main(CGDirectory.java:51) Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at com.ibm.wala.cast.java.translator.jdt.ecj.ECJSourceLoaderImpl.getTranslator(ECJSourceLoaderImpl.java:62) at com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.loadAllSources(JavaSourceLoaderImpl.java:601) at com.ibm.wala.classLoader.ClassLoaderImpl.init(ClassLoaderImpl.java:506) at com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl.init(JavaSourceLoaderImpl.java:612) at com.ibm.wala.cast.java.translator.jdt.ecj.ECJClassLoaderFactory.makeNewClassLoader(ECJClassLoaderFactory.java:31) at com.ibm.wala.classLoader.ClassLoaderFactoryImpl.getLoader(ClassLoaderFactoryImpl.java:63) at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:271) at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:204) at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:87) at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:73) at directory_analysis.CGDirectory.doit(CGDirectory.java:117) at directory_analysis.CGDirectory.main(CGDirectory.java:51) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:419) at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192) at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
I am getting this error from this line from the source code:
IClassHierarchy cha = ClassHierarchyFactory.make(scope , new ECJClassLoaderFactory(scope.getExclusions()));
I ran the following cmd on the terminal:
java -cp "lib/*" src/directory_analysis/CGDirectory.java -sourceDir ./CGTest1/src/example_analysis -mainClass LCGenTest
Following is my directory structure:
The project is neither a maven nor gradle project and I directly using the jars taken from maven repository.
JDK : 17.0.11 OS: macOS Sonoma 14.5 (aarch64)
Can you anyone please tell me how to fix this error?