[英]Why is `invokespecial` used to invoke `<init>` method in java?
Why is invokespecial
used to invoke <init>
method in java? 为什么invokespecial
用于在java中调用<init>
方法?
I read at multiple places but could not understand the perfect reason? 我在多个地方读过但却无法理解完美的理由?
Any help would be appreciated. 任何帮助,将不胜感激。
The main use of
invokespecial
is to invoke an object's instance initialization method,<init>
, during the construction phase for a new object.invokespecial
的主要用途是在构造阶段为新对象调用对象的实例初始化方法<init>
。
In other words,
invokespecial
is used to call methods without concern for dynamic binding, in order to invoke the particular class' version of a method. 换句话说,invokespecial
用于调用方法而不关心动态绑定,以便调用特定类的方法版本。
Second quotation is the most applicable to your question cause we know that calling constructor ( <init>
) method has always static binding. 第二个引用最适用于您的问题因为我们知道调用构造函数( <init>
)方法始终是静态绑定。
These link are useful with very simple language 这些链接对于非常简单的语言很有用
http://arhipov.blogspot.in/2011/01/java-bytecode-fundamentals.html http://arhipov.blogspot.in/2011/01/java-bytecode-fundamentals.html
http://commons.apache.org/bcel/manual.html http://commons.apache.org/bcel/manual.html
This article from ibm is also nice with good example 来自ibm的这篇文章也是很好的例子
http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/ http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.