mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8263102: Expand documention of Method.isBridge
Reviewed-by: smarks
This commit is contained in:
parent
d0c1aec202
commit
67ea3bd6a4
3 changed files with 42 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -511,6 +511,7 @@ public final class Constructor<T> extends Executable {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @jls 13.1 The Form of a Binary
|
* @jls 13.1 The Form of a Binary
|
||||||
|
* @jvms 4.6 Methods
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -518,6 +518,7 @@ public abstract class Executable extends AccessibleObject
|
||||||
* construct as defined by
|
* construct as defined by
|
||||||
* <cite>The Java Language Specification</cite>.
|
* <cite>The Java Language Specification</cite>.
|
||||||
* @jls 13.1 The Form of a Binary
|
* @jls 13.1 The Form of a Binary
|
||||||
|
* @jvms 4.6 Methods
|
||||||
*/
|
*/
|
||||||
public boolean isSynthetic() {
|
public boolean isSynthetic() {
|
||||||
return Modifier.isSynthetic(getModifiers());
|
return Modifier.isSynthetic(getModifiers());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -567,12 +567,44 @@ public final class Method extends Executable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if this method is a bridge
|
* {@return {@code true} if this method is a bridge
|
||||||
* method; returns {@code false} otherwise.
|
* method; returns {@code false} otherwise}
|
||||||
*
|
*
|
||||||
* @return true if and only if this method is a bridge
|
* @apiNote
|
||||||
* method as defined by the Java Language Specification.
|
* A bridge method is a {@linkplain isSynthetic synthetic} method
|
||||||
|
* created by a Java compiler alongside a method originating from
|
||||||
|
* the source code. Bridge methods are used by Java compilers in
|
||||||
|
* various circumstances to span differences in Java programming
|
||||||
|
* language semantics and JVM semantics.
|
||||||
|
*
|
||||||
|
* <p>One example use of bridge methods is as a technique for a
|
||||||
|
* Java compiler to support <i>covariant overrides</i>, where a
|
||||||
|
* subclass overrides a method and gives the new method a more
|
||||||
|
* specific return type than the method in the superclass. While
|
||||||
|
* the Java language specification forbids a class declaring two
|
||||||
|
* methods with the same parameter types but a different return
|
||||||
|
* type, the virtual machine does not. A common case where
|
||||||
|
* covariant overrides are used is for a {@link
|
||||||
|
* java.lang.Cloneable Cloneable} class where the {@link
|
||||||
|
* Object#clone() clone} method inherited from {@code
|
||||||
|
* java.lang.Object} is overridden and declared to return the type
|
||||||
|
* of the class. For example, {@code Object} declares
|
||||||
|
* <pre>{@code protected Object clone() throws CloneNotSupportedException {...}}</pre>
|
||||||
|
* and {@code EnumSet<E>} declares its language-level {@linkplain
|
||||||
|
* java.util.EnumSet#clone() covariant override}
|
||||||
|
* <pre>{@code public EnumSet<E> clone() {...}}</pre>
|
||||||
|
* If this technique was being used, the resulting class file for
|
||||||
|
* {@code EnumSet} would have two {@code clone} methods, one
|
||||||
|
* returning {@code EnumSet<E>} and the second a bridge method
|
||||||
|
* returning {@code Object}. The bridge method is a JVM-level
|
||||||
|
* override of {@code Object.clone()}. The body of the {@code
|
||||||
|
* clone} bridge method calls its non-bridge counterpart and
|
||||||
|
* returns its result.
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
|
*
|
||||||
|
* @jls 8.4.8.3 Requirements in Overriding and Hiding
|
||||||
|
* @jls 15.12.4.5 Create Frame, Synchronize, Transfer Control
|
||||||
|
* @jvms 4.6 Methods
|
||||||
*/
|
*/
|
||||||
public boolean isBridge() {
|
public boolean isBridge() {
|
||||||
return (getModifiers() & Modifier.BRIDGE) != 0;
|
return (getModifiers() & Modifier.BRIDGE) != 0;
|
||||||
|
@ -590,6 +622,7 @@ public final class Method extends Executable {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @jls 13.1 The Form of a Binary
|
* @jls 13.1 The Form of a Binary
|
||||||
|
* @jvms 4.6 Methods
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue