From e3d7a55d648588a67107afe47f9bd4e6da5f1630 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@379699f6-c40d-0410-875b-85095c16579e> Date: Wed, 7 Jul 1999 17:14:16 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'stable'. git-svn-id: https://svn.code.sf.net/p/jode/code/branches/stable@1049 379699f6-c40d-0410-875b-85095c16579e --- jode/.cvsignore | 9 + jode/AUTHORS | 1 + jode/ChangeLog | 0 jode/INSTALL | 33 +++ jode/Makefile.am | 5 + jode/NEWS | 10 + jode/README | 106 ++++++++ jode/acinclude.m4 | 43 +++ jode/configure.in | 128 +++++++++ jode/doc/.cvsignore | 2 + jode/doc/Makefile.am | 5 + jode/doc/jode-applet.html | 39 +++ jode/doc/jode-obfuscator.html | 15 ++ jode/doc/jode-unix.html | 97 +++++++ jode/doc/jode-useapplet.html | 49 ++++ jode/doc/jode-win.html | 62 +++++ jode/doc/jode.html | 125 +++++++++ jode/jode/.cvsignore | 4 + jode/jode/GlobalOptions.java.in | 107 ++++++++ jode/jode/Makefile.am | 231 ++++++++++++++++ jode/jode/swingui/Main.java.in | 278 ++++++++++++++++++++ jode/jode/swingui/PackagesTreeModel.java.in | 176 +++++++++++++ jode/test/.cvsignore | 2 + jode/test/Makefile.am | 0 24 files changed, 1527 insertions(+) create mode 100644 jode/.cvsignore create mode 100644 jode/AUTHORS create mode 100644 jode/ChangeLog create mode 100644 jode/INSTALL create mode 100644 jode/Makefile.am create mode 100644 jode/NEWS create mode 100644 jode/README create mode 100644 jode/acinclude.m4 create mode 100644 jode/configure.in create mode 100644 jode/doc/.cvsignore create mode 100644 jode/doc/Makefile.am create mode 100644 jode/doc/jode-applet.html create mode 100644 jode/doc/jode-obfuscator.html create mode 100644 jode/doc/jode-unix.html create mode 100644 jode/doc/jode-useapplet.html create mode 100644 jode/doc/jode-win.html create mode 100644 jode/doc/jode.html create mode 100644 jode/jode/.cvsignore create mode 100644 jode/jode/GlobalOptions.java.in create mode 100644 jode/jode/Makefile.am create mode 100644 jode/jode/swingui/Main.java.in create mode 100644 jode/jode/swingui/PackagesTreeModel.java.in create mode 100644 jode/test/.cvsignore create mode 100644 jode/test/Makefile.am diff --git a/jode/.cvsignore b/jode/.cvsignore new file mode 100644 index 0000000..92379e3 --- /dev/null +++ b/jode/.cvsignore @@ -0,0 +1,9 @@ +Makefile +Makefile.in +configure +config.log +config.cache +config.status +stamp-h +libtool +aclocal.m4 diff --git a/jode/AUTHORS b/jode/AUTHORS new file mode 100644 index 0000000..fc38b9f --- /dev/null +++ b/jode/AUTHORS @@ -0,0 +1 @@ +Jochen Hoenicke \ No newline at end of file diff --git a/jode/ChangeLog b/jode/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/jode/INSTALL b/jode/INSTALL new file mode 100644 index 0000000..2aafeea --- /dev/null +++ b/jode/INSTALL @@ -0,0 +1,33 @@ +Before installing, make sure you have a java compiler (e.g javac or +jikes) and the java 1.1 runtime class library installed. If you want +to run this program you need at least a 1.1 compatible java virtual +machine. There are some bugs in javac included in the SUN JDK 1.1, it +won't work. + +This package was designed to use the GNU standard for configuration +and makefiles. To build and install do the following: + +0). Make sure that you have all libraries that are needed in you +classpath. You need gnu.getopt, and if you have JDK 1.1 you also need +the collection classes and swing for 1.1. + +1). Run "aclocal && autoconf && automake --add-missing". + +2). Run the "configure" script to configure the package. There are +various options you might want to pass to configure to control how the +package is built. "configure --help" will give a complete list. + +If you have jikes, you should specify it with --with-jikes. You can +give a path to the directory where it resides, otherwise it is +searched in the path. + +3). Type "make" to build the package. If you don't have jikes, you +should make clean first, since the dependency problem is not yet +resolved. + +4). Type "make install" to install everything. This doesn't work yet. + +The created jar file is stored in the share directory. + + Jochen + diff --git a/jode/Makefile.am b/jode/Makefile.am new file mode 100644 index 0000000..304113b --- /dev/null +++ b/jode/Makefile.am @@ -0,0 +1,5 @@ +## Input file for automake to generate the Makefile.in used by configure + +SUBDIRS = jode doc test + +EXTRA_DIST = TODO diff --git a/jode/NEWS b/jode/NEWS new file mode 100644 index 0000000..de761b2 --- /dev/null +++ b/jode/NEWS @@ -0,0 +1,10 @@ +1.0.90 is a prerelease.. +* First version using configure. Jode can now be almost automatically + build, see INSTALL for instructions. +* The decompiler can handler inner and anoymous classes. +* You now need the gnu getopt package. +* You need JDK 1.2 or alternatively the swing and collection packages + for 1.1 + + + diff --git a/jode/README b/jode/README new file mode 100644 index 0000000..c3f70f8 --- /dev/null +++ b/jode/README @@ -0,0 +1,106 @@ +takes class-files as input and produces something similar to the +original java-File. Of course this can't be perfect: There is no way +to produce the comments or the names of local variables (except when +compiled with -g) and there are often more ways to write +the same thing. But it does its job quite well.

+ +

Quick Test

+I have now an applet interface to the decompiler. +Check it out. + +

How to get it

+

You can donwload the files in zip form. +The sources contain only the +java files, the classes +contain only the class files.

+ +

I also have a tar.gz file containing only +the RCS directories. This is the form I maintain the +project, but you probably need unix and a few tools to use them.

+ +

There are also some snapshots that have new +features like inner and anonymous classes.

+ +

Click here to browse the files online. +

+ + + +

How to use it

+ +

I have some simple step by step pages. There are three +possibilities: +

+ +

Known bugs

+ +

There may be situations, where the code doesn't understand complex +expressions. In this many ugly temporary variables are used, but the +code should still be compileable. This does especially happen when +you compile with `-O' flag and javac has inlined some methods.

+ +

Sometimes this program may exit with an Exception or +produce incorrect code. Most time the code can't be compiled, so that +it can be easily spotted. If you have one of these problems (except +those that occur on some of the jode.test files, I would +be very interested in a bug report (including the class +file, if possible).

+ +

Sometimes it generates some GOTO expression and +labels. This can't be compiled, but shouldn't happen any more with +javac or jikes.

+ +

It doesn't handle inner and anonymous classes, yet. You can +decompile them separately, though (use `+$' switch under +jikes), but there is a bug in javac, so that a final variable is twice +initialized. If you encounter this problem just remove the doubled +line by hand.

+ +

New! The latest snapshot can handle +inner and anonymous classes.

+ + +

Why did I wrote it?

+ +

Someday I found guavad, a disassembler for java byte +code (it does similar things like javap -c). I used +it on a class file, and found that it was possible to reconstruct the +original java code. First I did it by hand on some small routines, +but I soon realized that it was a rather stupid task, and that I could +write a perl script +that does the same. At the end of the next day I had a working +decompiler.

+ +

Now while it was working, it was not easy to use. You had to +decompile the code first with a disassembler, cut the method, you +wanted to decompile and then run the perl script on it. So I decided +to get some information of the class files and do this all +automatically. I decided to write it in java now, +because it suited best.

+ +

Just for the records: the java code is now more than 50 times +bigger than the original perl script and is still growing.

+ +

License

+ +

This code is under GNU GPL. That basically means, that you can copy +or modify this code, as long as you put all your modification under +the GPL again. Look +here for the complete license.

+ +
+ +

+http://www.informatik.uni-oldenburg.de/~delwi/jode/jode.html, last +updated on 17-Jun-1999.

+ + + diff --git a/jode/acinclude.m4 b/jode/acinclude.m4 new file mode 100644 index 0000000..a7ef9df --- /dev/null +++ b/jode/acinclude.m4 @@ -0,0 +1,43 @@ +dnl +dnl Add macros +dnl JODE_CHECK_JAVA +dnl + +dnl JODE_CHECK_JAVA(path) +AC_DEFUN(JODE_CHECK_JAVA, +[ + AC_PATH_PROG(JAVAC, javac, "", $PATH:$1/bin) + AC_PATH_PROG(JAR, jar, "", $PATH:$1/bin) + for path in $1/lib $1/jre/lib $1/shared; do + for classlib in classes.zip rt.jar; do + AC_CHECK_FILES($path/$classlib, + [ CLASSLIB=$path/$classlib + break 3 + ], [ true ]) + done + done + AC_SUBST(CLASSPATH) + AC_SUBST(CLASSLIB) +]) + +AC_DEFUN(JODE_CHECK_CLASS, +[ + if (IFS=":" + clazz=`echo $1 | sed -e 's/\./\//g' -e 's/\(.*\)/\1.class/'` + jode_found=0 + for path in $2; do + if test -d $path; then + if test -e $path/$clazz; then + exit 0 + fi + elif $UNZIP -v -C $path $clazz &>/dev/null ; then + exit 0 + fi + done; + exit 1) + then + $3 + else + $4 + fi +]) diff --git a/jode/configure.in b/jode/configure.in new file mode 100644 index 0000000..beb8e1c --- /dev/null +++ b/jode/configure.in @@ -0,0 +1,128 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT() + +AM_INIT_AUTOMAKE(jode, 1.0.90) + +dnl Checks for programs. +dnl AC_PROG_CXX +dnl AC_PROG_AWK +dnl AC_PROG_CC +dnl AC_PROG_CPP +dnl AC_PROG_INSTALL +dnl AC_PROG_LN_S +AC_PROG_MAKE_SET +dnl AC_PROG_RANLIB +dnl AC_PATH_PROG(ZIP, zip) +AC_PATH_PROG(UNZIP, unzip) + +dnl Checks for libraries. + +dnl Checks for header files. + +dnl Checks for typedefs, structures, and compiler characteristics. + +dnl Checks for library functions. + +dnl hack to quote Makefile lines +QUOTE="" +AC_SUBST(QUOTE) + +AC_SUBST(SHELL) + +AC_ARG_WITH(java, + [ --with-java specify path to a java-like program ], + [ + if test ${withval} != "" || test ${withval} != "yes" || test ${withval} != "no"; then + # set javac to user input value + JODE_CHECK_JAVA(${withval}) + else + JODE_CHECK_JAVA(/usr/lib/java) + fi + ], + [ + JODE_CHECK_JAVA(/usr/lib/java) + ]) + +dnl jikes can also handle dependancies. +AC_ARG_WITH(jikes, +[ --with-jikes specify location of jikes ], +[ + USER_SPECIFIED_JIKES=true + if test "${withval}" = "yes" || test "${withval}" = ""; then + AC_PATH_PROG(JIKES, jikes, "", $PATH) + else + echo "searching jikes in ${withval}:$PATH" + AC_PATH_PROG(JIKES, jikes, "", ${withval}:$PATH) + fi + if test -n "$JIKES"; then + JAVAC=$JIKES + fi +], +[ + USER_SPECIFIED_JIKES= + AC_PATH_PROG(JIKES, jikes, "", $PATH) +]) +AM_CONDITIONAL(HAVE_JIKES, test x"$JIKES" != x) + +AC_ARG_WITH(javac, + [ --with-javac specify location of javac ], + [ + if test x$USER_SPECIFIED_JIKES == xtrue; then + AC_MSG_ERROR(You must only give one option --with-javac or --with-jikes) + fi + if test ${withval} != "" || test ${withval} != "yes" || test ${withval} != "no"; then + AC_CHECK_FILES(${withval}, + [ JAVAC=${withval} ], + [ AC_MSG_ERROR(${withval} does not exists) ]) + fi +], [ true ]) + +JODE_CHECK_CLASS(java.lang.Object, $CLASSLIB, + [ true ], + [ AC_MSG_ERROR(Please specify location of java class library for jikes) ]) + +AC_MSG_CHECKING(for collection classes) +JODE_CHECK_CLASS(java.util.Set, $CLASSPATH:$CLASSLIB, + [ COLLECTIONS="java.util" ], + [ JODE_CHECK_CLASS(com.sun.java.util.collections.Set, $CLASSPATH:$CLASSLIB, + [ COLLECTIONS="com.sun.java.util.collections" ], + [ AC_MSG_RESULT(no) + AC_MSG_ERROR(You need the Java 1.2 collection classes in your classpath) + ]) + ] ) +AC_MSG_RESULT($COLLECTIONS) +AC_SUBST(COLLECTIONS) + +AC_MSG_CHECKING(for gnu.getopt) +JODE_CHECK_CLASS(gnu.getopt.Getopt, $CLASSPATH:$CLASSLIB, + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no) + AC_MSG_ERROR(You need gnu getopt for java.) ]) + +AC_MSG_CHECKING(for swing) +JODE_CHECK_CLASS(javax.swing.JFrame, $CLASSPATH:$CLASSLIB, + [ JAVAX_SWING="javax.swing" ], + [ JODE_CHECK_CLASS(com.sun.swing.JFrame, $CLASSPATH:$CLASSLIB, + [ JAVAX_SWING="com.sun.java.swing" ], + [ JAVAX_SWING="no" ]) ] ) +AC_MSG_RESULT($JAVAX_SWING) +AC_SUBST(JAVAX_SWING) +if test x"$JAVAX_SWING" != x; then + SWING_CLASSES="jode/swingui/Main.class" +else + AC_MSG_WARN(Swing is not in classpath ... skipping swingui) + SWING_CLASSES="" +fi +AC_SUBST(SWING_CLASSES) + +AC_SUBST(CLASSPATH) +AC_SUBST(JAVAC) + +AC_OUTPUT(Makefile +jode/Makefile +doc/Makefile +test/Makefile +jode/GlobalOptions.java +jode/swingui/Main.java +jode/swingui/PackagesTreeModel.java) + diff --git a/jode/doc/.cvsignore b/jode/doc/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/jode/doc/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/jode/doc/Makefile.am b/jode/doc/Makefile.am new file mode 100644 index 0000000..cc2d74b --- /dev/null +++ b/jode/doc/Makefile.am @@ -0,0 +1,5 @@ +## Input file for automake to generate the Makefile.in used by configure + +EXTRA_DIST = \ + jode.html jode-applet.html jode-obfuscator.html jode-unix.html \ + jode-useapplet.html jode-win.html diff --git a/jode/doc/jode-applet.html b/jode/doc/jode-applet.html new file mode 100644 index 0000000..c71c73f --- /dev/null +++ b/jode/doc/jode-applet.html @@ -0,0 +1,39 @@ + + +Jode Test Applet + + + + +Up + +

Test Applet

+ + + + +

+ +Press the start button to decompile this applet. You may change the +class path and class name to point to a class file of your choice. +But note that most browsers doesn't allow loading files from a +different server.

+ +Save probably doesn't work, because it is forbidden by the browser.

+ +You may give multiple entries in the class path field separated by a +comma. The components may be local or remote zip or jar files or +directories. Note that browsers forbid accesses to different hosts or +local files that are not in a subdirectory of the applet +directory.

+ +BTW: If you just want to read the source, you may browse it +online :-)

+ +You can download this, look here for +a description. + + + diff --git a/jode/doc/jode-obfuscator.html b/jode/doc/jode-obfuscator.html new file mode 100644 index 0000000..995c085 --- /dev/null +++ b/jode/doc/jode-obfuscator.html @@ -0,0 +1,15 @@ + + + +Using the obfuscator + + +Up + +The obfuscator currently takes a lot of options (I plan to use an +extra file containing the options). You should therefore create a +script (or batch file under Windows) that invokes the obfuscator.
+ + + + \ No newline at end of file diff --git a/jode/doc/jode-unix.html b/jode/doc/jode-unix.html new file mode 100644 index 0000000..6371c53 --- /dev/null +++ b/jode/doc/jode-unix.html @@ -0,0 +1,97 @@ + + + +Using the decompiler under Unix + + +Up + + +

Step by Step

+ +You need java version 1.1 or higher. In the following description I +assume you have the JDK 1.1, residing in /usr/lib/java. +For other installations you have to adopt the paths. Also I use the +bourne shell syntax. + +
    +
  1. Set the classpath. It should include the jode_cls.zip as well as + the directory where the class files you want to decompile resides. + You can also specify a zip file instead of a directory. It is + also a good idea to include the zip resp. jar file containing the + basic java.* class files. +
    +export CLASSPATH=$HOME/jode_cls.zip:$HOME/download:/usr/lib/java/lib/classes.zip
    +
    +
  2. +
  3. Now you can start the graphical interface as following (Note the + case of the parameter) +
        
    +java jode.JodeWindow
    +
    +
  4. +
  5. The classpath field should already contain the classpath you set + above. The class field contains jode.JodeWindow and + you may push start immediately to decompile this class. +
  6. +
  7. If you want to decompile your own .class file, enter + the name of the file without .class extension and + push the start button. Change the class path if it doesn't point + to the right directory. +
  8. +
  9. After decompiling, you can save the file using the save button. +
  10. +
+ +

Packaged classes

+ +If the class file belongs to a package (like jode.JodeWindow) you +have to give the full qualified class name (the package names +separated by a dot followed by the class name). The class path should +point to the directory containing the package sub directories in this +case.

+ +

Command line utility

+ +There is also a command line utility which is much more powerful, but +also more difficult to use. You can start it (after setting the +classpath) with +
+java jode.Decompiler
+
+and get a list of the supported parameters. To decompile the whole +decompiler you can use these magic lines: +
+mkdir src
+CLASSPATH=jode_cls.zip java jode.Decompiler --dest src \
+  `unzip -v jode_cls.zip|grep .class|cut -c59-|sed s/.class//|sed s?/?.?g`
+
+ +

Obfuscator

+ +So you want to protect your classes from decompiling? Well that is +your choice. You may use my obfuscator. The class files are +decompileable again (except when using -strong option, but this is +reversable by obfuscating again), but at least the information about +the names of identifiers are completely lost.

+ +The obfuscator is quite difficult to use (this is why I hided this +section here) and there is only a short description of the command +line parameters: +
+CLASSPATH=jode_cls.zip java jode.Obfuscator
+
+ +As a hint, to obfuscate the obfuscator use the following command line: +
+CLASSPATH=jode_cls.zip java jode.Obfuscator \
+  -cp jode_cls.zip:/usr/lib/java/lib/classes.zip -d obfuscated.zip \
+  -weak -revtable translate.tbl -swaporder \
+  -preserve jode.Obfuscator.main jode
+
+ +The options -unique and -table can be +helpful to deobfuscate obfuscated code. + + + diff --git a/jode/doc/jode-useapplet.html b/jode/doc/jode-useapplet.html new file mode 100644 index 0000000..24bcc3a --- /dev/null +++ b/jode/doc/jode-useapplet.html @@ -0,0 +1,49 @@ + + + +Using the decompiler as applet (locally) + + +Up + +

Step by Step

+ +If you want to use the applet version you need a recent Internet +Explorer or Netscape which supports java 1.1. You can also use the +appletviewer of the java development kit. + +
    +
  1. Copy jode-applet.html into a local directory. +
  2. +
  3. Copy jode_cls.zip to the same directory. +
  4. +
  5. Copy the .class file or zip file, you + want to decompile, to that directory. +
  6. +
  7. Load the html file into Netscape or Internet Explorer. +
  8. +
  9. Set the classpath simply to `.' (without quotes). + You may also specify a zip or jar file here. Note that applet and + class files must be in the same directory due to security policy.
    + You can also change the default classpath in the html file. +
  10. +
  11. Enter the name of the class without .class + extension. +
  12. +
  13. Press start button in applet.
  14. +
  15. Press save button to save the decompiled code.
  16. +
+ +

Packaged classes

+ +If the class file belongs to a package (like jode.JodeWindow) you +have to give the full qualified class name (the package names +separated by a dot followed by the class name). The class path should +point to the directory containing the package sub directories in this +case. + + diff --git a/jode/doc/jode-win.html b/jode/doc/jode-win.html new file mode 100644 index 0000000..99d9927 --- /dev/null +++ b/jode/doc/jode-win.html @@ -0,0 +1,62 @@ + + + +Using the decompiler under Windows + + +Up + +

Step by Step

+ +You need java version 1.1 or higher. I suggest using the Sun JDK or +JRE 1.1 or 1.2. In the following description I assume Sun JDK 1.2, +for other virtual machines the paths and the name of the java +interpreter (c:\jdk1.2\java) may differ.

+ +
    +
  1. Set the classpath. It should include the jode_cls.zip as well as + the directory where the class files you want to decompile resides. + You can also specify a zip file instead of a directory. It is + also a good Idea to include the zip resp. jar file containing the + basic java.* class files. +
    +set CLASSPATH=c:\temp\jode_cls.zip;c:\temp;c:\jdk1.2\jre\lib\rt.jar
    +
    +
  2. +
  3. Now you can start the graphical interface as following (Note the + case of the parameter) +
        
    +c:\jdk1.2\java jode.JodeWindow
    +
    +
  4. +
  5. The classpath field should already contain the classpath you set + above. The class field contains jode.JodeWindow and + you may push start immediately to decompile this class. +
  6. +
  7. If you want to decompile your own .class file, enter + the name of the file without .class extension and + push the start button. Change the class path if it doesn't point + to the right directory. +
  8. +
  9. After decompiling, you can save the file using the save button. +
  10. +
+ +

Packaged classes

+ +If the class file belongs to a package (like jode.JodeWindow) you +have to give the full qualified class name (the package names +separated by a dot followed by the class name). The class path should +point to the directory containing the package sub directories in this +case.

+ +

Command line utility

+ +There is also a command line utility which is much more powerful, but +also more difficult to use. You can start it (after setting the +classpath) with +
+c:\jdk1.2\java jode.Decompiler
+
+and get a list of the supported parameters. + diff --git a/jode/doc/jode.html b/jode/doc/jode.html new file mode 100644 index 0000000..38175bd --- /dev/null +++ b/jode/doc/jode.html @@ -0,0 +1,125 @@ + + + + JOchens' java-DEcompiler (JODE) + + + + + + + + + + +An uptodate version of this page is located here.

+ +

What is it?

+ +

This is a decompiler for java I have written in my spare time. It +takes class-files as input and produces something similar to the +original java-File. Of course this can't be perfect: There is no way +to produce the comments or the names of local variables (except when +compiled with -g) and there are often more ways to write +the same thing. But it does its job quite well.

+ +

Quick Test

+I have now an applet interface to the decompiler. +Check it out. + +

How to get it

+

You can donwload the files in zip form. +The sources contain only the +java files, the classes +contain only the class files.

+ +

I also have a tar.gz file containing only +the RCS directories. This is the form I maintain the +project, but you probably need unix and a few tools to use them.

+ +

There are also some snapshots that have new +features like inner and anonymous classes.

+ +

Click here to browse the files online. +

+ + +

How to use it

+ +

I have some simple step by step pages. There are three +possibilities: +

+ +

Known bugs

+ +

There may be situations, where the code doesn't understand complex +expressions. In this many ugly temporary variables are used, but the +code should still be compileable. This does especially happen when +you compile with `-O' flag and javac has inlined some methods.

+ +

Sometimes this program may exit with an Exception or +produce incorrect code. Most time the code can't be compiled, so that +it can be easily spotted. If you have one of these problems (except +those that occur on some of the jode.test files, I would +be very interested in a bug report (including the class +file, if possible).

+ +

Sometimes it generates some GOTO expression and +labels. This can't be compiled, but shouldn't happen any more with +javac or jikes.

+ +

It doesn't handle inner and anonymous classes, yet. You can +decompile them separately, though (use `+$' switch under +jikes), but there is a bug in javac, so that a final variable is twice +initialized. If you encounter this problem just remove the doubled +line by hand.

+ +

New! The latest snapshot can handle +inner and anonymous classes.

+ + +

Why did I wrote it?

+ +

Someday I found guavad, a disassembler for java byte +code (it does similar things like javap -c). I used +it on a class file, and found that it was possible to reconstruct the +original java code. First I did it by hand on some small routines, +but I soon realized that it was a rather stupid task, and that I could +write a perl script +that does the same. At the end of the next day I had a working +decompiler.

+ +

Now while it was working, it was not easy to use. You had to +decompile the code first with a disassembler, cut the method, you +wanted to decompile and then run the perl script on it. So I decided +to get some information of the class files and do this all +automatically. I decided to write it in java now, +because it suited best.

+ +

Just for the records: the java code is now more than 50 times +bigger than the original perl script and is still growing.

+ +

License

+ +

This code is under GNU GPL. That basically means, that you can copy +or modify this code, as long as you put all your modification under +the GPL again. Look +here for the complete license.

+ +
+ +

+http://www.informatik.uni-oldenburg.de/~delwi/jode/jode.html, last +updated on 17-Jun-1999.

+ + + diff --git a/jode/jode/.cvsignore b/jode/jode/.cvsignore new file mode 100644 index 0000000..9f5ef71 --- /dev/null +++ b/jode/jode/.cvsignore @@ -0,0 +1,4 @@ +Makefile +Makefile.in +.java.deps +jode.jar diff --git a/jode/jode/GlobalOptions.java.in b/jode/jode/GlobalOptions.java.in new file mode 100644 index 0000000..0d79e80 --- /dev/null +++ b/jode/jode/GlobalOptions.java.in @@ -0,0 +1,107 @@ +/* GlobalOptions Copyright (C) 1999 Jochen Hoenicke. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package jode; +import java.io.PrintWriter; +import java.util.StringTokenizer; + +public class GlobalOptions { + public final static String version = "@VERSION@"; + public final static String email = "jochen@gnu.org"; + public final static String copyright = + "Jode (c) 1998,1999 Jochen Hoenicke <"+email+">"; + public final static String URL = + "http://www.informatik.uni-oldenburg.de/~delwi/jode/jode.html"; + + public static PrintWriter err = new PrintWriter(System.err, true); + public static int verboseLevel = 0; + public static int debuggingFlags = 0; + + public static final int DEBUG_BYTECODE = 0x001; + public static final int DEBUG_VERIFIER = 0x002; + public static final int DEBUG_TYPES = 0x004; + public static final int DEBUG_FLOW = 0x008; + public static final int DEBUG_INOUT = 0x010; + public static final int DEBUG_ANALYZE = 0x020; + public static final int DEBUG_LVT = 0x040; + public static final int DEBUG_CHECK = 0x080; + public static final int DEBUG_LOCALS = 0x100; + public static final int DEBUG_CONSTRS = 0x200; + public static final int DEBUG_INTERPRT = 0x400; + + public static final String[] debuggingNames = { + "bytecode", "verifier", "types", "flow", + "inout", "analyze", "lvt", "check", "locals", + "constructors", "interpreter" + }; + + public static void usageDebugging() { + err.println("Debugging option: --debug=flag1,flag2,..."); + err.println("possible flags:"); + err.println(" bytecode " + + "show bytecode, as it is read from class file."); + err.println(" verifier " + + "show result of bytecode verification."); + err.println(" types " + + "show type intersections"); + err.println(" flow " + + "show flow block merging."); + err.println(" analyze " + + "show T1/T2 analyzation of flow blocks."); + err.println(" inout " + + "show in/out set analysis."); + err.println(" lvt " + + "dump LocalVariableTable."); + err.println(" check " + + "do time consuming sanity checks."); + err.println(" locals " + + "dump local merging information."); + err.println(" constructors " + + "dump constructor simplification."); + err.println(" interpreter " + + "debug execution of interpreter."); + System.exit(0); + } + + /** + * Parse the argument given to the debugging flag. + * @return true, if the argument parsed without problems. + */ + public static boolean setDebugging(String debuggingString) { + if (debuggingString.length() == 0 || debuggingString.equals("help")) { + usageDebugging(); + return false; + } + + StringTokenizer st = new StringTokenizer(debuggingString, ","); + next_token: + while (st.hasMoreTokens()) { + String token = st.nextToken().intern(); + for (int i=0; i= 0) + return i; + throw new NoSuchElementException + (((TreeElement)parent).getFullName() + "." + child); + } + + public Object getRoot() { + return root; + } + + public boolean isLeaf(Object node) { + return ((TreeElement)node).isLeaf(); + } + + public String getFullName(Object node) { + return ((TreeElement) node).getFullName(); + } +} diff --git a/jode/test/.cvsignore b/jode/test/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/jode/test/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/jode/test/Makefile.am b/jode/test/Makefile.am new file mode 100644 index 0000000..e69de29