- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我无法理解下面的文字... 是否意味着 <clinit>
是为空的构造函数?为什么拥有两个不同的版本很重要?
https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html
2.9. Special Methods
At the level of the Java virtual machine, every constructor (§2.12) appears as an instance initialization method that has the special name
<init>
. This name is supplied by a compiler. Because the name<init>
is not a valid identifier, it cannot be used directly in a program written in the Java programming language. Instance initialization methods may be invoked only within the Java virtual machine by the invokespecial instruction, and they may be invoked only on uninitialized class instances. An instance initialization method takes on the access permissions (§2.7.4) of the constructor from which it was derived.A class or interface has at most one class or interface initialization method and is initialized (§2.17.4) by invoking that method. The initialization method of a class or interface is static and takes no arguments. It has the special name
<clinit>
. This name is supplied by a compiler. Because the name<clinit>
is not a valid identifier, it cannot be used directly in a program written in the Java programming language. Class and interface initialization methods are invoked implicitly by the Java virtual machine; they are never invoked directly from any Java virtual machine inw2struction, but are invoked only indirectly as part of the class initialization process.
最佳答案
<init>
是实例的(或其中一个)构造函数,并且是非静态字段初始化。
<clinit>
是类的静态初始化 block ,以及静态字段初始化。
class X {
static Log log = LogFactory.getLog(); // <clinit>
private int x = 1; // <init>
X(){
// <init>
}
static {
// <clinit>
}
}
关于Java:<init> 和 <clinit> 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8517121/
我知道 new、dup、invokespecial 和 astore 字节码模式将调用初始化方法 在类实例化期间。什么调用了特殊的 方法,什么时候发生? 我的猜测是 在之前 方法被调用。这是否记
对于特定类,一个方法只执行一次是否正确? 最佳答案 我创建了测试类并按如下方式引用它 新运算符 反射(reflection) block 仅被引用 1 次 public class ClinitTe
我无法理解下面的文字... 是否意味着 是为空的构造函数?为什么拥有两个不同的版本很重要? https://docs.oracle.com/javase/specs/jvms/se7/html/jvm
当我看到 JVM 规范时,它说每个类最多有一个类初始化方法,那就是“clinit”,所以我认为我们应该有一些命令来查看该方法是如何在 .class 文件中编码的。 一开始我以为用javap就可以了,但
我正在使用 iCal4J 向 MS Outlook 发送约会,效果很好,约会正在进行中。但是我的控制台显示以下内容: Oct 24, 2013 9:53:57 AM net.fortuna.ical4
这是我的测试助手: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpa
我开始学习Hibernate,出现这样的错误: exception javax.servlet.ServletException: Servlet execution threw an excepti
我是android游戏开发人员的新手,但经过几个月的工作,我终于在ue4中完成了游戏的制作。 但是,当将其上传到Google Play的Alpha轨道上,然后尝试启动该应用程序时,它会崩溃。 错误本身
最近我们在 AS 3.0.1 中注意到了这些警告: Error:WARNING in butterknife.Unbinder.:()V: defining a static interface me
我正在创建一个应用程序,但出现如下所示的错误。 我正在使用 Tomcat 6.0 和 Spring 3.0。 SEVERE: Servlet.service() for servlet jsp thr
我正在使用 Httpclient-4.5.2.jar 和 httpcore-4.4.4.jar HttpClient 组件,但出现以下错误。 Exception in thread "main" ja
我的请求URL中有字符[和],项目部署在Tomcat8.5.33上。当我发布请求时发生了一些异常。 20-Sep-2018 10:55:36.494 WARNING [http-nio-8075-ex
我成功使用了我编写的 Java 命令行程序使用 Apache POI 文件读取 MicrosoftWord (.docx) 文件并邮寄。我希望将其打包为可执行 jar。 我正在创建这个通过获取我的应用
我是一名优秀的程序员,十分优秀!