参见英文答案 >
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方法
但它没有做的是处理所有的比特
// 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在这里意味着任何东西,它可能意味着即使它没有做任何事情也不要删除该方法.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。