JDK-8301001 : Retire the system properties sun.io.useCanonCaches and sun.io.useCanonPrefixCache
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2023-01-24
  • Updated: 2023-03-22
  • Resolved: 2023-03-22
Related Reports
CSR :  
Description
Summary
-------
Retire the system properties `sun.io.useCanonCaches` and `sun.io.useCanonPrefixCache` and the underlying internal `java.io.ExpiringCache` class.

Problem
-------

`java.io.File` has a cache of canonical paths and part paths to help the performance of the `File::getCanonicalFile` and `File::File::getCanonicalPath`. The cache was introduced in JDK 1.4.x to help the startup of Applets and Java Web Start applications running with a security manager.  These types of applications are not relevant to JDK 9 or newer releases.  Furthermore, `java.io.FilePermission` was changed in JDK 9 to no longer need the canonical path so this removes must of the original motivation for the cache for the few remaining applications that run with a security manager.

The cache has correctness issues that arise when files are changed or when symbolic files are added to removed. The cache was disabled in JDK 12. It is time to finally remove it.

Solution
-------

Drop the cache and the following two system properties:

 - `sun.io.useCanonCaches`
 - `sun.io.useCanonPrefixCache`


Specification
-------------

No specification changes, the system properties (and the caching mechanism) were never documented in an implNote. 

A release note will be added.

Comments
Moving to Approved.
22-03-2023

[~pminborg], for now, moving the request to Finalized to indicate it is ready for the second phase of review.
22-03-2023

Under "Specification", I have added references to the system properties and the affected classes. Can we move this to Approved now?
21-03-2023

Moving to Provisional, not Approved. [~pminborg], before the request is Finalized for the second phase of CSR review, please list what specific "...reference[s] to the above system properties" end up getting removed, if any.
01-03-2023

I've edited the Problem section to add the history of this mis-feature. I've also added myself as Reviewer so the CSR can be Finalized. Also I've added release-note=yes to the issue so that we remember to add a RN for this change.
01-03-2023

Also just to add that the CSR doesn't need to mention java.io.ExpiringCache as that is a JDK internal class. Instead, this CSR is about dropping the ability to enable caching of canonical paths and the two system properties. As background, this caching was a mis-feature introduced in JDK 1.4.x to help startup (Java Web Start / Plugin) as there were many security manager permission checks that needed the canonical path. I say "mis-feature" because it interacts badly in environments with symbolic links and where directories are being created and removed while an application is running. The work in JDK 9 to remove canonicalization from FilePermission (JDK-8164705) mostly eliminated the need for this caching. The cache was changed to be disabled by default in JDK 12 (JDK-8207005).
01-03-2023

[~pminborg], please move the CSR to "Proposed" or "Finalized" to indicate it is ready for CSR review; thanks.
28-02-2023