1

我想知道 JVM 上的“bridge”关键字除了将方法标记为特殊之外是否有任何具体目的?我问的是与“抽象”或“受保护”相反的问题,这实际上会直接影响其余代码的解释或功能方式。

谢谢

4

1 回答 1

4

bridge不是关键字。它用于标记用于实现泛型和协变返回类型的合成方法。它对性能没有太大影响,甚至不会在运行时出现在调用堆栈中。

来自http://www.docjar.com/html/api/java/lang/reflect/Modifier.java.html

/**
 * The {@code int} value representing the {@code volatile}
 * modifier.
 */
public static final int VOLATILE         = 0x00000040;

// 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
static final int BRIDGE    = 0x00000040;
于 2012-07-04T17:46:53.887 回答