解答例 | 海谷ホームページ | 問題へ戻る | 学科 |
問題のCountAdapter.classは 解答は6/28の夜に一旦,集めました.
問題1
djava -c -o DJava CountAdapter.class の出力結果を参考にしながら,ちゃきちゃきやるしかないでしょう. あと, jasmin形式にしたアセンブラ も参考になります. というか,これらを参考にしないで解答を作るのは大変です! (まぁ,時間があればできるけど);; 384(d) bytes data (Revision: 4.9) CA FE BA BE ; magic number 00 03 ; minor version 00 2D ; major version 00 19 ; constant pool number= 24(d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 07 00 17 ;(00 01) Class => CountAdapter 01 00 0C 6D 6F 75 73 65 45 6E 74 65 72 65 64 ;(00 02) Utf8 = "mouseEntered" 01 00 06 3C 69 6E 69 74 3E ;(00 03) Utf8 = "<init>" 0C 00 03 00 07 ;(00 04) NameAndType => <init>:()V 0A 00 15 00 04 ;(00 05) Methodref => java/awt/event/MouseAdapter.<init>:()V 0C 00 14 00 10 ;(00 06) NameAndType => exit:(I)V 01 00 03 28 29 56 ;(00 07) Utf8 = "()V" 07 00 13 ;(00 08) Class => java/lang/System 01 00 04 43 6F 64 65 ;(00 09) Utf8 = "Code" 01 00 0C 6D 6F 75 73 65 50 72 65 73 73 65 64 ;(00 0A) Utf8 = "mousePressed" 0A 00 08 00 06 ;(00 0B) Methodref => java/lang/System.exit:(I)V 01 00 05 63 6F 75 6E 74 ;(00 0C) Utf8 = "count" 01 00 0F 43 6F 75 6E 74 41 64 61 70 74 65 72 2E 6A 32 ;(00 0D) Utf8 = "CountAdapter.j2" 01 00 0A 53 6F 75 72 63 65 46 69 6C 65 ;(00 0E) Utf8 = "SourceFile" 01 00 01 49 ;(00 0F) Utf8 = "I" 01 00 04 28 49 29 56 ;(00 10) Utf8 = "(I)V" ; 01 00 1E 28 4C 6A 61 76 61 2F 61 77 74 2F 65 76 65 6E 74 2F 4D 6F 75 73 65 45 76 65 6E 74 3B 29 56 ;(00 11) Utf8 = "(Ljava/awt/event/MouseEvent;)V" 01 00 1B 6A 61 76 61 2F 61 77 74 2F 65 76 65 6E 74 2F 4D 6F 75 73 65 41 64 61 70 74 65 72 ;(00 12) Utf8 = "java/awt/event/MouseAdapter" 01 00 10 6A 61 76 61 2F 6C 61 6E 67 2F 53 79 73 74 65 6D ;(00 13) Utf8 = "java/lang/System" 01 00 04 65 78 69 74 ;(00 14) Utf8 = "exit" 07 00 12 ;(00 15) Class => java/awt/event/MouseAdapter 09 00 01 00 18 ;(00 16) Fieldref => CountAdapter.count:I 01 00 0C 43 6F 75 6E 74 41 64 61 70 74 65 72 ;(00 17) Utf8 = "CountAdapter" 0C 00 0C 00 0F ;(00 18) NameAndType => count:I ;; class info. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00 20 ; access flag= SUPER p.58 00 01 ; this class= "CountAdapter" 00 15 ; super class= "java/awt/event/MouseAdapter" 00 00 ; num. of implemented interface(s)= 0(d) ;;;;;;;;;;;;;;;;;;;;;; 00 01 ; num. of field(s)= 1(d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;BEGIN field1(d) def. 00 02 ; access flag of method = PRIVATE p.62 00 0C ; method name ="count" 00 0F ; method type ="I" ; 00 00 ; num. of attribute(s), 0(d) ; ;END field1(d) def. 00 03 ; num. of methods(s)= 3(d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;BEGIN method1(d) def. 00 00 ; access flag of method = p.73 00 03 ; method name ="<init>" 00 07 ; method type ="()V" ; 00 01 ; num. of attribute(s), 1(d) ;;begin attribute 1(d) 00 09 ; attribute type= "Code" 00 00 00 16 ; attribute length= 22(d) ;; 00 02 ; stacks limits 00 01 ; locals limits 00 00 00 0A ; length of codes = 10(d) ;;; codes 2A ; aload_0 B7 00 05 ; invokespecial java/awt/event/MouseAdapter/<init>()V 2A ; aload_0 03 ; iconst_0 B5 00 16 ; putfield CountAdapter/count I B1 ; return ;; 00 00 ; num. of exception handler(s) = 0(d) ;; 00 00 ; num. of attr. of this code attr. = 0(d) ;;end attribute 1(d) ; ;END method1(d) def. ;BEGIN method2(d) def. 00 01 ; access flag of method = PUBLIC 00 02 ; method name ="mouseEntered" 00 11 ; method type ="(Ljava/awt/event/MouseEvent;)V" ; 00 01 ; num. of attribute(s), 1(d) ;;begin attribute 1(d) 00 09 ; attribute type= "Code" 00 00 00 17 ; attribute length= 23(d) ;; 00 03 ; stacks limits 00 02 ; locals limits 00 00 00 0B ; length of codes = 11(d) ;;; codes 2A ; aload_0 59 ; dup B4 00 16 ; getfield CountAdapter/count I 04 ; iconst_1 60 ; iadd B5 00 16 ; putfield CountAdapter/count I B1 ; return ;; 00 00 ; num. of exception handler(s) = 0(d) ;; 00 00 ; num. of attr. of this code attr. = 0(d) ;;end attribute 1(d) ; ;END method2(d) def. ;BEGIN method3(d) def. 00 01 ; access flag of method = PUBLIC 00 0A ; method name ="mousePressed" 00 11 ; method type ="(Ljava/awt/event/MouseEvent;)V" ; 00 01 ; num. of attribute(s), 1(d) ;;begin attribute 1(d) 00 09 ; attribute type= "Code" 00 00 00 14 ; attribute length= 20(d) ;; 00 01 ; stacks limits 00 02 ; locals limits 00 00 00 08 ; length of codes = 8(d) ;;; codes 2A ; aload_0 B4 00 16 ; getfield CountAdapter/count I B8 00 0B ; invokestatic java/lang/System/exit(I)V B1 ; return ;; 00 00 ; num. of exception handler(s) = 0(d) ;; 00 00 ; num. of attr. of this code attr. = 0(d) ;;end attribute 1(d) ; ;END method3(d) def. 00 00 ; num. of class attribute(s)= 0(d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; successfully parsed.
問題2
上記赤字の, B4 00 16 ; getfield CountAdapter/count I の部分のプール内の情報を図に書けばよい.
あー,画はデジカメでとった人もいましたが, まぁ,それでもOKです.(ってか,そんなこと思いつかなかった)
問題3
本ページトップ | 学科 | 問題 | 海谷ホームページ | $Id: index.html,v 1.3 2003-06-29 22:59:31+09 kaiya Exp kaiya $ |