代码之家  ›  专栏  ›  技术社区  ›  Amir Afghani

使用Jode反编译*any*类时遇到问题

  •  0
  • Amir Afghani  · 技术社区  · 16 年前

    Decompiler d = new Decompiler();
    try {
        FileWriter fw = new FileWriter("c:\\jode.txt");
    
        d.setClassPath("C:\\mycode");
    
        ProgressListener p = new ProgressListener() {
    
            public void updateProgress(double arg0, String arg1) {
                System.out.println("inside of progress listener with arg0 = " +arg0+ " and arg1 = " +arg1);
            }
        };
    
        d.decompile("Test.class" , fw, p);
    
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    

    我总是得到:

    Exception in thread "main" java.lang.NoClassDefFoundError: Test.class
            at jode.bytecode.ClassInfo.loadInfo(ClassInfo.java:620)
            at jode.decompiler.ClassAnalyzer.<init>(ClassAnalyzer.java:86)
            at jode.decompiler.ClassAnalyzer.<init>(ClassAnalyzer.java:123)
            at jode.decompiler.Decompiler.decompile(Decompiler.java:191)
            at testdecompiler.Main.main(Main.java:45)
    

    jode.decompiler.Main.decompile(...)
    

    一切正常,但我不能使用这个类文件,因为它位于仅遵循GPL的jode.jar中。

    4 回复  |  直到 16 年前
        1
  •  1
  •   JZeeb    16 年前

    我能够用他们网站上提供的所有不同的jode二进制版本重现这个问题。当我使用svn的主线构建新版本的jode时,它工作得很好。我在一个jode论坛上也看到了一个用户抱怨NoClassDefFound问题的条目。他的情况听起来略有不同,但jode开发人员建议他使用svn的主线而不是预构建二进制文件。

        2
  •  0
  •   Vladimir Dyuzhev    16 年前
    d.setClassPath("C:\\mycode");
    

    在我看来,这个类路径非常短。

        3
  •  0
  •   hypercube    16 年前

    这是一个猜测,因为我不喜欢反编译类,但我认为你应该使用

    d.decompile("Test" , fw, p);
    

    而不是你现在使用的。这可能类似于

    Class.forName("ClassName")
    

    没有“class”后缀。

        4
  •  0
  •   dz.    16 年前

    更新:我最初的假设是错误的,而且糟糕的是,据我所知,最初的异常/消息被丢弃了。JODE失败的代码如下:

     try {
          DataInputStream input = new DataInputStream
              (new BufferedInputStream
               (classpath.getFile(name.replace('.', '/') + ".class")));
            read(input, howMuch);            
    
      } catch (IOException ex) {
            String message = ex.getMessage();
          if ((howMuch & ~(FIELDS|METHODS|HIERARCHY
                           |INNERCLASSES|OUTERCLASSES)) != 0) {
              throw new NoClassDefFoundError(name);
            }
    

    由于必须抛出IOException才能获取NoClassDefFound,请检查有关IO子系统的任何内容,例如file.encoding。我想你应该修补JODE以获取详细的错误消息或调试到这一点。