On Mon, 9 Feb 2026 15:38:23 GMT, David Beaumont <[email protected]> wrote:

>> Allow users of Toolbox.MemoryFileManager to specify if the delegate file 
>> manager should also be closed when it is closed.
>> 
>> This fixes a use-after-close bug in TestOriginatingElements, where the 
>> system file manager and wrapping memory file manager have different, nested, 
>> lifetimes resulting in an early call to close the system file manager when 
>> the wrapper is closed, causing subsequent legitimate use of the system file 
>> manager to fail.
>> 
>> This wasn't noticed before now since the system file manager was using the 
>> singleton JRT file-system in which "close" does nothing. Now it's using a 
>> properly scoped instance of the JRT file-system which can be closed.
>
> David Beaumont has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains eight additional 
> commits since the last revision:
> 
>  - revert forwarding file manager
>  - Remove extraneous problem list entry
>  - Reworking to simplify
>    
>    * Problem list
>    * temp commit
>    * add @since for new method
>    * tidy and restore eagerly removed not-actually-dead code
>    * Allow callers to decide if delgate file manager should be closed
>  - Merge branch 'lworld' into jdk_8373825_ffm/squashed
>  - add @since for new method
>  - undo reformatting
>  - tidy and restore eagerly removed not-actually-dead code
>  - Allow callers to decide if delgate file manager should be closed

Consider upstreaming this to mainline.

JavaCompiler::getStandardFileManager specifies:

> The standard file manager will be automatically reopened if
> it is accessed after calls to `flush` or `close`.
> The standard file manager must be usable with other tools.

Logically the forwarding manager should never need to override close. The 
problem really lies in the standard file manager not reopening the correct 
resources.

src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java line 
1:

> 1: /*

Since you explicitly overrides `close` in the test, let's remove the changes 
here.

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

PR Review: 
https://git.openjdk.org/valhalla/pull/1810#pullrequestreview-3766601675
Changes requested by liach (Committer).

PR Review: 
https://git.openjdk.org/valhalla/pull/1810#pullrequestreview-3766643654
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/1810#discussion_r2777234693

Reply via email to