src/java.base/share/classes/java/lang/Long.java
changeset 52914 4fa75d8ad418
parent 52626 991fe09c698c
child 53018 8bf9268df0e2
--- a/src/java.base/share/classes/java/lang/Long.java	Sat Dec 08 18:52:57 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Long.java	Sun Dec 09 12:36:24 2018 -0500
@@ -26,8 +26,13 @@
 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.math.*;
 import java.util.Objects;
+import java.util.Optional;
+
 import jdk.internal.HotSpotIntrinsicCandidate;
 import jdk.internal.misc.VM;
 
@@ -57,7 +62,8 @@
  * @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, ConstantDesc {
     /**
      * A constant holding the minimum value a {@code long} can
      * have, -2<sup>63</sup>.
@@ -1960,6 +1966,31 @@
         return Math.min(a, b);
     }
 
+    /**
+     * Returns a nominal descriptor for this instance, which is the instance
+     * itself.
+     *
+     * @return an {@link Optional} describing the {@linkplain Long} instance
+     * @since 12
+     */
+    @Override
+    public Optional<Long> describeConstable() {
+        return Optional.of(this);
+    }
+
+    /**
+     * Resolves this instance as a {@link ConstantDesc}, the result of which is
+     * the instance itself.
+     *
+     * @param lookup ignored
+     * @return the {@linkplain Long} instance
+     * @since 12
+     */
+    @Override
+    public Long resolveConstantDesc(MethodHandles.Lookup lookup) {
+        return this;
+    }
+
     /** use serialVersionUID from JDK 1.0.2 for interoperability */
     @Native private static final long serialVersionUID = 4290774380558885855L;
 }