RFR: 8337838: Remove unused methods from ChronoLocalDateImpl

Stephen Colebourne scolebourne at openjdk.org
Wed Aug 7 08:59:32 UTC 2024


On Fri, 19 Jul 2024 09:52:50 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> A few methods in `java.time.chrono.ChronoLocalDateImpl` are unused and could be removed:
> 1. plusWeeks(long)
> 2. minusYears(long)
> 3. minusMonths(long)
> 4. minusWeeks(long)
> 5. minusDays(long)
> 
> Tested `test/jdk/java/time` on Linux x64 release

I believe the rest of the methods are OK to remove given the current design

src/java.base/share/classes/java/time/chrono/ChronoLocalDateImpl.java line 276:

> 274:      * @throws DateTimeException if the result exceeds the supported date range
> 275:      */
> 276:     D plusWeeks(long weeksToAdd) {

Rather than removing it, this method should in fact be called from `plus(long amountToAdd, TemporalUnit unit)` to give subclasses the chance to override the 7 day behaviour. 

(Sure, this is an internal class, and there is no implementation that needs to do that, but it is how the class was designed, and it would be clearer to fix tha current mistaken setup)

-------------

PR Review: https://git.openjdk.org/jdk/pull/20250#pullrequestreview-2223469992
PR Review Comment: https://git.openjdk.org/jdk/pull/20250#discussion_r1706638887


More information about the core-libs-dev mailing list