JDK-8149075 : New method: public static Double.toES6String(double)
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 8u72
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-02-04
  • Updated: 2021-11-16
Description
A DESCRIPTION OF THE REQUEST :
The most recent ECMAScript specification details how the "Number" data type should be formatted. Unfortunately they offer two alternatives.  The more advance alternative has been selected by Google for Chrome, as well as by Apple and Mozilla for Safari and Firefox respectively.

Java does not natively support any of these alternatives.

JUSTIFICATION :
The net effect of implementing this feature is that you can create normalized versions of JavaScript/JSON objects that can securely traverse through different systems even if they carry a digital signature.

An example of such a use:
https://cyberphone.github.io/openkeystore/resources/docs/jcs.html#ECMAScript_Compatibility_Mode

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ES6 formatted doubles
ACTUAL -
A non-compatible format.

---------- BEGIN SOURCE ----------
Here you have 10 million values to test with:
http://webpki.org/ietf/es6testfile.txt
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
There is open source code that does this conversion


Comments
If this method were to be added to the platform, I think it would be better added to somewhere dealing with JavaScript/JSON rather than directly on Double.
16-11-2021

http://webpki.org/ietf/es6testfile.txt returns HTTP 404. GZ version of test file is now available at https://github.com/cyberphone/json-canonicalization/releases/tag/es6testfile . Details regarding the generation of test file is at https://github.com/cyberphone/json-canonicalization/tree/master/testdata#es6-numbers .
16-11-2021