subscribe: Posts | Comments

Question and Answer

0 comments

Q1: Is the source code of Jad available?

A1: Currently I have no plans to release the Jad source code for any purposes including porting to other computer platforms.

Q2: What is the option -dead for?

A2: This option forces Jad to decompile the dead portions of bytecode. For example, non-optimizing compilation of the following code can produce the dead bytecode:

      if (false)
      {
          …
      }

This option should be on by default, but the incorrect dead bytecode can crash Jad.

Q3: Why does Jad fail to generate the throws clause in the method declarations like the one in

       int divide(int a, int b) throws DivideByZero { … }   ?

A3: This throws clause is represented in the Java class files by the Exceptions attribute. The Java Virtual Machine itself doesn’t use these attributes (well, at least, the common implementations of JVM), so they can be stripped out of the Java class files. Jad has no way of restoring this information in full if it’s missing from the class file.

Q4: Why does Jad generate weird-looking static fields like class$java$lang$Float and static methods class$(String)?

A4: These fields/methods are the internal representation of the <classname>.class expression and automatically generated by compiler. For example, java.lang.Thread.class is translated into the following:


((class$java$lang$Thread == null) ?
    (class$java$lang$Thread = class$("java.lang.Thread")) :
     class$java$lang$Thread);

static Class class$(String s)
{
  try
  {
      return Class.forName(s);
  }
  catch(ClassNotFoundException ex)
  {
      throw new NoClassDefFoundError(ex.getMessage());
  }
}

static Class class$java$lang$Thread;

This is fixed in 1.5.8. The explanation for the previous versions: Jad doesn’t convert all that back to the original expression, but apparently the Sun JDK 1.2 compiler is able to compile "the long format" successfully. JDK 1.3 compiler doesn’t accept names containing class$, so in order to recompile the decomplied class you need to change all expressions similar to the conditional expression above to <classname>.class and remove static methods/fields whose names start with class$.

Q5: Jad refuses to decompile my class file saying "Class file version mismatch". What can I do?

A5: Use -debug option. Jad then complains about the version mismatch, but attempts to decompile the file anyway. Note that this works starting from the version 1.5.6e.

Q6: Jad fails to decompile my class file, it spits out a bunch of gotos and JVM instructions. Why is that?

A6: There could be several possible reasons: the class file has been obfuscated or it was produced by non-JDK Java compiler or some functions were inlined by Java compiler. Generally Jad works best with class files generated by Sun Java compilers. If you encounter such a behaviour, please send me a bug report with attached .class files.

Q7: How to decompile jar or zip archive with classes?

A7: "Unjar" (jar xvf <jarfile>) or unzip (using unzip or WinZip) the archive into a directory on your hard drive. Then see the next answer.

Q8: How to decompile the whole class tree?

A8: Run

      jad -r [-d<directory_for_sources>] [<other_options>] <directory_with_classes>**/*.class

On Unix the last argument should be in single quotes. For more information please read Readme.txt.

Q9: Why do I get "Class <<ambiguous>>List not found" from the compiler?

A9: There are two List classes: java.awt.List and java.util.List. If Jad generates two import directives:

    import java.awt.*;
    import java.util.*;

and your class actually uses the List class, the compiler will complain. Prior version 1.5.7d use the command-line option -pi to prevent Jad from combining the import directives.

Q10: How to make the command-line options -ff -nonlb -space -t to be on by default?

A10: Use the environment variable JAD_OPTIONS to permanently override the default settings. The example for Windows:

    set JAD_OPTIONS=-ff+ -nonlb+ -t+ -space+

Q11: How to extract Java classes from an executable file (.exe)?

A11: Use the Java-Split utility written by the Decafe Pro team. Download it from http://decafe.hypermart.net/javasplit.htm.
Or use J++Extract from http://www.multimania.com/dolmen/productions.

Q12: What does the error message "JavaClassFileParseException: Invalid tag value 0x0" mean exactly?

A12: It means that your file is not a valid Java class and Jad was unable to parse it successfully. Either the file was broken (for example, during download) or the package this class belongs to contains a custom Java class loader that modifies (or decrypts) Java classes after reading them into the memory. In both cases Jad cannot decompile this file as it is.