soot icon indicating copy to clipboard operation
soot copied to clipboard

RuntimeException: None of the basic classes could be loaded!

Open bichselb opened this issue 4 years ago • 7 comments

I am getting this exception:

java.lang.RuntimeException: None of the basic classes could be loaded! Check your Soot class path!

When running this code:

public static SootClass loadClass(ClassToVerify c){
		// reset previously loaded classes (important for consecutive analysis)
		logger.info("Resetting Soot.");
		G.reset();

		// Loading classes roughly follows this example:
		// https://github.com/Sable/heros/wiki/Example:-Using-Heros-with-Soot

		// construct classpath to use when loading the examples
		String javaHome = Configuration.props.getSootJavaHome(); // /usr/lib/jvm/java-13-openjdk-amd64
		if (javaHome == null) {
			logger.error("JAVA_HOME not set: " + javaHome);
		}
		String classpath = c.getClassPath().toString();
		// set classpath:
		logger.debug("Soot classpath:" + classpath); // Soot classpath: /analysis/target/test-classes
		Options.v().set_process_dir(new ArrayList<String>(Collections.singletonList(classpath)));
		Options.v().set_soot_classpath(classpath);

		// Enable whole-program mode
		Options.v().set_whole_program(true);
		Options.v().set_app(true);

		Options.v().set_allow_phantom_refs(true);

		// produce more detailed output (helpful for debugging purposes)
		Options.v().set_verbose(true);

		// load the class
		String mainClass = c.getPackageName();
		logger.info("Loading {} into Soot", mainClass); // Loading x.y.z.MyClass into Soot

		// Set the main class of the application to be analysed
		Options.v().set_main_class(mainClass);

		// Load the main class
		SootClass sc = Scene.v().loadClass(mainClass, SootClass.BODIES);
		sc.setApplicationClass();

		Scene.v().setEntryPoints(sc.getMethods());

		Scene.v().loadNecessaryClasses(); // RuntimeException

		return sc;
	}

I am running Java 13, and the class to be analyzed was also compiled with Java 13. I could compile the class I am analyzing with Java 8 if necessary.

Any help is appreciated!

bichselb avatar Feb 12 '21 17:02 bichselb

I am still unable to resolve this issue. Does Soot even support Java 13 (as in, running Soot on Java 13, analyzing code compiled by Java 13, but the analyzed code only uses Java 8 features)?

Is there any additional information I could provide to help locate the problem?

bichselb avatar Feb 18 '21 18:02 bichselb

After I year, I still was unable to resolve this issue. Any help would be appreciated.

bichselb avatar Feb 03 '22 20:02 bichselb

I have encountered the same problem. I guess you may add the jre lib (e.g., "/home/apr/env/jdk1.7.0_80/jre/lib/rt.jar" according to the jre you are using) into your soot classpath. Hope this helps.

DehengYang avatar Feb 08 '22 06:02 DehengYang

Thanks for the recommendation! Unfortunately, I have not found the analogous file for Java 13. Specifically, there seems to be no file "rt.jar" for Java 13 at all. The closest file I was able to find is "/usr/lib/jvm/java-13-openjdk-amd64/lib/jrt-fs.jar", but this did not work (not sure if I specified it correctly though).

Instead, I tried using the "rt.jar" file from Java 1.8, and have not obtained any obvious errors. Does this sound right to you?

bichselb avatar Feb 08 '22 09:02 bichselb

Yes, the Jdk 11 I used did not have "rt.jar" either. But when I used "rt.jar" file from Java 1.8 or 1.7, it works without any runtime error.

DehengYang avatar Feb 08 '22 11:02 DehengYang

I just noticed that this works, but is extremely slow - much slower in Java 13 than in Java 1.8. Is this expected? The analyzed program is tiny, but the above code takes ~5sec to load it under Java 13, and maybe 1sec under Java 1.8.

bichselb avatar Feb 23 '22 20:02 bichselb

I just noticed that this works, but is extremely slow - much slower in Java 13 than in Java 1.8. Is this expected? The analyzed program is tiny, but the above code takes ~5sec to load it under Java 13, and maybe 1sec under Java 1.8.

I'd like to know how you set the class path under Java 13 to solve the problem. I have run into the problem under Java 18. Thank you.

191220032 avatar Apr 21 '22 06:04 191220032