Question

I've been staring at this issue for hours now. Any help is appreciated.

I wrote code that uses the Jode decompiler from the "embedded jode jar file". I want to use this version because it is under the Lesser GNU Public License.

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();
}

and I always get :

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)

If I use

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

things work - but I can't use this class file because it resides in the jode.jar that is only GPL.

Was it helpful?

Solution

I was able to reproduce the problem with all of the different binary versions of jode that are available from their web site. When I built a new version of jode using the mainline from svn, it worked fine. I also saw an entry in one of the jode forums where a user was complaining about the NoClassDefFound problem. His case sounded slightly different, but the jode developer suggested that he use the mainline from svn instead of the prebuild binary.

OTHER TIPS

d.setClassPath("C:\\mycode");

This classpath looks awfully short to me.

This is a guess, as i don't fancy myself with decompiling classes, but i think that u should use

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

instead of what u are using now. This could be similar to

Class.forName("ClassName")

without the "class" suffix.

Update: My original assumption was wrong, and to bad, the original exception/ message is thrown away, as far a i can see. The code where JODE fails looks like this:

 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);
        }

Since an IOException has to be thrown to get the NoClassDefFound, check anything regarding your IO subsytsem, e.g. the file.encoding. I guess you should patch JODE to get the detailed error message or debug to this point.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top