Java字节码说明

Mnemonic Opcode (in hex) Opcode (in binary) Other bytes Stack[before]->[after] Description
aaload 32 0011 0010 arrayref, index → value load onto the stack a reference from an array
aastore 53 0101 0011 arrayref, index, value → store a reference in an array
aconst_null 01 0000 0001 → null push a null reference onto the stack
aload 19 0001 1001 1: index → objectref load a reference onto the stack from a local variable #index
aload_0 2a 0010 1010 → objectref load a reference onto the stack from local variable 0
aload_1 2b 0010 1011 → objectref load a reference onto the stack from local variable 1
aload_2 2c 0010 1100 → objectref load a reference onto the stack from local variable 2
aload_3 2d 0010 1101 → objectref load a reference onto the stack from local variable 3
anewarray bd 1011 1101 2: indexbyte1, indexbyte2 count → arrayref create a new array of references of length count and component type identified by the class reference index (indexbyte1 << 8 | indexbyte2) in the constant pool
areturn b0 1011 0000 objectref → [empty] return a reference from a method
arraylength be 1011 1110 arrayref → length get the length of an array
astore 3a 0011 1010 1: index objectref → store a reference into a local variable #index
astore_0 4b 0100 1011 objectref → store a reference into local variable 0
astore_1 4c 0100 1100 objectref → store a reference into local variable 1
astore_2 4d 0100 1101 objectref → store a reference into local variable 2
astore_3 4e 0100 1110 objectref → store a reference into local variable 3
athrow bf 1011 1111 objectref → [empty], objectref throws an error or exception (notice that the rest of the stack is cleared, leaving only a reference to the Throwable)
baload 33 0011 0011 arrayref, index → value load a byte or Boolean value from an array
bastore 54 0101 0100 arrayref, index, value → store a byte or Boolean value into an array
bipush 10 0001 0000 1: byte → value push a byte onto the stack as an integer value
breakpoint ca 1100 1010 reserved for breakpoints in Java debuggers; should not appear in any class file
caload 34 0011 0100 arrayref, index → value load a char from an array
castore 55 0101 0101 arrayref, index, value → store a char into an array
checkcast c0 1100 0000 2: indexbyte1, indexbyte2 objectref → objectref checks whether an objectref is of a certain type, the class reference of which is in the constant pool at index (indexbyte1 << 8 | indexbyte2)
d2f 90 1001 0000 value → result convert a double to a float
d2i 8e 1000 1110 value → result convert a double to an int
d2l 8f 1000 1111 value → result convert a double to a long
dadd 63 0110 0011 value1, value2 → result add two doubles
daload 31 0011 0001 arrayref, index → value load a double from an array
dastore 52 0101 0010 arrayref, index, value → store a double into an array
dcmpg 98 1001 1000 value1, value2 → result compare two doubles, 1 on NaN
dcmpl 97 1001 0111 value1, value2 → result compare two doubles, -1 on NaN
dconst_0 0e 0000 1110 → 0.0 push the constant 0.0 (a double) onto the stack
dconst_1 0f 0000 1111 → 1.0 push the constant 1.0 (a double) onto the stack
ddiv 6f 0110 1111 value1, value2 → result divide two doubles
dload 18 0001 1000 1: index → value load a double value from a local variable #index
dload_0 26 0010 0110 → value load a double from local variable 0
dload_1 27 0010 0111 → value load a double from local variable 1
dload_2 28 0010 1000 → value load a double from local variable 2
dload_3 29 0010 1001 → value load a double from local variable 3
dmul 6b 0110 1011 value1, value2 → result multiply two doubles
dneg 77 0111 0111 value → result negate a double
drem 73 0111 0011 value1, value2 → result get the remainder from a division between two doubles
dreturn af 1010 1111 value → [empty] return a double from a method
dstore 39 0011 1001 1: index value → store a double value into a local variable #index
dstore_0 47 0100 0111 value → store a double into local variable 0
dstore_1 48 0100 1000 value → store a double into local variable 1
dstore_2 49 0100 1001 value → store a double into local variable 2
dstore_3 4a 0100 1010 value → store a double into local variable 3
dsub 67 0110 0111 value1, value2 → result subtract a double from another
dup 59 0101 1001 value → value, value duplicate the value on top of the stack
dup_x1 5a 0101 1010 value2, value1 → value1, value2, value1 insert a copy of the top value into the stack two values from the top. value1 and value2 must not be of the type double or long.
dup_x2 5b 0101 1011 value3, value2, value1 → value1, value3, value2, value1 insert a copy of the top value into the stack two (if value2 is double or long it takes up the entry of value3, too) or three values (if value2 is neither double nor long) from the top
dup2 5c 0101 1100 {value2, value1} → {value2, value1}, {value2, value1} duplicate top two stack words (two values, if value1 is not double nor long; a single value, if value1 is double or long)
dup2_x1 5d 0101 1101 value3, {value2, value1} → {value2, value1}, value3, {value2, value1} duplicate two words and insert beneath third word (see explanation above)
dup2_x2 5e 0101 1110 {value4, value3}, {value2, value1} → {value2, value1}, {value4, value3}, {value2, value1} duplicate two words and insert beneath fourth word
f2d 8d 1000 1101 value → result convert a float to a double
f2i 8b 1000 1011 value → result convert a float to an int
f2l 8c 1000 1100 value → result convert a float to a long
fadd 62 0110 0010 value1, value2 → result add two floats
faload 30 0011 0000 arrayref, index → value load a float from an array
fastore 51 0101 0001 arrayref, index, value → store a float in an array
fcmpg 96 1001 0110 value1, value2 → result compare two floats, 1 on NaN
fcmpl 95 1001 0101 value1, value2 → result compare two floats, -1 on NaN
fconst_0 0b 0000 1011 → 0.0f push 0.0f on the stack
fconst_1 0c 0000 1100 → 1.0f push 1.0f on the stack
fconst_2 0d 0000 1101 → 2.0f push 2.0f on the stack
fdiv 6e 0110 1110 value1, value2 → result divide two floats
fload 17 0001 0111 1: index → value load a float value from a local variable #index
fload_0 22 0010 0010 → value load a float value from local variable 0
fload_1 23 0010 0011 → value load a float value from local variable 1
fload_2 24 0010 0100 → value load a float value from local variable 2
fload_3 25 0010 0101 → value load a float value from local variable 3
fmul 6a 0110 1010 value1, value2 → result multiply two floats
fneg 76 0111 0110 value → result negate a float
frem 72 0111 0010 value1, value2 → result get the remainder from a division between two floats
freturn ae 1010 1110 value → [empty] return a float
fstore 38 0011 1000 1: index value → store a float value into a local variable #index
fstore_0 43 0100 0011 value → store a float value into local variable 0
fstore_1 44 0100 0100 value → store a float value into local variable 1
fstore_2 45 0100 0101 value → store a float value into local variable 2
fstore_3 46 0100 0110 value → store a float value into local variable 3
fsub 66 0110 0110 value1, value2 → result subtract two floats
getfield b4 1011 0100 2: indexbyte1, indexbyte2 objectref → value get a field value of an object objectref, where the field is identified by field reference in the constant pool index (indexbyte1 << 8 | indexbyte2)
getstatic b2 1011 0010 2: indexbyte1, indexbyte2 → value get a static field value of a class, where the field is identified by field reference in the constant pool index (indexbyte1 << 8 | indexbyte2)
goto a7 1010 0111 2: branchbyte1, branchbyte2 [no change] goes to another instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 | branchbyte2)
goto_w c8 1100 1000 4: branchbyte1, branchbyte2, branchbyte3, branchbyte4 [no change] goes to another instruction at branchoffset (signed int constructed from unsigned bytes branchbyte1 << 24 | branchbyte2 << 16 | branchbyte3 << 8 | branchbyte4)
i2b 91 1001 0001 value → result convert an int into a byte
i2c 92 1001 0010 value → result convert an int into a character
i2d 87 1000 0111 value → result convert an int into a double
i2f 86 1000 0110 value → result convert an int into a float
i2l 85 1000 0101 value → result convert an int into a long
i2s 93 1001 0011 value → result convert an int into a short
iadd 60 0110 0000 value1, value2 → result add two ints
iaload 2e 0010 1110 arrayref, index → value load an int from an array
iand 7e 0111 1110 value1, value2 → result perform a bitwise AND on two integers
iastore 4f 0100 1111 arrayref, index, value → store an int into an array
iconst_m1 02 0000 0010 → -1 load the int value −1 onto the stack
dup2_x2 5e 0101 1110 {value4, value3}, {value2, value1} → {value2, value1}, {value4, value3}, {value2, value1} duplicate two words and insert beneath fourth word
dup2 5c 0101 1100 {value2, value1} → {value2, value1}, {value2, value1} duplicate top two stack words (two values, if value1 is not double nor long; a single value, if value1 is double or long)
pop2 58 0101 1000 {value2, value1} → discard the top two values on the stack (or one value, if it is a double or long)
wide c4 1100 0100 3/5: opcode, indexbyte1, indexbyte2 or iinc, indexbyte1, indexbyte2, countbyte1, countbyte2 [same as for corresponding instructions] execute opcode, where opcode is either iload, fload, aload, lload, dload, istore, fstore, astore, lstore, dstore, or ret, but assume the index is 16 bit; or execute iinc, where the index is 16 bits and the constant to increment by is a signed 16 bit short
iinc 84 1000 0100 2: index, const [No change] increment local variable #index by signed byte const
ret a9 1010 1001 1: index [No change] continue execution from address taken from a local variable #index (the asymmetry with jsr is intentional)
nop 00 0000 0000 [No change] perform no operation
goto_w c8 1100 1000 4: branchbyte1, branchbyte2, branchbyte3, branchbyte4 [no change] goes to another instruction at branchoffset (signed int constructed from unsigned bytes branchbyte1 << 24 | branchbyte2 << 16 | branchbyte3 << 8 | branchbyte4)
goto a7 1010 0111 2: branchbyte1, branchbyte2 [no change] goes to another instruction at branchoffset (signed short constructed from unsigned bytes branchbyte1 << 8 | branchbyte2)
invokedynamic ba 1011 1010 4: indexbyte1, indexbyte2, 0, 0 [arg1, arg2, ...] → result invokes a dynamic method and puts the result on the stack (might be void); the method is identified by method reference index in constant pool (indexbyte1 << 8 | indexbyte2)
invokestatic b8 1011 1000 2: indexbyte1, indexbyte2 [arg1, arg2, ...] → result invoke a static method and puts the result on the stack (might be void); the method is identified by method reference index in constant pool (indexbyte1 << 8 | indexbyte2)
breakpoint ca 1100 1010 reserved for breakpoints in Java debuggers; should not appear in any class file
impdep1 fe 1111 1110 reserved for implementation-dependent operations within debuggers; should not appear in any class file
impdep2 ff 1111 1111 reserved for implementation-dependent operations within debuggers; should not appear in any class file
(no name) cb-fd these values are currently unassigned for opcodes and are reserved for future use

原文:https://en.wikipedia.org/wiki/List_of_Java_bytecode_instructions

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,616评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,020评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,078评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,040评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,154评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,265评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,298评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,072评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,491评论 1 306
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,795评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,970评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,654评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,272评论 3 318
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,985评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,223评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,815评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,852评论 2 351

推荐阅读更多精彩内容