---+ SourceTec Java Decompiler Simple Tests SourceTec, also known as Jasmine, is an old decompiler; in fact it's a patch to Mocha, probably the very first Java decompiler. The version I used is 1.10 (from the Readme file), though the decompiler output says Version 1.0. It only works on Java 1.1 files; most Java programs are Java 1.2 (Java 2) these days. I recompiled those tests that I could for 1.1 (using =-target 1.1=). %TOC% ---++ Fibo For source, see DecompilerFiboTestSource. Decompiled source from SourceTec:
/* Decompiled by Jasmine from Fibo.class */ /* Originally compiled from Fibo.java */ import java.io.PrintStream; synchronized class Fibo { Fibo() { } private static int fib(int i) { if (i > 1) return fib(i - 1) + fib(i - 2); else return i; } public static void main(String astring[]) throws Exception { int i = 0; try { i = Integer.parseInt(astring[0]); } catch (Exception e) { System.out.println("Input error"); System.exit(1); } int j = fib(i); System.out.println("fibonacci(" + i + ") = " + j); } }As you can see, the decompilation looks pretty good, but the =synchronized= keyword is wrong and stops the output from recompiling. (This would presumably not have happened with true Java 1.1 bytecode files). When this word was removed, the output compiled and ran with no further changes required. ---++ Casting For source, see DecompilerCastingTestSource. Here is the output from SourceTec:
/* Decompiled by Jasmine from Casting.class */ /* Originally compiled from Casting.java */ import java.io.PrintStream; public synchronized class Casting { public Casting() { } public static void main(String astring[]) { for (char ch = '\0'; ch < 128; ch = (char)(ch + 1)) System.out.println("ascii " + ch + " character " + ch); } }Again, the =synchronized= keyword had to be removed for it to recompile. The cast is missing, so the program did not run correctly. With those two changes (removed =synchronized=, added cast to integer), the program was correct. ---++ Inner classes For source, see DecompilerInnerClassesTestSource. When decompiled with SourceTec, the result is
Ignoring field attribute Synthetic 0 Ignoring class attribute InnerClasses 18 /* Decompiled by Jasmine from Usa$England.class */ /* Originally compiled from Usa.java */ public synchronized class Usa$England { public String name; private final Usa this$0 = usa; public Usa$England(Usa usa) { name = "London"; } }---++ Deuces Wild This is a 38K applet with two dimensional arrays of integers, some floating point code, and so on. The SourceTec decompiler bombed out with an array out of bounds exception. ---++ Sable Test Program For source, see DecompilerSableTestSource. Here is the result for function =f= (as produced by SourceTec):
public static void f(short s) { Object object; boolean flag; if (s > 10) { Rectangle rectangle = new Rectangle(s, s); flag = rectangle.isFat(); object = rectangle; } else { Circle circle = new Circle(s); flag = circle.isFat(); object = circle; } if (!flag) object.draw(); }It typed the variable, called =d= in the original source, as type =Object=, and neglected to cast the variable in the call to =drawable=. When the cast was added, =synchronized= was removed, and another cast was added (not shown above), it compiled correctly. ---++ Optimised code. For source, see DecompilerOptimisedTestSource. This was the result from SourceTec for the method =f=:
Method paint: Flow analysis could not complete Method run: Flow analysis could not completeSimilarly, 6 warnings were emitted for =LR_Colony=. These contained bytecode-like code, such as:
compare and if < goto 68 dup 1 over 0 expression 59---++ Conclusion This decompiled is essentially obsolete. It performs adequately for simple programs that happen to be in Java 1.1 format. -- Main.MikeVanEmmerik - 11 Feb 2003 CategoryDecompilation