[Soot-list] JDK Support and Soot's Classpath Setting

Liu Yuan liuyuan at fastmail.com
Sun Mar 14 08:59:18 EDT 2021


Hi Andreas, thank you very much  for your reply!

I tried it again. Unfortunately, it doesn’t work. 

My case is following. Could you please give me an example at JDK >=9? thank you.

public static void main(String[] args) {

        String classesDir = "/Users/liuyuan/Workspaces/testCFGbySoot/testCFGbySoot/target/classes/";
        String mainClass = "org.yliu.test.soot.APP";
        TypeReferenceSequencesSolver analysis = new TypeReferenceSequencesSolver();
        //Options.v().set_prepend_classpath(true);
        PackManager.v().getPack("wjtp").add(new Transform("wjtp.TypeReferenceSequencesSolver", analysis));
        String jmodsPath = "/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home/jmods";
        Options.v().set_soot_classpath("VIRTUAL_FS_FOR_JDK" + File.pathSeparator + jmodsPath);

        Options.v().set_process_dir(Arrays.asList(classesDir));
        Options.v().set_whole_program(false);
        Options.v().setPhaseOption("jb", "preserve-source-annotations:true");
        Options.v().setPhaseOption("jj", "use-original-names:true");
        Options.v().set_keep_line_number(true);

        SootClass appclass = Scene.v().loadClassAndSupport(mainClass);
        Scene.v().setMainClass(appclass);
        Scene.v().loadNecessaryClasses();

        PackManager.v().runPacks();
    }

> 2021年3月14日 06:20,Andreas Peter Dann <adann at mail.uni-paderborn.de> 写道:
> 
> Hi Yuan,
> 
> thanks for your question. Unfortunately, the current documentation is not very clear on that topic because only a few people used Soot to analyze ByteCode for Java Version >= 9.
> At the end of the readme in the repo you'll find paragraph explaining how to run soot with Java >=9
> https://github.com/soot-oss/soot
> 
> In a nutshell,
> - please use the latest version from Maven Central https://soot-oss.github.io/soot/
> - run soot with a JDK >= 8 (maybe it works with an older JDK but I've never tested it)
> - if you want to run soot on JDK 8 but want to analyze the ByteCode of Java >=9  please run 
> 
> java -cp soot-trunk.jar soot.Main -cp VIRTUAL_FS_FOR_JDK
> 
> the string VIRTUAL_FS_FOR_JDK tells Soot to look into the virtual file system of JDKs >=9 to find the base classes.
> 
> Please feel free to improve the current documentation by making a pull request.
> 
> Best,
> 
> Andreas
> ---------
> 
> Am 12.03.21, 01:20 schrieb "Soot-list im Auftrag von Liu Yuan" <soot-list-bounces at CS.McGill.CA im Auftrag von liuyuan at fastmail.com>:
> 
>    Hi, I have JDK16 installed, and using the following to create a CFG.
> 
>    But I get an exception Unsupported class file major version 60, for SootClass appclass = Scene.v().loadClassAndSupport(mainClass);
> 
>    I think soot can run in JDK 16, so the reason is that the class files to be analyzed is compied at a high JDK version.
> 
>    So is there any method to solve it? If not, what is the supported scope of the JDK compiled version for the class files? 
> 
>    Besides, JDK 9+ remove the rt.jar and ice.jar. After searching, I learned that I only need to set prepend_classpat to load the necessary classes for soot to run. I don't know if it is correct. 
> 
>    Any suggestion is appreciated, thank you.
> 
>    public static void main(String[] args) {
> 
>            String classesDir = "./input/dataset/tracker-server.jar";
>            String mainClass = "org.traccar.Main";
>            TypeReferenceSequencesSolver analysis = new TypeReferenceSequencesSolver();
>            Options.v().set_prepend_classpath(true);
>            PackManager.v().getPack("wjtp").add(new Transform("wjtp.TypeReferenceSequencesSolver", analysis));
> 
>            Options.v().set_process_dir(Arrays.asList(classesDir));
>            Options.v().set_whole_program(false);
>            Options.v().setPhaseOption("jb", "preserve-source-annotations:true");
>            Options.v().setPhaseOption("jj", "use-original-names:true");
>            Options.v().set_keep_line_number(true);
> 
>            SootClass appclass = Scene.v().loadClassAndSupport(mainClass);
>            Scene.v().setMainClass(appclass);
>            Scene.v().loadNecessaryClasses();
> 
>            PackManager.v().runPacks();
>        }
> 
>    Best,
>    Yuan
>    _______________________________________________
>    Soot-list mailing list
>    Soot-list at CS.McGill.CA
>    https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20210314/82bd0806/attachment.html>


More information about the Soot-list mailing list