JDK-7039369 : Limit range of strictfp in FloatingDecimal
Type:Bug
Component:core-libs
Sub-Component:java.lang
Affected Version:7
Priority:P3
Status:Closed
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2011-04-25
Updated:2011-06-16
Resolved:2011-06-16
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
While correct, the strictfp modifier added at a class-level in 7021568 can potentially cause performance degradations. Correctness can be maintained while reducing the range of the modfier.
Comments
PUBLIC COMMENTS
See
http://hg.openjdk.java.net/jdk7/tl/jdk/rev/147da2c8b749
26-04-2011
SUGGESTED FIX
# HG changeset patch
# User darcy
# Date 1303839306 25200
# Node ID 147da2c8b7497d2f8b29f1dc4226d7a67fe3aa39
# Parent 8b36b1c4bb7fa01fa33ab8c2e0414112e217903e
7039369: Limit range of strictfp in FloatingDecimal
Summary: Additional reviews by ###@###.###
Reviewed-by: alanb
--- a/src/share/classes/sun/misc/FloatingDecimal.java Tue Apr 26 12:49:34 2011 +0200
+++ b/src/share/classes/sun/misc/FloatingDecimal.java Tue Apr 26 10:35:06 2011 -0700
@@ -30,7 +30,7 @@ import sun.misc.FloatConsts;
import sun.misc.FloatConsts;
import java.util.regex.*;
-public strictfp class FloatingDecimal{
+public class FloatingDecimal{
boolean isExceptional;
boolean isNegative;
int decExponent;
@@ -239,8 +239,7 @@ public strictfp class FloatingDecimal{
* More difficult if subtracting and the argument
* is a normalized a power of 2, as the ULP changes at these points.
*/
- private static double
- ulp( double dval, boolean subtracting ){
+ private static double ulp( double dval, boolean subtracting ){
long lbits = Double.doubleToLongBits( dval ) & ~signMask;
int binexp = (int)(lbits >>> expShift);
double ulpval;
@@ -1251,8 +1250,7 @@ public strictfp class FloatingDecimal{
* for a single-precision float.
*/
- public double
- doubleValue(){
+ public strictfp double doubleValue(){
int kDigits = Math.min( nDigits, maxDecimalDigits+1 );
long lValue;
double dValue;
@@ -1611,8 +1609,7 @@ public strictfp class FloatingDecimal{
* ( because of the preference to a zero low-order bit ).
*/
- public float
- floatValue(){
+ public strictfp float floatValue(){
int kDigits = Math.min( nDigits, singleMaxDecimalDigits+1 );
int iValue;
float fValue;
--- a/src/share/classes/sun/misc/FormattedFloatingDecimal.java Tue Apr 26 12:49:34 2011 +0200
+++ b/src/share/classes/sun/misc/FormattedFloatingDecimal.java Tue Apr 26 10:35:06 2011 -0700
@@ -30,7 +30,7 @@ import sun.misc.FloatConsts;
import sun.misc.FloatConsts;
import java.util.regex.*;
-public strictfp class FormattedFloatingDecimal{
+public class FormattedFloatingDecimal{
boolean isExceptional;
boolean isNegative;
int decExponent; // value set at construction, then immutable
@@ -247,8 +247,7 @@ public strictfp class FormattedFloatingD
* More difficult if subtracting and the argument
* is a normalized a power of 2, as the ULP changes at these points.
*/
- private static double
- ulp( double dval, boolean subtracting ){
+ private static double ulp( double dval, boolean subtracting ){
long lbits = Double.doubleToLongBits( dval ) & ~signMask;
int binexp = (int)(lbits >>> expShift);
double ulpval;
@@ -1157,8 +1156,7 @@ public strictfp class FormattedFloatingD
* for a single-precision float.
*/
- public double
- doubleValue(){
+ public strictfp double doubleValue(){
int kDigits = Math.min( nDigits, maxDecimalDigits+1 );
long lValue;
double dValue;
@@ -1517,8 +1515,7 @@ public strictfp class FormattedFloatingD
* ( because of the preference to a zero low-order bit ).
*/
- public float
- floatValue(){
+ public strictfp float floatValue(){
int kDigits = Math.min( nDigits, singleMaxDecimalDigits+1 );
int iValue;
float fValue;
--- a/test/java/lang/Double/ParseDouble.java Tue Apr 26 12:49:34 2011 +0200
+++ b/test/java/lang/Double/ParseDouble.java Tue Apr 26 10:35:06 2011 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4160406 4705734 4707389 4826774 4895911 4421494 7021568
+ * @bug 4160406 4705734 4707389 4826774 4895911 4421494 7021568 7039369
* @summary Test for Double.parseDouble method and acceptance regex
*/