Пример #1
0
 /**
  * Look for the specified class. Return a ClassSource for it if found, or null if it was not
  * found.
  */
 public ClassSource find(String className) {
   // String fileName = className.replace('.', '/') + ".jimple";
   String fileName = className + ".jimple";
   SourceLocator.FoundFile file = SourceLocator.v().lookupInClassPath(fileName);
   if (file == null) return null;
   return new JimpleClassSource(className, file.inputStream());
 }
Пример #2
0
  /**
   * Load the set of classes that soot needs, including those specified on the command-line. This is
   * the standard way of initialising the list of classes soot should use.
   */
  public void loadNecessaryClasses() {
    loadBasicClasses();

    for (String name : Options.v().classes()) {
      loadNecessaryClass(name);
    }

    loadDynamicClasses();

    if (Options.v().oaat()) {
      if (Options.v().process_dir().isEmpty()) {
        throw new IllegalArgumentException(
            "If switch -oaat is used, then also -process-dir must be given.");
      }
    } else {
      for (final String path : Options.v().process_dir()) {
        for (String cl : SourceLocator.v().getClassesUnder(path)) {
          SootClass theClass = loadClassAndSupport(cl);
          theClass.setApplicationClass();
        }
      }
    }

    prepareClasses();
    setDoneResolving();
  }
Пример #3
0
  public void loadDynamicClasses() {
    dynamicClasses = new ArrayList<SootClass>();
    HashSet<String> dynClasses = new HashSet<String>();
    dynClasses.addAll(Options.v().dynamic_class());

    for (Iterator<String> pathIt = Options.v().dynamic_dir().iterator(); pathIt.hasNext(); ) {

      final String path = (String) pathIt.next();
      dynClasses.addAll(SourceLocator.v().getClassesUnder(path));
    }

    for (Iterator<String> pkgIt = Options.v().dynamic_package().iterator(); pkgIt.hasNext(); ) {

      final String pkg = (String) pkgIt.next();
      dynClasses.addAll(SourceLocator.v().classesInDynamicPackage(pkg));
    }

    for (String className : dynClasses) {

      dynamicClasses.add(loadClassAndSupport(className));
    }

    // remove non-concrete classes that may accidentally have been loaded
    for (Iterator<SootClass> iterator = dynamicClasses.iterator(); iterator.hasNext(); ) {
      SootClass c = iterator.next();
      if (!c.isConcrete()) {
        if (Options.v().verbose()) {
          G.v()
              .out
              .println(
                  "Warning: dynamic class "
                      + c.getName()
                      + " is abstract or an interface, and it will not be considered.");
        }
        iterator.remove();
      }
    }
  }
Пример #4
0
  /**
   * Attempts to load the given class and all of the required support classes. Returns the original
   * class if it was loaded, or null otherwise.
   */
  public SootClass tryLoadClass(String className, int desiredLevel) {
    /*
    if(Options.v().time())
        Main.v().resolveTimer.start();
    */

    setPhantomRefs(true);
    // SootResolver resolver = new SootResolver();
    if (!getPhantomRefs() && SourceLocator.v().getClassSource(className) == null) {
      setPhantomRefs(false);
      return null;
    }
    SootResolver resolver = SootResolver.v();
    SootClass toReturn = resolver.resolveClass(className, desiredLevel);
    setPhantomRefs(false);

    return toReturn;

    /*
    if(Options.v().time())
        Main.v().resolveTimer.end(); */
  }
Пример #5
0
 public void setSootClassPath(String p) {
   sootClassPath = p;
   SourceLocator.v().invalidateClassPath();
 }