Method Invocation and Dispatch

Source: Internet
Author: User

The Java Virtual machine provides 5 call bytecode instructions, respectively

Invokestatic: Calling a static method

Invokespecial: Invokes instance constructors <init> methods, private methods, and parent class methods.

Invokevirtual: Call virtual method.

Invokeinterfacel invokes an interface method, which at run time determines an object that implements this interface.

Invokedynamic: The method referenced by the call-point qualifier is parsed dynamically at run time before executing the method, where the dispatch logic is cured inside the Java Virtual machine in the previous four calling instructions. The dispatch logic of the invokedynamic instruction is determined by the user-defined guidance method.

As long as the method called by the invokestatic and invokespecial directives can determine a unique invocation version in the parsing phase, there are static methods that meet this condition, private methods, instance constructors, The parent class method has four classes. They parse the symbolic reference as a direct reference to the method when the class loads. These methods can be called non-virtual methods. In contrast, other methods are called virtual methods (except the final method.

Above from << in-depth understanding of Java virtual Machines >>

Method Invocation and Dispatch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.