Example #1
0
  private static boolean cullMethods(boolean found) {
    for (ByteCodeClass bc : classes) {
      bc.unmark();
      if (bc.isIsInterface() || bc.getBaseClass() == null) {
        continue;
      }
      for (BytecodeMethod mtd : bc.getMethods()) {
        if (mtd.isEliminated()
            || mtd.isUsedByNative()
            || mtd.isMain()
            || mtd.getMethodName().equals("__CLINIT__")
            || mtd.getMethodName().equals("finalize")
            || mtd.isNative()) {
          continue;
        }

        if (!isMethodUsed(mtd)) {
          if (isMethodUsedByBaseClassOrInterface(mtd, bc)) {
            continue;
          }
          found = true;
          mtd.setEliminated(true);
          /*if(ByteCodeTranslator.verbose) {
          System.out.println("Eliminating method: " + mtd.getClsName() + "." + mtd.getMethodName());
          }*/
        }
      }
    }
    return found;
  }
Example #2
0
  private static boolean isMethodUsed(BytecodeMethod m) {
    for (ByteCodeClass bc : classes) {
      for (BytecodeMethod mtd : bc.getMethods()) {
        if (mtd.isEliminated() || mtd == m) {
          continue;
        }
        if (mtd.isMethodUsed(m)) {
          return true;
        }
      }
    }

    // check native code
    StringBuilder b = new StringBuilder();
    m.appendFunctionPointer(b);
    String str = b.toString();
    for (String s : nativeSources) {
      if (s.contains(str)) {
        return true;
      }
    }

    return false;
  }