RFR: 8352728: InternalError loading java.security due to Windows parent folder permissions [v8]

Francisco Ferrari Bihurriet fferrari at openjdk.org
Wed Nov 12 18:37:44 UTC 2025


On Fri, 7 Nov 2025 16:18:30 GMT, Sean Mullan <mullan at openjdk.org> wrote:

>> Francisco Ferrari Bihurriet has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Detect cyclic includes with Files::isSameFile
>>   
>>   checkCyclicInclude() is invoked after we successfully get an InputStream
>>   for the path to avoid skipping the same IOException several times inside
>>   checkCyclicInclude() if the path doesn't exist.
>>   
>>   Also, perform symlinks resolution only in the following cases:
>>    • When we need to resolve a relative include
>>    • For clarity to the user in logging messages
>>    • For clarity to the user in exception messages
>>   
>>   In the first case, the resolution is a requirement, in the last two
>>   cases it is a nice-to-have. But given the last two are exceptional
>>   cases anyway, we let any resolution error bubble up.
>
> src/java.base/share/classes/java/security/Security.java line 295:
> 
>> 293:                 throws IOException {
>> 294:             boolean isRegularFile = Files.isRegularFile(path);
>> 295:             if (!isRegularFile && Files.isDirectory(path)) {
> 
> Can a directory ever be a regular file? If not, you don't need the `!isRegularFile` check.

A directory is not a regular file, but we need `isRegularFile` later here:

https://github.com/openjdk/jdk/blob/a8d865c4985e6660655b27df28e76882855b2087/src/java.base/share/classes/java/security/Security.java#L302

So `!isRegularFile` is part of the condition to save the posible `Files::isDirectory` I/O operations in the most likely case (we are including a regular file).

Previous code was also saving this I/O:

https://github.com/openjdk/jdk/blob/4b315111493ac65511890bc2127489ceee693915/src/java.base/share/classes/java/security/Security.java#L268-L272

I would prefer not to, but I can remove the condition and inline `Files::isRegularFile` on line 302:


currentPath = Files.isRegularFile(path) ? path : null;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24465#discussion_r2519385066


More information about the security-dev mailing list