Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8300869: Make use of the Double.toString(double) algorithm in java.util.Formatter #12259

Closed
wants to merge 8 commits into from

Conversation

rgiulietti
Copy link
Contributor

@rgiulietti rgiulietti commented Jan 27, 2023

Align double and float decimal conversions in java.util.Formatter with the algorithm used in Double.toString(double).


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8301387 to be approved

Issues

  • JDK-8300869: Make use of the Double.toString(double) algorithm in java.util.Formatter
  • JDK-8301387: Align the specification of java.util.Formatter float conversions to the implementation (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12259/head:pull/12259
$ git checkout pull/12259

Update a local copy of the PR:
$ git checkout pull/12259
$ git pull https://git.openjdk.org/jdk pull/12259/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12259

View PR using the GUI difftool:
$ git pr show -t 12259

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12259.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 27, 2023

👋 Welcome back rgiulietti! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 27, 2023
@openjdk
Copy link

openjdk bot commented Jan 27, 2023

@rgiulietti The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Jan 27, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 27, 2023

@rgiulietti
Copy link
Contributor Author

The specification in Formatter explicitly refers to the outcome of Double.toString(double). However, it currently uses another implementation for the floating-point to decimal conversion, which might end up in rare, slightly different outcomes than the ones described in the specification.

This fixes the discrepancy between specification and implementation in Formatter.

Class jdk.internal.math.FormattedFPDecimal replaces jdk.internal.math.FormattedFloatingDecimal, which is no longer needed.

…il.Formatter

Added tests for known differences between current and new behavior.
@rgiulietti
Copy link
Contributor Author

Added tests for known differences.

Most of the modified files are generated automatically by a script that, somewhat questionably, renews the copyright year in some of the files for no apparent reason.

@@ -1,5 +1,5 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks line the non-float/double test classes are unchanged, they could be dropped from the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only changes I made myself in the test files are in Basic-X.java.template (including the copyright year). The other files were generated by a script, which happens to also change the copyright year for otherwise unmodified files.

If you agree, I'll happily remove the trivial copyright year changes and only retain those files containing more substantial modifications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me, I figured it was the script that changed the copyright and otherwise generated the same as before. tnx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise untouched files are now reverted back with previous copyright year

@jddarcy
Copy link
Member

jddarcy commented Jan 30, 2023

I've spoken to @rgiulietti about this PR; since there behavioral changes of possible interest, I'm requesting a CSR to cover those changes.

@jddarcy
Copy link
Member

jddarcy commented Jan 30, 2023

/csr needed

@@ -931,6 +931,16 @@ public class Basic$Type$ extends Basic {
test("%3.0e", "1e+07", 10000000.00);
test("%3.0e", "1e+08", 100000000.00);

//---------------------------------------------------------------------
// %e - adoption of Double.toString(double) algorithm (8300869)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we generally don't use the bug ids in comments like this, usually at most relying on a bug listed in the test "@bug" line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug id was added there because I'm not sure there's a way to add the @bug line to Basic-X.java.template`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see; it might suffice in this case to rely on the bug information in the SCM history, but I don't have a strong opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific *.java.template case, I think that the bug id in the comment somehow replaces the lack of the @bug line.
But I have no problems in removing it if there are stronger opinions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @bug tag is in BasicTestLauncher which is where 8300869 should likely go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bplb for pointing to the right place.
Done

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jan 30, 2023
@openjdk
Copy link

openjdk bot commented Jan 30, 2023

@jddarcy this pull request will not be integrated until the CSR request JDK-8301387 for issue JDK-8300869 has been approved.

@rgiulietti
Copy link
Contributor Author

The CSR has been added.

It covers both a behavioral change due to the implementation change in this PR, and a specification change to align it with the implementation (current and proposed), resolving a long standing mismatch in the e, f, and g conversions on float values.


package jdk.internal.math;

public final class FormattedFPDecimal {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a short explanation of what this class is used for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Feb 1, 2023
@openjdk
Copy link

openjdk bot commented Feb 1, 2023

@rgiulietti This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8300869: Make use of the Double.toString(double) algorithm in java.util.Formatter

Reviewed-by: darcy, naoto

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 203 new commits pushed to the master branch:

  • c647ae6: 8301149: Parallel: Refactor MutableNUMASpace::update_layout
  • de57733: 8301644: com/sun/jdi/JdbStopThreadTest.java fails after JDK-8300811
  • 930ec00: 8301636: Minor cleanup in CommentHelper and DocPretty
  • 725d57b: 8301659: Resolve initialization reordering issues on Windows for libawt and libsaproc
  • 2d50c7d: 8298979: Remove duplicated serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java
  • 59b7fb1: 8300273: [IR framework] Handle message instead of bailing out
  • 5b1584b: 8298880: VectorLogicalOpIdentityTest.java IR test incorrectly use avx3 instead of avx512
  • 21c1afb: 8301612: OopLoadProxy constructor should be explicit
  • 03b23a1: 8301367: Add exception handler method to the BaseLdapServer
  • 7b6ac41: 8286876: NMT.test_unaliged_block_address_vm_assert fails if using clang toolchain
  • ... and 193 more: https://git.openjdk.org/jdk/compare/f307e8c667895c302e916124751456a5443353ce...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 1, 2023
@rgiulietti
Copy link
Contributor Author

Anyone from i18n wants to review before integration?

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skimmed through the changes, and see no problem wrt the i18n area.

@rgiulietti
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 2, 2023

Going to push as commit f696785.
Since your change was applied there have been 204 commits pushed to the master branch:

  • cf6b9eb: 8301637: ThreadLocalRandom.current().doubles().parallel() contention
  • c647ae6: 8301149: Parallel: Refactor MutableNUMASpace::update_layout
  • de57733: 8301644: com/sun/jdi/JdbStopThreadTest.java fails after JDK-8300811
  • 930ec00: 8301636: Minor cleanup in CommentHelper and DocPretty
  • 725d57b: 8301659: Resolve initialization reordering issues on Windows for libawt and libsaproc
  • 2d50c7d: 8298979: Remove duplicated serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java
  • 59b7fb1: 8300273: [IR framework] Handle message instead of bailing out
  • 5b1584b: 8298880: VectorLogicalOpIdentityTest.java IR test incorrectly use avx3 instead of avx512
  • 21c1afb: 8301612: OopLoadProxy constructor should be explicit
  • 03b23a1: 8301367: Add exception handler method to the BaseLdapServer
  • ... and 194 more: https://git.openjdk.org/jdk/compare/f307e8c667895c302e916124751456a5443353ce...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 2, 2023
@openjdk openjdk bot closed this Feb 2, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 2, 2023
@openjdk
Copy link

openjdk bot commented Feb 2, 2023

@rgiulietti Pushed as commit f696785.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@rgiulietti rgiulietti deleted the JDK-8300869 branch February 3, 2023 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants