java – 方法签名中的’volatile’?
发布时间:2020-12-15 00:04:39 所属栏目:Java 来源:网络整理
导读:参见英文答案 Why make a method volatile in java?7个 这个很奇怪.我有以下代码: class A{ protected A clone() throws CloneNotSupportedException { return (A) super.clone(); }} 当我通过’showmycode.com’解码它的字节码时,它向我展示了以下代码: c
参见英文答案 >
Why make a method volatile in java?7个
这个很奇怪.我有以下代码: class A { protected A clone() throws CloneNotSupportedException { return (A) super.clone(); } } 当我通过’showmycode.com’解码它的字节码时,它向我展示了以下代码: class A { A() { } protected A clone() throws clonenotsupportedexception { return (A)super.clone(); } protected volatile object clone() throws clonenotsupportedexception { return clone(); } } 在第二个’clone’方法中,方法返回类型是volatile的意思是什么? (此代码是通过Eclipse的默认JDK 1.6编译器编译的). 解决方法
字段和方法的修饰符掩码类似但不完全相同.反编译器最有可能在这里使用toString方法
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/reflect/Modifier.java 但它没有做的是处理所有的比特 // Bits not (yet) exposed in the public API either because they // have different meanings for fields and methods and there is no // way to distinguish between the two in this class,or because // they are not Java programming language keywords 它不能处理的是可以表示编译器生成的代码的合成和桥接的位. 如果volatile在这里意味着任何东西,它可能意味着即使它没有做任何事情也不要删除该方法. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |