Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created April 20, 2011 06:01
Show Gist options
  • Save nobeans/930473 to your computer and use it in GitHub Desktop.
Save nobeans/930473 to your computer and use it in GitHub Desktop.
import java.io.IOException;
public class MultiCatch {
public static void main(String... args) {
try {
if (args.length == 1) {
throw new IOException("!!");
}
if (args.length == 2) {
throw new ClassNotFoundException("??");
}
} catch (IOException|ClassNotFoundException e) {
System.out.println("ex: " + e.getClass());
}
System.out.println("Done.");
}
}
-------------------------------------------------
$ javap -l -c MultiCatch
Compiled from "MultiCatch.java"
public class MultiCatch extends java.lang.Object {
public MultiCatch();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 3: 0
public static void main(java.lang.String...);
Code:
0: aload_0
1: arraylength
2: iconst_1
3: if_icmpne 16
6: new #2 // class java/io/IOException
9: dup
10: ldc #3 // String !!
12: invokespecial #4 // Method java/io/IOException."<init>":(Ljava/lang/String;)V
15: athrow
16: aload_0
17: arraylength
18: iconst_2
19: if_icmpne 32
22: new #5 // class java/lang/ClassNotFoundException
25: dup
26: ldc #6 // String ??
28: invokespecial #7 // Method java/lang/ClassNotFoundException."<init>":(Ljava/lang/String;)V
31: athrow
32: goto 64
35: astore_1
36: getstatic #8 // Field java/lang/System.out:Ljava/io/PrintStream;
39: new #9 // class java/lang/StringBuilder
42: dup
43: invokespecial #10 // Method java/lang/StringBuilder."<init>":()V
46: ldc #11 // String ex:
48: invokevirtual #12 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
51: aload_1
52: invokevirtual #13 // Method java/lang/Object.getClass:()Ljava/lang/Class;
55: invokevirtual #14 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
58: invokevirtual #15 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
61: invokevirtual #16 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
64: getstatic #8 // Field java/lang/System.out:Ljava/io/PrintStream;
67: ldc #17 // String Done.
69: invokevirtual #16 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
72: return
Exception table:
from to target type
0 32 35 Class java/io/IOException ★→これと
0 32 35 Class java/lang/ClassNotFoundException ★→こ。to, targetが同じ!!
LineNumberTable:
line 6: 0
line 7: 6
line 9: 16
line 10: 22
line 14: 32
line 12: 35
line 13: 36
line 16: 64
line 17: 72
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment