为什么Soot总是说我要加载的类是一个幻像类,即使它不存在

时间:2014-12-09 16:23:22

标签: soot

此soot类加载一个类并打印方法的数量。 当我给出要加载的类的正确名称时,表示该类是幻像。同样,当该类不存在时,它会给出相同的消息。我不知道我做错了什么。

public class Loader {
    public static void main(String args[]){

             List<String> projectPaths;
            String classPath;
             String highLevelPackageName;
            classPath = "C:\\Users\\Alastair\\workspace1\\Interview\\bin";

            projectPaths = new ArrayList<String>();

            projectPaths.add(classPath);

            Options.v().set_allow_phantom_refs(true);
            Options.v().set_whole_program(true);
            Options.v().set_app(true);
            Options.v().set_no_bodies_for_excluded(true);
            Options.v().set_process_dir(projectPaths);

            String previousClassPath = Scene.v().getSootClassPath();
            previousClassPath += ";" + classPath;

            Scene.v().setSootClassPath(previousClassPath);



            SootClass sootClass = Scene.v().loadClassAndSupport("Diagonal.class");

            sootClass.setApplicationClass();
            System.out.println(sootClass.getMethodCount());
    }
}

这是我要加载的课程。

public class Diagonal {

    public static void main(String args[]) {
        diagonal();
        lefttriangle();
        righttriangle();
        tree();
    }

    public static void diagonal() {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if (i == j) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
    }

    public static void lefttriangle() {
        for(int i=0;i<6;i++){
            for(int j=0;j<6;j++){
                if(j<=i){
                    System.out.print("*");
                }
                else{
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
    }

    public static void righttriangle(){
        for(int i=0;i<7;i++){
            for(int j=7;j>0;j--){
                if(i<j){
                    System.out.print(" ");
                }else{
                    System.out.print("*");
                }

            }
            System.out.println("");
        }
    }

    public static void tree(){
        for(int i=1;i<=7;i++){
            for(int j=7;j>i;j--){
                    System.out.print(" ");
            }
            for(int j = 1; j < i*2; j++){

                    System.out.print("*");

            }
            System.out.println("");
        }
    }



}

1 个答案:

答案 0 :(得分:1)

幻像类是隐式创建的类,这些类在Soot的类路径中不存在。要解决此问题,请确保您引用的类位于Soot的类路径中。

相关问题