Can we deprecate Path.endsWith(String)?

Brian Burkhalter brian.burkhalter at oracle.com
Thu Sep 18 18:08:51 UTC 2025


On Sep 17, 2025, at 8:24 AM, Pavel Rappo <pavel.rappo at gmail.com> wrote:

FWIW, I too have fallen into this trap, and I did that even more than
once. When my brain sees Path.endsWith(String), it somehow silently
assumes that its semantic is that of String.endsWith(String).

Of course, it isn't. What's worse, I learn about my mistake at
runtime. But not because of an exception, no; I learn about it by
getting unexpected results.

I have filed an issue to improve the specification of this method somehow:

https://bugs.openjdk.org/browse/JDK-8368007

There used to be a method that implemented the file extension thingy,
but the commit was backed out. If it makes its way back in one form or
another, it might help to avoid the trap:

One day I might evenutally attempt to push that boulder up the mountain again. Today is not that day.

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250918/e5a7005c/attachment.htm>


More information about the core-libs-dev mailing list