invokestatic
: This instruction is used to call static methods on a class. It is determined at compile time, which method will be called.invokevirtual
: This callspublic
andprotected
instance methods. Of course, it needs the instance reference on the stack, and also does the runtime binding (which adds overhead compared toinvokestatic
, but this "overhead" is not something you want to micro-optimize by design) for method dispatching. In fact,invokevirtual
is not a true instruction, the actual steps taken are determined at runtime (cf.invokestatic
) by the JVM, and can even involve Reflection, maybe even prohibit JIT in-place optimizations. Note, that the method handles are determined compile time, just the call path and strategy is determined at runtime (see: polymorphism).invokeinterface
: Similar toinvokevirtual
, just the method dispatch is based on an interface, not a class.invokespecial
: Calls the constructors (as they have special names that can't be referenced from plain Java code directly [on purpose]), alsoprivate
andsuper
(class parent's) methods.invokedynamic
: This was introduced to address the "performance issues" ofinvokevirtual
in a way, that the first call is executed as aninvokevirtual
, and the selected call path is stored for that invocation for subsequent reuse. In fact, this dynamic method resolution works with method handles obtained runtime (see:java.lang.invoke.*
methods), not at compile time.
According to The Directive 2009/24/EC of the European Parliament and of the Council, and Sec.103(f) of the DMCA (17 U.S.C. § 1201 (f)), the reverse engineering act committed to creating these blog posts is considered legal, as this is an original attempt to improve interoperability, and cannot be waived by license agreements.
The views expressed on this blog are my own and do not necessarily reflect the views of my past and present employers.
2016-10-25
Java: About invoke bytecode instructions
You can find the Java bytecode instruction here.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment