[go: up one dir, main page]

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

failed to load impl class com.ibm.wala.cast.java.translator.polyglot.PolyglotSourceLoaderImpl #1333

Open
xiezhuokui opened this issue Oct 28, 2023 · 1 comment

Comments

@xiezhuokui
Copy link

Hi, when I am trying to build class hierarchy, I encountered this error.

Part of my code is,

            // For create the Analysis Scope
            ScopeConfiguration configuration = new ScopeConfiguration(mainInstance.projectPath, mainInstance.sourceType, mainInstance.exclusion);
            AnalysisScope scope = configuration.getAnalysisScope();

            // Build Class Hierarchy
            IClassHierarchy cha = ClassHierarchyFactory.make(scope);

The stacktrace is

java.lang.ClassNotFoundException: com.ibm.wala.cast.java.translator.polyglot.PolyglotSourceLoaderImpl
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Unknown Source)
	at com.ibm.wala.classLoader.ClassLoaderFactoryImpl.makeNewClassLoader(ClassLoaderFactoryImpl.java:106)
	at com.ibm.wala.classLoader.ClassLoaderFactoryImpl.getLoader(ClassLoaderFactoryImpl.java:61)
	at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:270)
	at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:203)
	at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:85)
	at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:71)
	at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:28)
	at org.branson.slicer.Main.main(Main.java:106)
com.ibm.wala.ipa.cha.ClassHierarchyException: failed to load root <Primordial,Ljava/lang/Object> of class hierarchy
	at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:299)
	at com.ibm.wala.ipa.cha.ClassHierarchy.<init>(ClassHierarchy.java:203)
	at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:85)
	at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:71)
	at com.ibm.wala.ipa.cha.ClassHierarchyFactory.make(ClassHierarchyFactory.java:28)
	at org.branson.slicer.Main.main(Main.java:106)

I searched the whole project and found this. I think it is the reason why this error happened.

image

I've checked and noticed that there is no "PolyglotSourceLoaderImpl" in WALA project currently. And I found a similar SourceLoaderImpl called "JavaSourceLoaderImpl" at.com.ibm.wala.cast.java/1.6.2/com.ibm.wala.cast.java-1.6.2.jar!/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.class". Is possible this is a potential bug? Or can you show me how to fix this? Thank you!

@msridhar
Copy link
Member
msridhar commented Nov 1, 2023

You're right that there is a bug here. Unfortunately I don't know the right fix, as I'm not very familiar with this code. We have JDTSourceLoaderImpl and ECJSourceLoaderImpl and it's not clear what should be chosen by default in the code above. Maybe that code is old and should be removed or just fail fast? @juliandolby any ideas here?

In the meantime, does it work as a workaround to do something like this?

IClassHierarchy cha = ClassHierarchyFactory.make(scope, getLoaderFactory(scope));

Where getLoaderFactory() is:

protected ClassLoaderFactory getLoaderFactory(AnalysisScope scope) {
return new ECJClassLoaderFactory(scope.getExclusions());
}

I'm assuming you're using ECJ. If you're using the JDT Eclipse plugin stuff there would be some slightly different code to use. Let me know if that works.

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

2 participants