Java – volatile in method signature?

See English answers > why make a method volatile in Java? 7

class A
{   
    protected A clone() throws CloneNotSupportedException
    {
        return (A) super.clone();       
    }
}

When I pass' show my code Com 'when decoding its bytecode, it shows me the following code:

class A
{

    A()
    {
    }

    protected A clone()
    throws clonenotsupportedexception
    {
        return (A)super.clone();
    }

    protected volatile object clone()
    throws clonenotsupportedexception
    {
        return clone();
    }
}

In the second 'clone' method, what does it mean that the return type of the method is volatile? (this code is compiled by eclipse's default JDK 1.6 compiler)

Solution

The modifier masks for fields and methods are similar but not identical The decompiler is most likely to use the toString method here

http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/reflect/Modifier.java

But what it doesn't do is process all the bits

// 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

It cannot handle bits that can represent the synthesis and bridging of compiler generated code

If volatile means anything here, it might mean not to delete the method even if it doesn't do anything

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>