Archive for 1月 4th, 2013
-
Hello, Java 2D(Jasmin) World!
Posted on 1月 4th, 2013 by cx20
Java 2D
Java 2D は Java による 2D グラフィックライブラリである。
以下は Jasmin による Java 2D の使用例となっている。ソースコード
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Sun Dec 02 01:34:06 JST 2012 .bytecode 50.0 .source Hello.java .class public Hello .super javax/swing/JFrame .method public static main([Ljava/lang/String;)V .limit stack 3 .limit locals 2 .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 Label0: .line 8 0: new Hello 3: dup 4: ldc "Hello, World" 6: invokespecial Hello/<init>(Ljava/lang/String;)V 9: astore_1 .line 9 10: aload_1 11: iconst_1 12: invokevirtual Hello/setVisible(Z)V Label1: .line 10 15: return .end method .method <init>(Ljava/lang/String;)V .limit stack 3 .limit locals 3 .var 0 is this LHello; from Label0 to Label1 .var 1 is arg0 Ljava/lang/String; from Label0 to Label1 Label0: .line 13 0: aload_0 1: aload_1 2: invokespecial javax/swing/JFrame/<init>(Ljava/lang/String;)V .line 14 5: aload_0 6: iconst_3 7: invokevirtual Hello/setDefaultCloseOperation(I)V .line 15 10: aload_0 11: sipush 640 14: sipush 480 17: invokevirtual Hello/setSize(II)V .line 17 20: new HelloPanel 23: dup 24: invokespecial HelloPanel/<init>()V 27: astore_2 .line 18 28: aload_0 29: aload_2 30: invokevirtual Hello/add(Ljava/awt/Component;)Ljava/awt/Component; 33: pop Label1: .line 19 34: return .end method
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Sun Dec 02 01:34:19 JST 2012 .bytecode 50.0 .source Hello.java .class HelloPanel .super javax/swing/JPanel .method <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHelloPanel; from Label0 to Label1 Label0: .line 22 0: aload_0 1: invokespecial javax/swing/JPanel/<init>()V Label1: 4: return .end method .method public paintComponent(Ljava/awt/Graphics;)V .limit stack 4 .limit locals 3 .var 0 is this LHelloPanel; from Label0 to Label1 .var 1 is arg0 Ljava/awt/Graphics; from Label0 to Label1 Label0: .line 24 0: aload_1 1: checkcast java/awt/Graphics2D 4: astore_2 .line 25 5: aload_2 6: ldc "Hello, Java2D World!" 8: iconst_0 9: bipush 16 11: invokevirtual java/awt/Graphics2D/drawString(Ljava/lang/String;II)V Label1: .line 26 14: return .end method
コンパイル&実行方法
C:¥> java -jar jasmin.jar Hello.j HelloPanel.j C:¥> javaw Hello
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Java 2D World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+