vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java
changeset 423 9b5868bf56ec
parent 408 21da8e2f5911
child 424 aef4fd91e99c
     1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Thu Jan 03 16:20:21 2013 +0100
     1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java	Thu Jan 10 13:09:19 2013 +0100
     1.3 @@ -1594,9 +1594,19 @@
     1.4              if (e.catch_cpx != 0) { //not finally
     1.5                  final String classInternalName = jc.getClassName(e.catch_cpx);
     1.6                  addReference(classInternalName);
     1.7 -                out.append("if (e.$instOf_" + classInternalName.replace('/', '_') + ") {");
     1.8 -                out.append("gt=" + e.handler_pc + "; stA0 = e; continue;");
     1.9 -                out.append("}\n");
    1.10 +                if ("java/lang/Throwable".equals(classInternalName)) {
    1.11 +                    out.append("if (e.$instOf_java_lang_Throwable) {");
    1.12 +                    out.append("  stA0 = e;");
    1.13 +                    out.append("} else {");
    1.14 +                    out.append("  stA0 = vm.java_lang_Throwable(true);");
    1.15 +                    out.append("  vm.java_lang_Throwable.cons__VLjava_lang_String_2(stA0, e.toString());");
    1.16 +                    out.append("}");
    1.17 +                    out.append("gt=" + e.handler_pc + "; continue;");
    1.18 +                } else {
    1.19 +                    out.append("if (e.$instOf_" + classInternalName.replace('/', '_') + ") {");
    1.20 +                    out.append("gt=" + e.handler_pc + "; stA0 = e; continue;");
    1.21 +                    out.append("}\n");
    1.22 +                }
    1.23              } else {
    1.24                  finallyPC = e.handler_pc;
    1.25              }