--- a/src/java.base/share/classes/java/lang/Float.java Sat Dec 08 18:52:57 2018 -0500
+++ b/src/java.base/share/classes/java/lang/Float.java Sun Dec 09 12:36:24 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,11 @@
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;
@@ -45,7 +50,8 @@
* @author Joseph D. Darcy
* @since 1.0
*/
-public final class Float extends Number implements Comparable<Float> {
+public final class Float extends Number
+ implements Comparable<Float>, Constable, ConstantDesc {
/**
* A constant holding the positive infinity of type
* {@code float}. It is equal to the value returned by
@@ -982,6 +988,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 Float} instance
+ * @since 12
+ */
+ @Override
+ public Optional<Float> 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 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;
}