---+ jAscii Java Decompiler Simple Tests NOTE: Jascii seems to have gone out of business at the end of 2003. I tested jAscii 1.0.20 from http://www.jascii.com. %TOC% ---++ Fibo For source, see DecompilerFiboTestSource. Decompiled source from jAscii:
//Decompiled by jAscii v1.0.20. Copyright 2001 D&C Software Solutions Inc. //jAscii home page: http://www.jascii.com //Decompiled from Fibo.class //Original Source File Name: Fibo.java import java.io.PrintStream; 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 as[]) throws Exception { int i = 0; try { i = Integer.parseInt(as[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 is almost identical to the original source. The output compiled and ran perfectly with no changes required. ---++ Casting For source, see DecompilerCastingTestSource. Here is the output from jAscii:
//Decompiled by jAscii v1.0.20. Copyright 2001 D&C Software Solutions Inc. import java.io.PrintStream; public class Casting { public Casting() { } public static void main(String as[]) { for (char ch = '\0'; ch < 128; ch = (char)(ch + 1)) System.out.println("ascii " + ch + " character " + ch); } }As before, there is a cast missing. No modifications were needed to recompile it; when the cast was inserted, the program ran correctly. ---++ Inner classes For source, see DecompilerInnerClassesTestSource. When decompiled with jAscii, the result is
//Decompiled by jAscii v1.0.20. Copyright 2001 D&C Software Solutions Inc. import java.io.PrintStream; public class Usa { public String name; public class England { public String name; public class Ireland { public String name; public Ireland() { name = "Dublin"; } public void print_names() { System.out.println(name); } } public England() { name = "London"; } } public Usa() { name = "Detroit"; } }It reproduced the inner classes correctly, although the initialisations were moved to the constructors. ---++ Deuces Wild This is a 38K applet with two dimensional arrays of integers, some floating point code, and so on. It decompiled in about 8 seconds, with one error. In one =for= loop, a pair of braces was missing. The body of the loop had only one statement (a do while loop) and a declaration; perhaps the declaration was added after the loop was designated as not needing braces. When the braces were added, it recompiled and ran perfectly with no modifications. The arrays of strings are initialised fairly naturally, e.g.
public int foo(int i, int j) { RuntimeException e; pop e for (i = 10; i < j; i = j++ / i); return j; }This result is strangely similar to that of SourceTec, and is completely wrong. For example, =i= should only be set to 10 if an exception occurs. Also obviously, =pop= is not valid Java. ---++ Exceptions For source, see DecompilerExceptionTestSource. Here is jAscii's output: