mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8210031: implementation for JVM Constants API
Co-authored-by: Brian Goetz <brian.goetz@oracle.com> Reviewed-by: jrose, mcimadamore, darcy, mchung, rriggs, dholmes, forax
This commit is contained in:
parent
b80d335354
commit
9846588b31
72 changed files with 6719 additions and 103 deletions
|
@ -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.math.DoubleConsts;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
|
@ -46,7 +51,8 @@ import jdk.internal.HotSpotIntrinsicCandidate;
|
|||
* @author Joseph D. Darcy
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class Double extends Number implements Comparable<Double> {
|
||||
public final class Double extends Number
|
||||
implements Comparable<Double>, Constable, ConstantDesc {
|
||||
/**
|
||||
* A constant holding the positive infinity of type
|
||||
* {@code double}. It is equal to the value returned by
|
||||
|
@ -1070,6 +1076,31 @@ public final class Double extends Number implements Comparable<Double> {
|
|||
return Math.min(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, which is the instance
|
||||
* itself.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Double} instance
|
||||
* @since 12
|
||||
*/
|
||||
@Override
|
||||
public Optional<Double> 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 Double} instance
|
||||
* @since 12
|
||||
*/
|
||||
@Override
|
||||
public Double resolveConstantDesc(MethodHandles.Lookup lookup) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** use serialVersionUID from JDK 1.0.2 for interoperability */
|
||||
private static final long serialVersionUID = -9172774392245257468L;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue