<!DOCTYPE html>
<!-- BaNnErBlUrFlE-BoDy-start -->
<!-- Preheader Text : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">
On Thu, 7 Mar 2024 22: 46: 06 GMT, Brian Burkhalter <bpb@ openjdk. org> wrote: >> Add to `java. nio. file. Path` a method `getExtension` to retrieve the `Path`'s extension, and companion methods `removeExtension` and `addExtension`. >
</div>
<!-- Preheader Text : END -->
<!-- Email Banner : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerStart</div>
<!--[if ((ie)|(mso))]>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 16px 0px 16px 0px; direction: ltr" ><tr><td>
<table border="0" cellspacing="0" cellpadding="0" style="padding: 0px 10px 5px 6px; width: 100%; border-radius:4px; border-top:4px solid #90a4ae;background-color:#D0D8DC;"><tr><td valign="top">
<table align="left" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 8px 4px 8px">
<tr><td style="color:#000000; font-family: 'Arial', sans-serif; font-weight:bold; font-size:14px; direction: ltr">
This Message Is From an External Sender
</td></tr>
<tr><td style="color:#000000; font-weight:normal; font-family: 'Arial', sans-serif; font-size:12px; direction: ltr">
This message came from outside your organization.
</td></tr>
</table>
<![if ie]><br clear="all"><![endif]>
<table align="right" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 0px 4px 0px"><tr>
<td style="direction: ltr"> <a target="_blank" href="https://us-phishalarm-ewt.proofpoint.com/EWT/v1/ACWV5N9M2RV99hQ!Od21NyRAGgFitj1MuX_Yd67RwKjnGB7X_MvaihU_cBLbIjSDAux0cUIKYYiMM2o7ZSA4MTbHXMyqygf3fsh02ANYJqlkDhN88E1Ml-nMEUxyb-j7s6WQ6zCnMjaY3K5JYt1Ck9pMva-L9osNH2_hCDeHOBbwoho$" style="mso-padding-alt: 7.5px; padding: 7.5px; border-radius: 2px; border: 1.5px solid #666666; "><strong style="font-weight: normal; color: #000000; text-decoration: none; font-family: 'Arial', sans-serif; font-size:14px; line-height: 40px; "> Report Suspicious </strong></a> </td>
</tr></table>
</td></tr></table>
</td></tr></table>
<![endif]-->
<![if !((ie)|(mso))]>
<div dir="ltr" id="pfptBanner9e9qw3p" style="all: revert !important; display:block !important; text-align: left !important; margin:16px 0px 16px 0px !important; padding:8px 16px 8px 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: #D0D8DC !important; background-color: #D0D8DC; border-top: 4px solid #90a4ae !important; border-top: 4px solid #90a4ae;">
<div id="pfptBanner9e9qw3p" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
<div id="pfptBanner9e9qw3p" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-weight:bold !important; font-weight:bold; font-size:14px !important; line-height:18px !important; line-height:18px">
This Message Is From an External Sender
</div>
<div id="pfptBanner9e9qw3p" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-weight:normal; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size:12px !important; line-height:18px !important; line-height:18px; margin-top:2px !important;">
This message came from outside your organization.
</div>
</div>
<div id="pfptBanner9e9qw3p" style="all: unset !important; float: right !important; display: block !important; display: block; margin: 0px 0px 0px 16px !important; text-align: right !important; width: fit-content !important;">
<a id="pfptBanner9e9qw3p" href="https://us-phishalarm-ewt.proofpoint.com/EWT/v1/ACWV5N9M2RV99hQ!Od21NyRAGgFitj1MuX_Yd67RwKjnGB7X_MvaihU_cBLbIjSDAux0cUIKYYiMM2o7ZSA4MTbHXMyqygf3fsh02ANYJqlkDhN88E1Ml-nMEUxyb-j7s6WQ6zCnMjaY3K5JYt1Ck9pMva-L9osNH2_hCDeHOBbwoho$"
style="all: unset !important; display: inline-block !important; text-decoration: none">
<div class="pfptPrimaryButton9e9qw3p" style="display: inline-block !important; display: inline-block; visibility: visible !important; opacity: 1 !important; color: #000000 !important; color: #000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size: 14px !important; font-weight: normal !important; text-decoration: none !important; border-radius: 2px !important; padding: 7.5px 16px !important; margin: 3px 0 3px 16px !important; white-space: nowrap !important; width: fit-content !important;
border: 1px solid #666666">
Report Suspicious
</div>
</a>
</div>
<div style="clear: both !important; display: block !important; visibility: hidden !important; line-height: 0 !important; font-size: 0.01px !important; height: 0px"> </div>
</div>
<![endif]>
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerEnd</div>
<!-- Email Banner : END -->
<!-- BaNnErBlUrFlE-BoDy-end -->
<html>
<head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
#pfptBanner9e9qw3p { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #D0D8DC !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButton9e9qw3p:hover, .pfptPrimaryButton9e9qw3p:focus {
background-color: #b4c1c7 !important; }
.pfptPrimaryButton9e9qw3p:active {
background-color: #90a4ae !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
<meta charset="utf-8"></head><body><pre style="font-family: sans-serif; font-size: 100%; white-space: pre-wrap; word-wrap: break-word">On Thu, 7 Mar 2024 22:46:06 GMT, Brian Burkhalter <bpb@openjdk.org> wrote:
>> Add to `java.nio.file.Path` a method `getExtension` to retrieve the `Path`'s extension, and companion methods `removeExtension` and `addExtension`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8298318: corretions to commit 030a250aaf4c309d515507527932b233f210501e
1. What is the rationale for `Path.of("..mp3").getExtension()` being equal to `""`?
Of all the other languages' (*) and Java APIs (**) I've looked at, only Python specifies this peculiar behavior (Ruby also exhibits this behavior, but it's unspecified and thus unclear whether it does so by design). (Actually, since both Python and Ruby include the dot in the extension, the proposed API doesn't match *any* other API I've looked at.)
2. [`Files::isHidden`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#isHidden(java.nio.file.Path)) specifies:
> The exact definition of hidden is platform or provider dependent. On UNIX for example a file is considered to be hidden if its name begins with a period character ('.'). On Windows a file is considered hidden if the DOS hidden attribute is set.
Why can't `Path::getExtension` be platform or provider dependent as well and specify something as follows?
> The exact definition of extension is platform or provider dependent. On UNIX for example a leading dot marks a path as [hidden](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#isHidden(java.nio.file.Path)) and is not considered when determining the extension.
This allows Windows to exhibit Windows behavior, and UNIX to exhibit UNIX behavior, exactly as `Files.isHidden(Path.of(".mp3"))` returns `false|true` on Windows and `true` on UNIX.
3. The invariant in `withoutExtension` is problematic for custom providers.
The invariant effectively says "the extension always comes at the very end of the filename" *and* "the extension separator is a dot".
So I cannot implement a compliant provider that says the extension of `foo#filename.mp3` is `foo`, for example, even though that may be the whole point of that provider: to piggyback on these APIs to encode an additional piece of metadata in the filename and delegate to the default provider for everything else.
(*) Python, JavaScript (Node.js), Kotlin, .NET (C#/PowerShell), Rust, Go, PHP, C (Win32), Objective-C, Ruby
(**) `Files::probeContentType`, Guava, Apache Commons
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1986116361
</pre></body></html>