< prev index next >

src/java.base/share/classes/java/lang/Float.java

Print this page
rev 52786 : 8210031: implementation for JVM Constants API

*** 23,32 **** --- 23,37 ---- * questions. */ package java.lang; + import java.lang.invoke.MethodHandles; + import java.lang.constant.Constable; + import java.lang.constant.ConstantDesc; + import java.util.Optional; + import jdk.internal.math.FloatingDecimal; import jdk.internal.HotSpotIntrinsicCandidate; /** * The {@code Float} class wraps a value of primitive type
*** 43,53 **** * @author Lee Boynton * @author Arthur van Hoff * @author Joseph D. Darcy * @since 1.0 */ ! public final class Float extends Number implements Comparable<Float> { /** * A constant holding the positive infinity of type * {@code float}. It is equal to the value returned by * {@code Float.intBitsToFloat(0x7f800000)}. */ --- 48,59 ---- * @author Lee Boynton * @author Arthur van Hoff * @author Joseph D. Darcy * @since 1.0 */ ! public final class Float extends Number ! implements Comparable<Float>, ConstantDesc, Constable { /** * A constant holding the positive infinity of type * {@code float}. It is equal to the value returned by * {@code Float.intBitsToFloat(0x7f800000)}. */
*** 980,987 **** --- 986,1018 ---- */ public static float min(float a, float b) { return Math.min(a, b); } + /** + * Returns a nominal descriptor for this instance, which is the instance + * itself. + * + * @return an {@link Optional} describing the {@linkplain Float} instance + * @since 12 + */ + @Override + public Optional<Float> describeConstable() { + return Optional.of(this); + } + + /** + * Resolve this instance as a {@link ConstantDesc}, the result of which is + * the instance itself. + * + * @param lookup ignored + * @return the {@linkplain Float} instance + * @since 12 + */ + @Override + public Float resolveConstantDesc(MethodHandles.Lookup lookup) { + return this; + } + /** use serialVersionUID from JDK 1.0.2 for interoperability */ private static final long serialVersionUID = -2671257302660747028L; }
< prev index next >