JDK-6799689 : Make sun.misc.FloatingDecimal.hexFloatPattern static field initialized lazily
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.math
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-01-30
  • Updated: 2010-05-10
  • Resolved: 2009-03-13
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.

To download the current JDK release, click here.
JDK 6 JDK 7
6u14Fixed 7 b51Fixed
Related Reports
Relates :  
Description
sun.misc.FloatingDecimal has a static field of java.util.Pattern type that loads and initializes the regex classes.  This static field is used by parseHexString method to parse a hexadecimal floating-point string and should be initialized lazily to avoid regex classes to be pulled until it's really needed.

Comments
EVALUATION Will fix this in JDK 7
30-01-2009

SUGGESTED FIX --- a/src/share/classes/sun/misc/FloatingDecimal.java +++ b/src/share/classes/sun/misc/FloatingDecimal.java @@ -1867,10 +1867,16 @@ public class FloatingDecimal{ * Grammar is compatible with hexadecimal floating-point constants * described in section 6.4.4.2 of the C99 specification. */ - private static Pattern hexFloatPattern = Pattern.compile( + private static Pattern hexFloatPattern = null; + private static synchronized Pattern getHexFloatPattern() { + if (hexFloatPattern == null) { + hexFloatPattern = Pattern.compile( //1 234 56 7 8 9 "([-+])?0[xX](((\\p{XDigit}+)\\.?)|((\\p{XDigit}*)\\.(\\p{XDigit}+)))[pP]([-+])?(\\p{Digit}+)[fFdD]?" ); + } + return hexFloatPattern; + } /* * Convert string s to a suitable floating decimal; uses the @@ -1880,7 +1886,7 @@ public class FloatingDecimal{ static FloatingDecimal parseHexString(String s) { // Verify string is a member of the hexadecimal floating-point // string language. - Matcher m = hexFloatPattern.matcher(s); + Matcher m = getHexFloatPattern().matcher(s); boolean validInput = m.matches();
30-01-2009