Пример #1
0
  /**
   * Loads a single class file.
   *
   * @param classFile
   * @throws ClassNotFoundException
   */
  public Application(String classFile) throws ClassNotFoundException {
    loader = new ClassFileLoader();
    context = new PersistentBloatContext(loader);

    ClassInfo info = loader.loadClass(classFile);
    classes = new ClassNode[] {new ClassNode(info, context.editClass(info))};
  }
Пример #2
0
  public Application(ZipFile archive) throws ClassNotFoundException {
    loader = new ClassFileLoader();
    context = new PersistentBloatContext(loader);

    ClassInfo[] classInfos = loader.loadClassesFromZipFile(archive);
    classes = new ClassNode[classInfos.length];

    boolean removeNulls = false;
    for (int i = 0; i < classes.length; i++) {
      ClassInfo info = classInfos[i];
      if (info == null) {
        removeNulls = true;
        continue;
      }

      classes[i] = new ClassNode(info, context.editClass(info));
    }

    if (removeNulls) {
      ArrayList<ClassNode> classList = new ArrayList<ClassNode>();
      for (ClassNode c : classes) {
        if (c != null) {
          classList.add(c);
        }
      }

      classes = classList.toArray(new ClassNode[0]);
    }
  }