方法签名中的'volatile'? [英] 'volatile' in method signature?

查看:101
本文介绍了方法签名中的'volatile'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个很奇怪。我有以下代码:

This one is weird. I have the following code:

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

当我通过'showmycode解码其字节码时。 com',它向我展示了以下代码:

when I de-compiled its bytecode through 'showmycode.com', it showed me the following code:

class A
{

    A()
    {
    }

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

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

方法返回类型是什么意思在第二个'克隆'方法中是不稳定的? (此代码是通过Eclipse的默认JDK 1.6编译器编译的。)

What does it mean for a method return type to be volatile in the second 'clone' method? (This code was compiled through Eclipse's default JDK 1.6 compiler).

推荐答案

字段和方法的修饰符掩码类似但不完全相同相同。反编译器很可能在这里使用 toString 方法

The modifier mask for fields and methods is similar but not exactly the same. The decompiler is most likely using 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 handle all 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

它不能处理的是可能意味着合成和<$ c的位$ c> bridge ,用于标识编译器生成的代码。

What its doesn't handle is the bits which can mean synthetic and bridge which identify compiler generated code.

如果 volatile 表示任何内容所有这里,它可能意味着不删除方法,即使它没有什么。

If volatile means anything at all here, it could mean don't remove the method even though it doesn't do anything.

这篇关于方法签名中的'volatile'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆