Here is a simple example:
The Jabaco code
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Option Explicit
Public Sub Command1_Click()
Dim tb As TextBox = Null
On Error Goto ErrHandler
' the following line provokes a nullpointer exception
tb.Text = "a text"
Exit Sub
ErrHandler:
MsgBox "got it wrong!"
End Sub
|
The de-compiled Java code:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
Couldn't fully decompile method Command1_Click
Couldn't resolve all exception handlers in method Command1_Click
public void Command1_Click()
{
Throwable Err;
TextBox tb;
Err = null;
tb = null;
tb.$Text("a text");
goto _L1
_L2:
Interaction.MsgBox("got it wrong!");
_L1:
return;
Err;
goto _L2
}
|
The de-compiled Java byte code:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
public void Command1_Click()
{
// Byte code:
// 0: aconst_null
// 1: astore_1
// 2: aconst_null
// 3: astore_3
// 4: aload_3
// 5: ldc 211
// 7: invokevirtual 216 VB/TextBox:$Text (Ljava/lang/String;)V
// 10: goto +10 -> 20
// 13: nop
// 14: ldc 218
// 16: invokestatic 224 VBA/Interaction:MsgBox (Ljava/lang/String;)LVBA/VBMsgBoxResult;
// 19: pop
// 20: nop
// 21: return
// 22: astore_2
// 23: astore_1
// 24: ret 2
// 26: jsr -4 -> 22
// 29: goto -16 -> 13
//
// Exception table:
// from to target type
// 4 20 26 finally
}
|
Jabaco is using the "on error" mechanism known from VisualBasic 6 rather than the try() / catch() from Java.
It should be possible to catch all exceptions using an "on error" statement.
Happy experimenting!
A1880