调用接口方法比类方法慢。

相关指令:

invokeinterface

b9

4: indexbyte1, indexbyte2, count, 0

objectref, [arg1, arg2, ...] →

invokes an interface method on object objectref, where the interface method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)

invokespecial

b7

2: indexbyte1, indexbyte2

objectref, [arg1, arg2, ...] →

invoke instance method on object objectref, where the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)

invokestatic

b8

2: indexbyte1, indexbyte2

[arg1, arg2, ...] →

invoke a static method, where the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)

invokevirtual

b6

2: indexbyte1, indexbyte2

objectref, [arg1, arg2, ...] →

invoke virtual method on object objectref, where the method is identified by method reference index in constant pool (indexbyte1 << 8 + indexbyte2)



java接口方法和类方法的区别 - 调用速度_ide