Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8289504

BigDecimal movePointLeft() and movePointRight() do not follow their API spec

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 20
    • core-libs
    • None
    • behavioral
    • minimal
    • Consumers of the API points that rely on the methods to always return the target of the invocations when the argument is 0 should be updated.
    • Java API
    • Implementation

    Description

      Summary

      JDK-8183912 introduced an optimization for the cases BigDecimal.movePoint[Left|Right](0) to always return this. While the spec never claims to return this, it might be the case that consumers incautiously rely on such behavior.

      Problem

      This behavior is at odds with the methods' own spec, which prescribes a specific scale for the result, even when the argument is 0. In particular, when the scale is negative, the methods must return an instance which is not equals() to this (even less so, identical ==).

      Solution

      The proposed changes re-align the behavior with the spec.

      Specification

      The specification is not changed in any way. It's only an implementation change, although the change is behaviorally observable. Consumers of these API points that rely on the methods to always return this when the argument is 0 should be updated.

      Attachments

        Issue Links

          Activity

            People

              rgiulietti Raffaello Giulietti
              webbuggrp Webbug Group
              Joe Darcy
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: