Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8346573: Can't use custom default file system provider with custom system class loader #22842

Closed
wants to merge 1 commit into from

Conversation

AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Dec 20, 2024

If an application is deployed to use a custom default file system provider, and a custom system class loader, and initialisation of the custom system class loader uses the file system APIs, then it leads to a recursive initialisation issue. This issue has always existed but has only recently been reported. Using both configuration knobs at the same time is probably very rare but it does require attention in advance of any proposals that re-implement the java.io file classes on java.nio.file.

The proposed change here is to re-specify FileSystems.getDefault to use the default system class loader when locating the custom default file system provider. In spec terms, this is changing "system class loader" to "default system class loader" with a link to its meaning in ClassLoader.getSystemClassLoader. As part of the change I've expanded the wording to specify that the custom default file system provider must be public in a package exported to at least java.base, and that the one-arg constructor also be public. This additional clarification specifies long standing behavior and does not change any implementation.

The SetDefaultProvider.java test is expanded to add a new test the runs with both a custom default file system provider and custom system class loader, and where where the custom system class loader uses the file APIs in its initialisation.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Change requires CSR request JDK-8346709 to be approved
  • Commit message must refer to an issue

Issues

  • JDK-8346573: Can't use custom default file system provider with custom system class loader (Bug - P3)
  • JDK-8346709: Can't use custom default file system provider with custom system class loader (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22842/head:pull/22842
$ git checkout pull/22842

Update a local copy of the PR:
$ git checkout pull/22842
$ git pull https://git.openjdk.org/jdk.git pull/22842/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22842

View PR using the GUI difftool:
$ git pr show -t 22842

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22842.diff

Using Webrev

Link to Webrev Comment

@AlanBateman
Copy link
Contributor Author

/csr

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 20, 2024

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 20, 2024

@AlanBateman This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8346573: Can't use custom default file system provider with custom system class loader

Reviewed-by: mkartashev, bpb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 48 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Dec 20, 2024
@openjdk
Copy link

openjdk bot commented Dec 20, 2024

@AlanBateman has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@AlanBateman please create a CSR request for issue JDK-8346573 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk
Copy link

openjdk bot commented Dec 20, 2024

@AlanBateman The following label will be automatically applied to this pull request:

  • nio

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@AlanBateman AlanBateman marked this pull request as ready for review December 20, 2024 10:40
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 20, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 20, 2024

Webrevs

Copy link
Member

@mkartashev mkartashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a reviewer, but this does solve the problem with the circular initialization that we had.


// use default file system
FileSystem fs = FileSystems.getDefault();
var path = fs.getPath("foo");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe print the path out so that the whole thing does not get optimized away as vacuous in accordance with the language rules?

Copy link
Member

@bplb bplb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

Constructor<?> ctor = c
.getDeclaredConstructor(FileSystemProvider.class);
provider = (FileSystemProvider)ctor.newInstance(provider);
Class<?> c = Class.forName(cn, true, ClassLoaders.appClassLoader());
Copy link

@ExE-Boss ExE-Boss Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this might break the case where a custom system ClassLoader doesn’t depend on a custom default FileSystemProvider but the latter depends on the custom system ClassLoader, so this should call ClassLoaders​::appClassLoader() only when VM.isBooted() is false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A custom default file system provider can't depend on a custom system ClassLoader. Think of access to the default file system as something that works at a much lower level that a class loader.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Jan 6, 2025
@AlanBateman
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 7, 2025

Going to push as commit f119663.
Since your change was applied there have been 53 commits pushed to the master branch:

  • 379ac34: 8346838: RISC-V: runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java crash with debug VMs
  • 0285020: 8345676: [ubsan] ProcessImpl_md.c:561:40: runtime error: applying zero offset to null pointer on macOS aarch64
  • 0a81676: 8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer
  • 08debd3: 8346993: C2 SuperWord: refactor to make more vector nodes available in VectorNode::make
  • de02503: 8346832: runtime/CompressedOops/CompressedCPUSpecificClassSpaceReservation.java fails on RISC-V
  • 27646e5: 8344148: Add an explicit compiler phase for warning generation
  • 8d388cc: 8346457: AOT cache creation crashes with "assert(pair_at(i).match() < pair_at(i+1).match()) failed: unsorted table entries"
  • d723597: 8345432: (ch, fs) Replace anonymous Thread with InnocuousThread
  • 9c393a2: 8346953: Remove unnecessary @SuppressWarnings annotations (client, Make "can write" check work on Windows #2)
  • 9a60f44: 8345668: ZoneOffset.ofTotalSeconds performance regression
  • ... and 43 more: https://git.openjdk.org/jdk/compare/54f34750edb284f4a49fb86c3939491211eb98fe...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 7, 2025
@openjdk openjdk bot closed this Jan 7, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 7, 2025
@openjdk
Copy link

openjdk bot commented Jan 7, 2025

@AlanBateman Pushed as commit f119663.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated nio [email protected]
Development

Successfully merging this pull request may close these issues.

4 participants