disassemble the code

489 ワード

これはバイトコードファイルを操作するもので、Testがあると仮定する.class
 
javap -c Test
 
int b = 9;
b = b + (b = 3);

 
  Code:
   0:   bipush  9
   2:   istore_1
   3:   iload_1
   4:   iconst_3
   5:   dup
   6:   istore_1
   7:   iadd
   8:   istore_1
   9:   return

 
1.見られるように、まず9をb 2に保存する.bの値、すなわち9 3をとる.定数値3が得られ、9回目のスタック4となる.3をb 5に格納.スタック内の加算動作6を実行する.bに保存して戻る