src/java.base/share/classes/java/lang/Long.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.math.*;
 import java.util.Objects;
 import jdk.internal.HotSpotIntrinsicCandidate;
 
 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 Long extends Number implements Comparable<Long> {
+public final class Long extends Number implements Comparable<Long>, Constable<Long> {
     /**
      * A constant holding the minimum value a {@code long} can
      * have, -2<sup>63</sup>.
      */
     @Native public static final long MIN_VALUE = 0x8000000000000000L;

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