Image credit: Pexels

Soot Java 9 Support - Experimental Release

Finally, we made it! A first (experimental) version of soot-j9 is now available on github.

Get Soot-J9

You will find soot-j9 in the branch java9.

You can also download a deploy-ready jar from our build server.

What works?

  • Automatic modules (modules automatically created from jars in the module-path)
  • Named modules
  • Exploded modules
  • Modular jar files
  • Resolving modules in Soot’s ModuleScene
  • Spark

What does not work yet?

  • Anonymous modules (mixing module- and class-path)
  • Multi-module jar files

How to use Soot-j9?

Use from Source Code

To load modules in Soot’s ModuleScene from java:

// configure Soot's options
Options.v().set_prepend_classpath(true); // this is currently required to include the virtual java 9 filesystem jrt://
Options.v().set_soot_modulepath(modulePath);


// load classes from modules into Soot
  	Map<String, List<String>> map = ModulePathSourceLocator.v().getClassUnderModulePath(modulePath);
        for (String module : map.keySet()) {
            for (String klass : map.get(module)) {
                logger.info("Loaded Class: " + klass + "\n");
                loadClass(klass, false, module);

            }
    }


    //this must be called after all classes are resolved
    Scene.v().loadNecessaryClasses();


  public static SootClass loadClass(String name, boolean main, String module) {
        SootClass c = ModuleScene.v().loadClassAndSupport(name, Optional.of(module));
        c.setApplicationClass();
        if (main)
            Scene.v().setMainClass(c);
        return c;
    }

Use from the Command Line

To load modules and classes in Soot using java 1.8 run:

java -cp PATH_TO_JAVA9/jrt-fs.jar:soot-trunk-j9.jar soot.Main -pp -soot-modulepath modules/

Please replace PATH_TO_JAVA9 with the path to your local installation of java 9. The jrt-fs.jar is a built-in NIO FileSystem provider for the jrt:// filesystem java 9 uses that replaces the old rt.jar.

Related