Archive for the ‘Jasmin’ Category
-
Hello, COM(Jasmin) World!
Posted on 1月 26th, 2013 by cx20
COM(Jasmin)
COM(Component Object Model)はマイクロソフトの提唱するプログラム部品の仕様である。
COM を用いて開発された部品であれば言語を問わず利用することができる。
Jasmin 自身には、COM を呼び出す機能を持っていないが、別途ライブラリを経由することで呼び出すことが可能である。
以下は Jasmin より JACOB(JAVA-COM Bridge) ライブラリを使用した COM クライアントの例となっている。ソースコード
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Sun Dec 09 17:59:35 JST 2012 .bytecode 51.0 .source Hello.java .class public Hello .super java/lang/Object .method public ()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 4 0: aload_0 1: invokespecial java/lang/Object/()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 4 .limit locals 8 .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 Label0: .line 6 0: new com/jacob/activeX/ActiveXComponent 3: dup 4: ldc "Shell.Application" 6: invokespecial com/jacob/activeX/ActiveXComponent/(Ljava/lang/String;)V 9: astore_1 .line 7 10: new com/jacob/com/Variant 13: dup 14: iconst_0 15: invokespecial com/jacob/com/Variant/(I)V 18: astore_2 .line 8 19: new com/jacob/com/Variant 22: dup 23: ldc "Hello, COM(JACOB) World!" 25: invokespecial com/jacob/com/Variant/(Ljava/lang/String;)V 28: astore_3 .line 9 29: new com/jacob/com/Variant 32: dup 33: iconst_0 34: invokespecial com/jacob/com/Variant/(I)V 37: astore 4 .line 10 39: new com/jacob/com/Variant 42: dup 43: bipush 36 45: invokespecial com/jacob/com/Variant/(I)V 48: astore 5 .line 11 50: iconst_4 51: anewarray com/jacob/com/Variant 54: dup 55: iconst_0 56: aload_2 57: aastore 58: dup 59: iconst_1 60: aload_3 61: aastore 62: dup 63: iconst_2 64: aload 4 66: aastore 67: dup 68: iconst_3 69: aload 5 71: aastore 72: astore 6 .line 12 74: aload_1 75: ldc "BrowseForFolder" 77: aload 6 79: invokevirtual com/jacob/activeX/ActiveXComponent/invoke(Ljava/lang/String;[Lcom/jacob/com/Variant;)Lcom/jacob/com/Variant; 82: astore 7 Label1: .line 13 84: return .end method
コンパイル&実行方法
C:¥> jasmin Hello.j C:¥> java -cp jacob.jar;. Hello
実行結果
+----------------------------------------+ |Browse For Folder [X]| +----------------------------------------+ | Hello, COM(JACOB) Wolrd! | | | | +------------------------------------+ | | |[Windows] | | | | +[addins] | | | | +[AppCompat] | | | | +[AppPatch] | | | | +[assembly] | | | | : | | | | : | | | | : | | | +------------------------------------+ | | [Make New Folder] [ OK ] [Cancel] | +----------------------------------------+
-
Hello, Win32 API(Jasmin) World!
Posted on 1月 16th, 2013 by cx20
Win32 API(Jasmin)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
以下は Jasmin にて SWT の非公開 API を使用した Win32 API 呼出しの例となっている。ソースコード
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Sat Dec 08 23:04:58 JST 2012 .bytecode 51.0 .source Hello.java .class public Hello .super java/lang/Object .method public ()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 4 0: aload_0 1: invokespecial java/lang/Object/()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 5 .limit locals 3 .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 Label0: .line 6 0: new org/eclipse/swt/internal/win32/TCHAR 3: dup 4: iconst_0 5: ldc "Hello, Win32 API World!" 7: iconst_1 8: invokespecial org/eclipse/swt/internal/win32/TCHAR/(ILjava/lang/String;Z)V 11: astore_1 .line 7 12: new org/eclipse/swt/internal/win32/TCHAR 15: dup 16: iconst_0 17: ldc "Hello, World" 19: iconst_1 20: invokespecial org/eclipse/swt/internal/win32/TCHAR/(ILjava/lang/String;Z)V 23: astore_2 .line 8 24: iconst_0 25: aload_1 26: aload_2 27: iconst_0 28: invokestatic org/eclipse/swt/internal/win32/OS/MessageBox(ILorg/eclipse/swt/internal/win32/TCHAR;Lorg/eclipse/swt/internal/win32/TCHAR;I)I 31: pop Label1: .line 9 32: return .end method
コンパイル&実行方法
C:¥> jasmin Hello.j C:¥> java -cp org.eclipse.swt.win32.win32.x86_3.6.1.v3655c.jar;. Hello
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API World! --------------------------- OK ---------------------------
-
Hello, Java 3D(Jasmin) World!
Posted on 1月 5th, 2013 by cx20
Java 3D
Java 3D は Java による 3D グラフィックライブラリである。
以下は Jasmin による Java 3D の使用例となっている。ソースコード
; 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:53:35 JST 2012 .bytecode 51.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 12 0: new Hello 3: dup 4: ldc "Hello, World" 6: invokespecial Hello/<init>(Ljava/lang/String;)V 9: astore_1 .line 13 10: aload_1 11: iconst_1 12: invokevirtual Hello/setVisible(Z)V Label1: .line 14 15: return .end method .method public <init>(Ljava/lang/String;)V .limit stack 3 .limit locals 4 .var 0 is this LHello; from Label0 to Label1 .var 1 is arg0 Ljava/lang/String; from Label0 to Label1 Label0: .line 17 0: aload_0 1: aload_1 2: invokespecial javax/swing/JFrame/<init>(Ljava/lang/String;)V .line 18 5: aload_0 6: sipush 640 9: sipush 480 12: invokevirtual Hello/setSize(II)V .line 19 15: aload_0 16: iconst_3 17: invokevirtual Hello/setDefaultCloseOperation(I)V .line 20 20: aload_0 21: invokespecial Hello/createCanvas3D()Ljavax/media/j3d/Canvas3D; 24: astore_2 .line 21 25: aload_0 26: invokevirtual Hello/createSceneGraph()Ljavax/media/j3d/BranchGroup; 29: astore_3 .line 22 30: aload_0 31: aload_2 32: aload_3 33: invokespecial Hello/connect(Ljavax/media/j3d/Canvas3D;Ljavax/media/j3d/BranchGroup;)V Label1: .line 23 36: return .end method .method private createCanvas3D()Ljavax/media/j3d/Canvas3D; .limit stack 3 .limit locals 3 .var 0 is this LHello; from Label0 to Label1 Label0: .line 26 0: aload_0 1: invokevirtual Hello/getContentPane()Ljava/awt/Container; 4: new java/awt/BorderLayout 7: dup 8: invokespecial java/awt/BorderLayout/<init>()V 11: invokevirtual java/awt/Container/setLayout(Ljava/awt/LayoutManager;)V .line 27 14: invokestatic com/sun/j3d/utils/universe/SimpleUniverse/getPreferredConfiguration()Ljava/awt/GraphicsConfiguration; 17: astore_1 .line 28 18: new javax/media/j3d/Canvas3D 21: dup 22: aload_1 23: invokespecial javax/media/j3d/Canvas3D/<init>(Ljava/awt/GraphicsConfiguration;)V 26: astore_2 .line 29 27: aload_0 28: invokevirtual Hello/getContentPane()Ljava/awt/Container; 31: aload_2 32: invokevirtual java/awt/Container/add(Ljava/awt/Component;)Ljava/awt/Component; 35: pop .line 30 36: aload_2 Label1: 37: areturn .end method .method public createSceneGraph()Ljavax/media/j3d/BranchGroup; .limit stack 7 .limit locals 5 .var 0 is this LHello; from Label0 to Label1 Label0: .line 34 0: new javax/media/j3d/BranchGroup 3: dup 4: invokespecial javax/media/j3d/BranchGroup/<init>()V 7: astore_1 .line 35 8: aload_0 9: invokespecial Hello/moveTextBack()Ljavax/media/j3d/TransformGroup; 12: astore_2 .line 36 13: aload_0 14: invokespecial Hello/createSpinner()Ljavax/media/j3d/TransformGroup; 17: astore_3 .line 37 18: new javax/media/j3d/RotationInterpolator 21: dup 22: new javax/media/j3d/Alpha 25: dup 26: iconst_m1 27: ldc2_w 4000 30: invokespecial javax/media/j3d/Alpha/<init>(IJ)V 33: aload_3 34: new javax/media/j3d/Transform3D 37: dup 38: invokespecial javax/media/j3d/Transform3D/<init>()V 41: fconst_0 42: ldc 6.2831855 44: invokespecial javax/media/j3d/RotationInterpolator/<init>(Ljavax/media/j3d/Alpha;Ljavax/media/j3d/TransformGroup;Ljavax/media/j3d/Transform3D;FF)V 47: astore 4 .line 38 49: aload 4 51: new javax/media/j3d/BoundingSphere 54: dup 55: invokespecial javax/media/j3d/BoundingSphere/<init>()V 58: invokevirtual javax/media/j3d/RotationInterpolator/setSchedulingBounds(Ljavax/media/j3d/Bounds;)V .line 39 61: aload_3 62: aload 4 64: invokevirtual javax/media/j3d/TransformGroup/addChild(Ljavax/media/j3d/Node;)V .line 40 67: aload_1 68: aload_2 69: invokevirtual javax/media/j3d/BranchGroup/addChild(Ljavax/media/j3d/Node;)V .line 41 72: aload_2 73: aload_3 74: invokevirtual javax/media/j3d/TransformGroup/addChild(Ljavax/media/j3d/Node;)V .line 42 77: aload_3 78: aload_0 79: invokespecial Hello/createTextShape()Ljavax/media/j3d/Shape3D; 82: invokevirtual javax/media/j3d/TransformGroup/addChild(Ljavax/media/j3d/Node;)V .line 43 85: aload_0 86: aload_2 87: invokespecial Hello/setLighting(Ljavax/media/j3d/TransformGroup;)V .line 44 90: aload_1 Label1: 91: areturn .end method .method private createSpinner()Ljavax/media/j3d/TransformGroup; .limit stack 2 .limit locals 2 .var 0 is this LHello; from Label0 to Label1 Label0: .line 48 0: new javax/media/j3d/TransformGroup 3: dup 4: invokespecial javax/media/j3d/TransformGroup/<init>()V 7: astore_1 .line 49 8: aload_1 9: bipush 18 11: invokevirtual javax/media/j3d/TransformGroup/setCapability(I)V .line 50 14: aload_1 Label1: 15: areturn .end method .method private moveTextBack()Ljavax/media/j3d/TransformGroup; .limit stack 6 .limit locals 2 .var 0 is this LHello; from Label0 to Label1 Label0: .line 54 0: new javax/media/j3d/Transform3D 3: dup 4: invokespecial javax/media/j3d/Transform3D/<init>()V 7: astore_1 .line 55 8: aload_1 9: new javax/vecmath/Vector3f 12: dup 13: fconst_0 14: fconst_0 15: ldc -10.0 17: invokespecial javax/vecmath/Vector3f/<init>(FFF)V 20: invokevirtual javax/media/j3d/Transform3D/setTranslation(Ljavax/vecmath/Vector3f;)V .line 56 23: new javax/media/j3d/TransformGroup 26: dup 27: aload_1 28: invokespecial javax/media/j3d/TransformGroup/<init>(Ljavax/media/j3d/Transform3D;)V Label1: 31: areturn .end method .method private createTextShape()Ljavax/media/j3d/Shape3D; .limit stack 7 .limit locals 5 .var 0 is this LHello; from Label0 to Label1 Label0: .line 60 0: new javax/media/j3d/Appearance 3: dup 4: invokespecial javax/media/j3d/Appearance/<init>()V 7: astore_1 .line 61 8: aload_1 9: new javax/media/j3d/Material 12: dup 13: invokespecial javax/media/j3d/Material/<init>()V 16: invokevirtual javax/media/j3d/Appearance/setMaterial(Ljavax/media/j3d/Material;)V .line 62 19: new javax/media/j3d/Font3D 22: dup 23: new java/awt/Font 26: dup 27: ldc "MS Pゴシック" 29: iconst_0 30: iconst_1 31: invokespecial java/awt/Font/<init>(Ljava/lang/String;II)V 34: new javax/media/j3d/FontExtrusion 37: dup 38: invokespecial javax/media/j3d/FontExtrusion/<init>()V 41: invokespecial javax/media/j3d/Font3D/<init>(Ljava/awt/Font;Ljavax/media/j3d/FontExtrusion;)V 44: astore_2 .line 63 45: new javax/media/j3d/Text3D 48: dup 49: aload_2 50: new java/lang/String 53: dup 54: ldc "Hello, Java 3D World!" 56: invokespecial java/lang/String/<init>(Ljava/lang/String;)V 59: invokespecial javax/media/j3d/Text3D/<init>(Ljavax/media/j3d/Font3D;Ljava/lang/String;)V 62: astore_3 .line 64 63: aload_3 64: iconst_0 65: invokevirtual javax/media/j3d/Text3D/setAlignment(I)V .line 65 68: new javax/media/j3d/Shape3D 71: dup 72: invokespecial javax/media/j3d/Shape3D/<init>()V 75: astore 4 .line 66 77: aload 4 79: aload_3 80: invokevirtual javax/media/j3d/Shape3D/setGeometry(Ljavax/media/j3d/Geometry;)V .line 67 83: aload 4 85: aload_1 86: invokevirtual javax/media/j3d/Shape3D/setAppearance(Ljavax/media/j3d/Appearance;)V .line 68 89: aload 4 Label1: 91: areturn .end method .method private setLighting(Ljavax/media/j3d/TransformGroup;)V .limit stack 6 .limit locals 3 .var 0 is this LHello; from Label0 to Label1 .var 1 is arg0 Ljavax/media/j3d/TransformGroup; from Label0 to Label1 Label0: .line 72 0: new javax/media/j3d/DirectionalLight 3: dup 4: invokespecial javax/media/j3d/DirectionalLight/<init>()V 7: astore_2 .line 73 8: aload_2 9: new javax/media/j3d/BoundingSphere 12: dup 13: invokespecial javax/media/j3d/BoundingSphere/<init>()V 16: invokevirtual javax/media/j3d/DirectionalLight/setInfluencingBounds(Ljavax/media/j3d/Bounds;)V .line 74 19: aload_2 20: new javax/vecmath/Vector3f 23: dup 24: fconst_0 25: fconst_0 26: ldc -1.0 28: invokespecial javax/vecmath/Vector3f/<init>(FFF)V 31: invokevirtual javax/media/j3d/DirectionalLight/setDirection(Ljavax/vecmath/Vector3f;)V .line 75 34: aload_2 35: new javax/vecmath/Color3f 38: dup 39: fconst_1 40: fconst_1 41: fconst_1 42: invokespecial javax/vecmath/Color3f/<init>(FFF)V 45: invokevirtual javax/media/j3d/DirectionalLight/setColor(Ljavax/vecmath/Color3f;)V .line 76 48: aload_1 49: aload_2 50: invokevirtual javax/media/j3d/TransformGroup/addChild(Ljavax/media/j3d/Node;)V Label1: .line 77 53: return .end method .method private connect(Ljavax/media/j3d/Canvas3D;Ljavax/media/j3d/BranchGroup;)V .limit stack 3 .limit locals 4 .var 0 is this LHello; from Label0 to Label1 .var 1 is arg0 Ljavax/media/j3d/Canvas3D; from Label0 to Label1 .var 2 is arg1 Ljavax/media/j3d/BranchGroup; from Label0 to Label1 Label0: .line 80 0: new com/sun/j3d/utils/universe/SimpleUniverse 3: dup 4: aload_1 5: invokespecial com/sun/j3d/utils/universe/SimpleUniverse/<init>(Ljavax/media/j3d/Canvas3D;)V 8: astore_3 .line 81 9: aload_3 10: invokevirtual com/sun/j3d/utils/universe/SimpleUniverse/getViewingPlatform()Lcom/sun/j3d/utils/universe/ViewingPlatform; 13: invokevirtual com/sun/j3d/utils/universe/ViewingPlatform/setNominalViewingTransform()V .line 82 16: aload_3 17: aload_2 18: invokevirtual com/sun/j3d/utils/universe/SimpleUniverse/addBranchGraph(Ljavax/media/j3d/BranchGroup;)V Label1: .line 83 21: return .end method
コンパイル&実行方法
C:¥> java -jar jasmin.jar Hello.j C:¥> javaw Hello
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Java 3D World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
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! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, JavaFX(Jasmin) World!
Posted on 1月 3rd, 2013 by cx20
JavaFX(Jasmin)
JavaFX は Java による RIA 向けの GUI ライブラリならびにプラットフォームである。
類似の RIA プラットフォームとしては Adobe Flex や Microsoft Silverlight などがある。
以下は Jasmin による JavaFX の使用例となっている。ソースコード
; 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:36:56 JST 2012 .bytecode 51.0 .source Hello.java .class public Hello .super javafx/application/Application .method public <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 7 0: aload_0 1: invokespecial javafx/application/Application/<init>()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 2 .limit locals 1 .var 0 is arg0 [Ljava/lang/String; from Label0 to Label1 Label0: .line 9 0: ldc_w Hello 3: aload_0 4: invokestatic javafx/application/Application/launch(Ljava/lang/Class;[Ljava/lang/String;)V Label1: .line 10 7: return .end method .method public start(Ljavafx/stage/Stage;)V .limit stack 7 .limit locals 4 .var 0 is this LHello; from Label0 to Label1 .var 1 is arg0 Ljavafx/stage/Stage; from Label0 to Label1 Label0: .line 14 0: new javafx/scene/layout/HBox 3: dup 4: invokespecial javafx/scene/layout/HBox/<init>()V 7: astore_2 .line 15 8: new javafx/scene/Scene 11: dup 12: aload_2 13: ldc2_w 640.0 16: ldc2_w 480.0 19: invokespecial javafx/scene/Scene/<init>(Ljavafx/scene/Parent;DD)V 22: astore_3 .line 16 23: aload_2 24: invokevirtual javafx/scene/layout/HBox/getChildren()Ljavafx/collections/ObservableList; 27: new javafx/scene/control/Label 30: dup 31: ldc "Hello, JavaFX World!" 33: invokespecial javafx/scene/control/Label/<init>(Ljava/lang/String;)V 36: invokeinterface javafx/collections/ObservableList/add(Ljava/lang/Object;)Z 2 41: pop .line 18 42: aload_1 43: aload_3 44: invokevirtual javafx/stage/Stage/setScene(Ljavafx/scene/Scene;)V .line 19 47: aload_1 48: ldc "Hello, World" 50: invokevirtual javafx/stage/Stage/setTitle(Ljava/lang/String;)V .line 20 53: aload_1 54: invokevirtual javafx/stage/Stage/show()V Label1: .line 21 57: return .end method
コンパイル&実行方法
C:¥> SET JAVAFX_HOME=C:\Program Files (x86)\Oracle\JavaFX 2.0 SDK C:¥> java -jar jasmin.jar Hello.j C:¥> javaw -cp "%JAVAFX_HOME%\rt\lib\jfxrt.jar;." Hello
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, JavaFX World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, SWT(Jasmin) World!
Posted on 1月 2nd, 2013 by cx20
SWT(Java)
SWT(Standard Widget Toolkit) は Java で GUI を扱うためのライブラリである。
IBM により AWT や Swing を置き換える目的で作成された。
以下は Jasmin による SWT の使用例となっている。ソースコード
; 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:23:19 JST 2012 .bytecode 50.0 .source Hello.java .class public Hello .super java/lang/Object .method public <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 5 0: aload_0 1: invokespecial java/lang/Object/<init>()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 4 .limit locals 5 .var 0 is arg0 [Ljava/lang/String; from Label3 to Label4 Label3: .line 7 0: new org/eclipse/swt/widgets/Display 3: dup 4: invokespecial org/eclipse/swt/widgets/Display/<init>()V 7: astore_1 .line 8 8: new org/eclipse/swt/widgets/Shell 11: dup 12: aload_1 13: invokespecial org/eclipse/swt/widgets/Shell/<init>(Lorg/eclipse/swt/widgets/Display;)V 16: astore_2 .line 9 17: aload_2 18: ldc "Hello, World" 20: invokevirtual org/eclipse/swt/widgets/Shell/setText(Ljava/lang/String;)V .line 12 23: new org/eclipse/swt/layout/FillLayout 26: dup 27: sipush 512 30: invokespecial org/eclipse/swt/layout/FillLayout/<init>(I)V 33: astore_3 .line 13 34: aload_2 35: aload_3 36: invokevirtual org/eclipse/swt/widgets/Shell/setLayout(Lorg/eclipse/swt/widgets/Layout;)V .line 15 39: new org/eclipse/swt/widgets/Label 42: dup 43: aload_2 44: sipush 2048 47: invokespecial org/eclipse/swt/widgets/Label/<init>(Lorg/eclipse/swt/widgets/Composite;I)V 50: astore 4 .line 16 52: aload 4 54: ldc "Hello, SWT World!" 56: invokevirtual org/eclipse/swt/widgets/Label/setText(Ljava/lang/String;)V .line 18 59: aload_2 60: sipush 640 63: sipush 480 66: invokevirtual org/eclipse/swt/widgets/Shell/setSize(II)V .line 19 69: aload_2 70: invokevirtual org/eclipse/swt/widgets/Shell/open()V Label1: .line 21 73: aload_2 74: invokevirtual org/eclipse/swt/widgets/Shell/isDisposed()Z 77: ifne Label0 .line 22 80: aload_1 81: invokevirtual org/eclipse/swt/widgets/Display/readAndDispatch()Z 84: ifne Label1 .line 23 87: aload_1 88: invokevirtual org/eclipse/swt/widgets/Display/sleep()Z 91: pop 92: goto Label1 Label0: .line 27 95: aload_1 96: invokevirtual org/eclipse/swt/widgets/Display/dispose()V Label4: .line 28 99: return .end method
コンパイル&実行方法
C:¥> java -jar jasmin.jar Hello.j C:¥> javaw -cp org.eclipse.swt.win32.win32.x86_3.6.1.v3655c.jar;. Hello
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, SWT World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, Swing(Jasmin) World!
Posted on 1月 1st, 2013 by cx20
Swing(Java)
Swing は AWT(Abstract Window Toolkit) を拡張したものであり Java で GUI を扱うためのライブラリである。
J2SE 1.2 以降は AWT よりも Swing が使われることが多くなっている。
以下は Jasmin による Swing の使用例となっている。ソースコード
; 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:16:09 JST 2012 .bytecode 51.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 7 0: new Hello 3: dup 4: ldc "Hello, World" 6: invokespecial Hello/<init>(Ljava/lang/String;)V 9: astore_1 .line 8 10: aload_1 11: iconst_1 12: invokevirtual Hello/setVisible(Z)V Label1: .line 9 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 12 0: aload_0 1: aload_1 2: invokespecial javax/swing/JFrame/<init>(Ljava/lang/String;)V .line 13 5: aload_0 6: iconst_3 7: invokevirtual Hello/setDefaultCloseOperation(I)V .line 14 10: aload_0 11: aconst_null 12: invokevirtual Hello/setLocationRelativeTo(Ljava/awt/Component;)V .line 15 15: aload_0 16: sipush 640 19: sipush 480 22: invokevirtual Hello/setSize(II)V .line 17 25: new javax/swing/JLabel 28: dup 29: ldc "Hello, Swing World!" 31: invokespecial javax/swing/JLabel/<init>(Ljava/lang/String;)V 34: astore_2 .line 18 35: aload_2 36: iconst_1 37: invokevirtual javax/swing/JLabel/setVerticalAlignment(I)V .line 19 40: aload_0 41: aload_2 42: invokevirtual Hello/add(Ljava/awt/Component;)Ljava/awt/Component; 45: pop Label1: .line 20 46: return .end method
コンパイル&実行方法
C:¥> java -jar jasmin.jar Hello.j C:¥> javaw Hello
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, Swing World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, AWT(Jasmin) World!
Posted on 12月 31st, 2012 by cx20
AWT(Java)
AWT(Abstract Window Toolkit) は Java で GUI を扱うためのライブラリである。
J2SE 1.2 以降は AWT を拡張した Swing が使われることが多くなっている。
以下は Jasmin による AWT の使用例となっている。ソースコード
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Sun Dec 02 00:54:44 JST 2012 .bytecode 51.0 .source Hello.java .class public Hello .super java/awt/Frame .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 6 0: new Hello 3: dup 4: ldc "Hello, World" 6: invokespecial Hello/<init>(Ljava/lang/String;)V 9: astore_1 .line 7 10: aload_1 11: iconst_1 12: invokevirtual Hello/setVisible(Z)V Label1: .line 8 15: return .end method .method <init>(Ljava/lang/String;)V .limit stack 4 .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 11 0: aload_0 1: aload_1 2: invokespecial java/awt/Frame/<init>(Ljava/lang/String;)V .line 13 5: aload_0 6: new java/awt/FlowLayout 9: dup 10: iconst_0 11: invokespecial java/awt/FlowLayout/<init>(I)V 14: invokevirtual Hello/setLayout(Ljava/awt/LayoutManager;)V .line 15 17: new java/awt/Label 20: dup 21: ldc "Hello, AWT World!" 23: invokespecial java/awt/Label/<init>(Ljava/lang/String;)V 26: astore_2 .line 16 27: aload_0 28: aload_2 29: invokevirtual Hello/add(Ljava/awt/Component;)Ljava/awt/Component; 32: pop .line 18 33: aload_0 34: new HelloWindowAdapter 37: dup 38: invokespecial HelloWindowAdapter/<init>()V 41: invokevirtual Hello/addWindowListener(Ljava/awt/event/WindowListener;)V .line 19 44: aload_0 45: sipush 640 48: sipush 480 51: invokevirtual Hello/setSize(II)V Label1: .line 20 54: 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 00:54:57 JST 2012 .bytecode 51.0 .source Hello.java .class HelloWindowAdapter .super java/awt/event/WindowAdapter .method <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHelloWindowAdapter; from Label0 to Label1 Label0: .line 24 0: aload_0 1: invokespecial java/awt/event/WindowAdapter/<init>()V Label1: 4: return .end method .method public windowClosing(Ljava/awt/event/WindowEvent;)V .limit stack 1 .limit locals 2 .var 0 is this LHelloWindowAdapter; from Label0 to Label1 .var 1 is arg0 Ljava/awt/event/WindowEvent; from Label0 to Label1 Label0: .line 26 0: iconst_0 1: invokestatic java/lang/System/exit(I)V Label1: .line 27 4: return .end method
コンパイル&実行方法
C:¥> java -jar jasmin.jar Hello.j HelloWindowAdapter.j C:¥> javaw Hello
実行結果
+------------------------------------------+ |Hello, World! [_][~][X]| +------------------------------------------+ |Hello, AWT World! | | | | | | | | | | | | | | | | | | | +------------------------------------------+
-
Hello, JDBC Type4(Jasmin) World!
Posted on 10月 30th, 2012 by cx20
JDBC Type4
JDBC(Java Database Connectivity)は、Java 用のデータベース接続 API である。実装方法によりType1~4の4つのタイプが存在する。
Type4 は DBMS のクライアントライブラリを使用しない Pure Java の DBMS ドライバである。
以下は Jasmin による JDBC ライブラリの使用例となっている。ソースコード(Jasmin + JDBC Type4 + SQL Server)
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Tue Oct 16 23:33:16 JST 2012 .bytecode 50.0 .source Hello.java .class Hello .super java/lang/Object .method <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 3 0: aload_0 1: invokespecial java/lang/Object/<init>()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 3 .limit locals 4 .var 0 is arg0 [Ljava/lang/String; from Label2 to Label3 Label2: .line 6 0: ldc "com.microsoft.sqlserver.jdbc.SQLServerDriver" 2: invokestatic java/lang/Class/forName(Ljava/lang/String;)Ljava/lang/Class; 5: pop .line 8 6: ldc "jdbc:sqlserver://;serverName=localhost" 8: ldc "sa" 10: ldc "P@ssW0rd" 12: invokestatic java/sql/DriverManager/getConnection(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection; 15: astore_1 .line 9 16: aload_1 17: invokeinterface java/sql/Connection/createStatement()Ljava/sql/Statement; 1 22: astore_2 .line 10 23: aload_2 24: ldc "SELECT 'Hello, JDBC Type4 World!' AS Message" 26: invokeinterface java/sql/Statement/executeQuery(Ljava/lang/String;)Ljava/sql/ResultSet; 2 31: astore_3 Label1: .line 11 32: aload_3 33: invokeinterface java/sql/ResultSet/next()Z 1 38: ifeq Label0 .line 12 41: getstatic java.lang.System.out Ljava/io/PrintStream; 44: aload_3 45: iconst_1 46: invokeinterface java/sql/ResultSet/getString(I)Ljava/lang/String; 2 51: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V 54: goto Label1 Label0: .line 14 57: aload_3 58: invokeinterface java/sql/ResultSet/close()V 1 .line 15 63: aload_2 64: invokeinterface java/sql/Statement/close()V 1 .line 16 69: aload_1 70: invokeinterface java/sql/Connection/close()V 1 Label3: .line 17 75: return .throws java/lang/Exception .end method
実行方法(Jasmin + JDBC Type4 + SQL Server)
C:¥> java -jar jasmin.jar Hello.j C:¥> java -cp sqljdbc4.jar;. Hello
ソースコード(Jasmin + JDBC Type4 + Oracle)
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Tue Oct 16 23:37:45 JST 2012 .bytecode 50.0 .source Hello.java .class Hello .super java/lang/Object .method <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 3 0: aload_0 1: invokespecial java/lang/Object/<init>()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 3 .limit locals 4 .var 0 is arg0 [Ljava/lang/String; from Label2 to Label3 Label2: .line 6 0: ldc "oracle.jdbc.driver.OracleDriver" 2: invokestatic java/lang/Class/forName(Ljava/lang/String;)Ljava/lang/Class; 5: pop .line 8 6: ldc "jdbc:oracle:thin:@localhost:1521:orcl" 8: ldc "scott" 10: ldc "tiger" 12: invokestatic java/sql/DriverManager/getConnection(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection; 15: astore_1 .line 9 16: aload_1 17: invokeinterface java/sql/Connection/createStatement()Ljava/sql/Statement; 1 22: astore_2 .line 10 23: aload_2 24: ldc "SELECT 'Hello, JDBC Type4 World!' AS Message FROM DUAL" 26: invokeinterface java/sql/Statement/executeQuery(Ljava/lang/String;)Ljava/sql/ResultSet; 2 31: astore_3 Label1: .line 11 32: aload_3 33: invokeinterface java/sql/ResultSet/next()Z 1 38: ifeq Label0 .line 12 41: getstatic java.lang.System.out Ljava/io/PrintStream; 44: aload_3 45: iconst_1 46: invokeinterface java/sql/ResultSet/getString(I)Ljava/lang/String; 2 51: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V 54: goto Label1 Label0: .line 14 57: aload_3 58: invokeinterface java/sql/ResultSet/close()V 1 .line 15 63: aload_2 64: invokeinterface java/sql/Statement/close()V 1 .line 16 69: aload_1 70: invokeinterface java/sql/Connection/close()V 1 Label3: .line 17 75: return .throws java/lang/Exception .end method
実行方法(Jasmin + JDBC Type4 + Oracle)
C:¥> java -jar jasmin.jar Hello.j C:¥> java -cp ojdbc6.jar;. Hello
ソースコード(Jasmin + JDBC Type4 + MySQL)
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Tue Oct 16 23:37:45 JST 2012 .bytecode 50.0 .source Hello.java .class Hello .super java/lang/Object .method <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 3 0: aload_0 1: invokespecial java/lang/Object/<init>()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 3 .limit locals 4 .var 0 is arg0 [Ljava/lang/String; from Label2 to Label3 Label2: .line 6 0: ldc "com.mysql.jdbc.Driver" 2: invokestatic java/lang/Class/forName(Ljava/lang/String;)Ljava/lang/Class; 5: pop .line 8 6: ldc "jdbc:mysql://localhost:3306" 8: ldc "root" 10: ldc "P@ssW0rd" 12: invokestatic java/sql/DriverManager/getConnection(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection; 15: astore_1 .line 9 16: aload_1 17: invokeinterface java/sql/Connection/createStatement()Ljava/sql/Statement; 1 22: astore_2 .line 10 23: aload_2 24: ldc "SELECT 'Hello, JDBC Type4 World!' AS Message" 26: invokeinterface java/sql/Statement/executeQuery(Ljava/lang/String;)Ljava/sql/ResultSet; 2 31: astore_3 Label1: .line 11 32: aload_3 33: invokeinterface java/sql/ResultSet/next()Z 1 38: ifeq Label0 .line 12 41: getstatic java.lang.System.out Ljava/io/PrintStream; 44: aload_3 45: iconst_1 46: invokeinterface java/sql/ResultSet/getString(I)Ljava/lang/String; 2 51: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V 54: goto Label1 Label0: .line 14 57: aload_3 58: invokeinterface java/sql/ResultSet/close()V 1 .line 15 63: aload_2 64: invokeinterface java/sql/Statement/close()V 1 .line 16 69: aload_1 70: invokeinterface java/sql/Connection/close()V 1 Label3: .line 17 75: return .throws java/lang/Exception .end method
実行方法(Jasmin + JDBC Type4 + MySQL)
C:¥> java -jar jasmin.jar Hello.j C:¥> java -cp mysql-connector-java-5.1.22-bin.jar;. Hello
実行結果
Hello, JDBC Type4 World!
-
Hello, JDBC Type2(Jasmin) World!
Posted on 10月 29th, 2012 by cx20
JDBC Type2
JDBC(Java Database Connectivity)は、Java 用のデータベース接続 API である。実装方法によりType1~4の4つのタイプが存在する。
Type2 は JDBC と DBMS クライアントの API をマップさせたブリッジドライバである。
例えば、Oracle であればクライアントライブラリとして OCI が使用される。
以下は Jasmin による JDBC ライブラリの使用例となっている。ソースコード(Jasmin + JDBC Type2 + Oracle)
; Produced by NeoJasminVisitor (tinapoc) ; http://tinapoc.sourceforge.net ; The original JasminVisitor is part of the BCEL ; http://jakarta.apache.org/bcel/ ; Tue Oct 16 23:37:45 JST 2012 .bytecode 50.0 .source Hello.java .class Hello .super java/lang/Object .method <init>()V .limit stack 1 .limit locals 1 .var 0 is this LHello; from Label0 to Label1 Label0: .line 3 0: aload_0 1: invokespecial java/lang/Object/<init>()V Label1: 4: return .end method .method public static main([Ljava/lang/String;)V .limit stack 3 .limit locals 4 .var 0 is arg0 [Ljava/lang/String; from Label2 to Label3 Label2: .line 6 0: ldc "oracle.jdbc.driver.OracleDriver" 2: invokestatic java/lang/Class/forName(Ljava/lang/String;)Ljava/lang/Class; 5: pop .line 8 6: ldc "jdbc:oracle:oci:@orcl" 8: ldc "scott" 10: ldc "tiger" 12: invokestatic java/sql/DriverManager/getConnection(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection; 15: astore_1 .line 9 16: aload_1 17: invokeinterface java/sql/Connection/createStatement()Ljava/sql/Statement; 1 22: astore_2 .line 10 23: aload_2 24: ldc "SELECT 'Hello, JDBC Type4 World!' AS Message FROM DUAL" 26: invokeinterface java/sql/Statement/executeQuery(Ljava/lang/String;)Ljava/sql/ResultSet; 2 31: astore_3 Label1: .line 11 32: aload_3 33: invokeinterface java/sql/ResultSet/next()Z 1 38: ifeq Label0 .line 12 41: getstatic java.lang.System.out Ljava/io/PrintStream; 44: aload_3 45: iconst_1 46: invokeinterface java/sql/ResultSet/getString(I)Ljava/lang/String; 2 51: invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V 54: goto Label1 Label0: .line 14 57: aload_3 58: invokeinterface java/sql/ResultSet/close()V 1 .line 15 63: aload_2 64: invokeinterface java/sql/Statement/close()V 1 .line 16 69: aload_1 70: invokeinterface java/sql/Connection/close()V 1 Label3: .line 17 75: return .throws java/lang/Exception .end method
実行方法
C:¥> java -jar jasmin.jar Hello.j C:¥> java -cp ojdbc6.jar;. Hello
実行結果
Hello, JDBC Type2 World!