This is the Jasmin (essentially Java "assembly language") source code for the exceptions decompiler test. It is an attempt at the test program from Figure 6 of the paper Decompiling Java Bytecode: Problems, Traps and Pitfalls, but since the results are so different to theirs, I must have failed to reproduce their original example. I should be pretty close, though, because the SourceTec decompiler produces results very similar to what their paper claims Wingdis produces.

I wrote this program as follows. First, I wrote a Java program that comes close to the control flow required. I compiled this to bytecodes, and used Soot (see http://www.sable.mcgill.edu/soot/) to convert this to Jasmin. I then edited the Jasmin to have the control flow required, and edited the labels to be more readable. I then "assembled" this code with jasmin (a slightly modified version comes as part of Soot).

.class  foo
.super java/lang/Object

.method  <init>()V
    .limit stack 1
    .limit locals 1
    aload_0
    invokespecial java/lang/Object/<init>()V
    return
.end method

.method public foo()V
.catch java/lang/RuntimeException from label_b to after_c using catch_g
.catch java/lang/RuntimeException from label_c to after_d using catch_e
    .limit stack 2
    .limit locals 1
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "a"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
label_b:
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "b"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
label_c:
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "c"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
after_c:
    goto label_d
catch_g:
    astore_0
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "g"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
    goto label_f
label_d:
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "d"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
after_d:
    goto label_f
catch_e:
    astore_0
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "e"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
label_f:
    getstatic java/lang/System/out Ljava/io/PrintStream;
    ldc "f"
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
    return
.end method

.method public static main()V
    .limit stack 2
    .limit locals 1
    new foo
    dup
    invokespecial foo/<init>()V
    astore_0
    return
.end method

-- MikeVanEmmerik - 12 Feb 2003

Revision: r1.1 - 12 Feb 2003 - 06:52 - MikeVanEmmerik
Transform > DeCompilationApplicationSpecificApproach? > DecompilerExceptionTestSource
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback