Can we deprecate Path.endsWith(String)?

Anthony Vanelverdinghe anthonyv.be at outlook.com
Sun Jan 11 19:06:22 UTC 2026


I dissent. (Apparently my previous message wasn't clear.)

The right order of things is to first introduce a file extension API. 
Then see if there's still complaints about `Path::endsWith(String)`. And 
only then, if there are, consider taking action.

In my previous message I've already explained how these methods add 
real, tangible value and actually are intuitive.
(Again, ask developers to guess how `A::foo(B)` behaves, given that both 
`A::foo(A)` and `B::foo(B)` exist, and a large majority of them will 
intuitively guess it converts its `b` argument to an instance of `A` and 
passes it on to `A::foo(A)`. And their intuition would be correct in the 
case of `Path::endsWith(String)`. That being said, I'll be the first to 
admit that I've also made the mistake of attempting to use 
`Path::endsWith(String)` to test the file extension.)

In hindsight, maybe `endsWithNames(String)` would've been a better 
choice, but hindsight is 20/20.

Deprecating these methods now is premature. And deprecating them without 
replacement methods would result in way more complaints than there have 
ever been about `endsWith(String)`.

Anthony

On 1/11/2026 12:19 AM, David Alayachew wrote:
> Of course.
>
> I see lots of approvals and not really any dissenters. Are we waiting 
> for more responses? Or is there anything we can do to kick start this?
>
> On Fri, Jan 9, 2026, 10:22 PM Brian Burkhalter 
> <brian.burkhalter at oracle.com> wrote:
>
>     Thanks for the corroboration.
>
>>     On Jan 8, 2026, at 1:50 PM, David Alayachew
>>     <davidalayachew at gmail.com> wrote:
>>
>>     Thanks for reviving this.
>>
>>     I am perfectly happy with the idea of deprecating the
>>     Path.{start,ends}With(String), and then only add the file
>>     extension method. Originally, I didn't know that new method was
>>     on the table, so I suggested a rename. But the file extension api
>>     feels like the superior solution.
>>
>>     10 times out of 10, if I am calling endsWith, the only time I am
>>     not looking for "whole" path elements is when I am looking for a
>>     file extension. In every other instance, the api does exactly
>>     what I expect and want. And plus, something like looking for a
>>     file extension is better off being explicit.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20260111/273471e4/attachment-0001.htm>


More information about the core-libs-dev mailing list