Exemplo n.º 1
0
  public ClassNode getClassNodeFromFile(File file, String clsName) {
    JadxDecompiler d = new JadxDecompiler(getArgs());
    try {
      d.loadFile(file);
    } catch (JadxException e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
    RootNode root = JadxInternalAccess.getRoot(d);
    root.getResourcesNames().putAll(resMap);

    ClassNode cls = root.searchClassByName(clsName);
    assertThat("Class not found: " + clsName, cls, notNullValue());
    assertThat(clsName, is(cls.getClassInfo().getFullName()));

    if (unloadCls) {
      decompile(d, cls);
    } else {
      decompileWithoutUnload(d, cls);
    }

    System.out.println("-----------------------------------------------------------");
    System.out.println(cls.getCode());
    System.out.println("-----------------------------------------------------------");

    checkCode(cls);
    compile(cls);
    runAutoCheck(clsName);
    return cls;
  }
Exemplo n.º 2
0
 private boolean process() {
   if (isPrintHelp()) {
     printUsage();
     return false;
   }
   try {
     if (threadsCount <= 0) {
       throw new JadxException("Threads count must be positive");
     }
     if (files != null) {
       for (String fileName : files) {
         File file = new File(fileName);
         if (file.exists()) {
           input.add(file);
         } else {
           throw new JadxException("File not found: " + file);
         }
       }
     }
     if (input.size() > 1) {
       throw new JadxException("Only one input file is supported");
     }
     if (outDirName != null) {
       outputDir = new File(outDirName);
     }
     if (isVerbose()) {
       ch.qos.logback.classic.Logger rootLogger =
           (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
       // remove INFO ThresholdFilter
       Appender<ILoggingEvent> appender = rootLogger.getAppender("STDOUT");
       if (appender != null) {
         appender.clearAllFilters();
       }
     }
   } catch (JadxException e) {
     System.err.println("ERROR: " + e.getMessage());
     printUsage();
     return false;
   }
   return true;
 }