< prev index next >

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

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

*** 24,34 **** --- 24,39 ---- */ package java.lang; import java.lang.annotation.Native; + import java.lang.invoke.MethodHandles; + import java.lang.constant.Constable; + import java.lang.constant.ConstantDesc; import java.util.Objects; + import java.util.Optional; + import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.VM; import static java.lang.String.COMPACT_STRINGS; import static java.lang.String.LATIN1;
*** 54,64 **** * @author Arthur van Hoff * @author Josh Bloch * @author Joseph D. Darcy * @since 1.0 */ ! public final class Integer extends Number implements Comparable<Integer> { /** * A constant holding the minimum value an {@code int} can * have, -2<sup>31</sup>. */ @Native public static final int MIN_VALUE = 0x80000000; --- 59,70 ---- * @author Arthur van Hoff * @author Josh Bloch * @author Joseph D. Darcy * @since 1.0 */ ! public final class Integer extends Number ! implements Comparable<Integer>, ConstantDesc, Constable { /** * A constant holding the minimum value an {@code int} can * have, -2<sup>31</sup>. */ @Native public static final int MIN_VALUE = 0x80000000;
*** 1829,1836 **** --- 1835,1867 ---- */ public static int min(int a, int 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 Integer} instance + * @since 12 + */ + @Override + public Optional<Integer> 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 Integer} instance + * @since 12 + */ + @Override + public Integer resolveConstantDesc(MethodHandles.Lookup lookup) { + return this; + } + /** use serialVersionUID from JDK 1.0.2 for interoperability */ @Native private static final long serialVersionUID = 1360826667806852920L; }
< prev index next >