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

Print this page

        

@@ -24,10 +24,12 @@
  */
 
 package java.lang;
 
 import java.lang.annotation.Native;
+import java.lang.invoke.Constable;
+import java.lang.invoke.MethodHandles;
 import java.util.Objects;
 import jdk.internal.HotSpotIntrinsicCandidate;
 import jdk.internal.misc.VM;
 
 import static java.lang.String.COMPACT_STRINGS;

@@ -54,11 +56,11 @@
  * @author  Arthur van Hoff
  * @author  Josh Bloch
  * @author  Joseph D. Darcy
  * @since 1.0
  */
-public final class Integer extends Number implements Comparable<Integer> {
+public final class Integer extends Number implements Comparable<Integer>, Constable<Integer> {
     /**
      * A constant holding the minimum value an {@code int} can
      * have, -2<sup>31</sup>.
      */
     @Native public static final int   MIN_VALUE = 0x80000000;

@@ -1864,8 +1866,13 @@
      */
     public static int min(int a, int b) {
         return Math.min(a, b);
     }
 
+    @Override
+    public Integer resolveConstant(MethodHandles.Lookup lookup) {
+        return this;
+    }
+
     /** use serialVersionUID from JDK 1.0.2 for interoperability */
     @Native private static final long serialVersionUID = 1360826667806852920L;
 }