RFR: 8307944: ClassFileDumper should only load java.nio.file.Path if enabled [v2]

Mandy Chung mchung at openjdk.org
Tue May 30 17:37:24 UTC 2023


> Change `ClassFileDumper` constructor to take a `String` rather than `Path` to avoid the file system implementation classes loaded during startup.  In addition, `FilePermission` also causes the default file system to be initialized. 
> 
> This patch changes `ClassFileDumper` to validate the given path only if it's enabled and not to use limited `doPrivileged` to avoid the initialization of `FilePermission` class and the file system implementation classes by default.
> 
> This patch also changes `ClassFileDumper::write` to use `File` instead of `Path` because of JDK-8306678.  `OperatingSystem::<clinit>` causes `Enum::valueOf` to be called which calls core reflection which in turns invokes method handles.   If `-Djdk.invoke.MethodHandle.dumpMethodHandleInternals` is set, VM initialization would fail because `BootLoader::<clinit>` causes `ClassLoaderHelper` to initialize which in turn causes `OperatingSystem` be initialized.   If additional LFs are spinned and dumped, if `ClassFileDumper` uses `Path` for writing, `FileSystems::getDefault` would fail with `NullPointerException` because it calls `BootLoader.loadLibrary` which is not fully initialized. 
> 
> A separate issue will be filed to follow up the startup overhead of `OperatingSystem`.

Mandy Chung 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 four additional commits since the last revision:

 - minor clean up
 - Revert ClassFileDumper to use Path as JDK-8308960 removed the dependency to Enum::valueOf
 - Merge branch 'master' of https://github.com/openjdk/jdk into class-file-dumper
 - 8307944: ClassFileDumper should only load java.nio.file.Path if enabled

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/14160/files
  - new: https://git.openjdk.org/jdk/pull/14160/files/b0502d6e..3529e2fa

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14160&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14160&range=00-01

  Stats: 8727 lines in 195 files changed: 5998 ins; 795 del; 1934 mod
  Patch: https://git.openjdk.org/jdk/pull/14160.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14160/head:pull/14160

PR: https://git.openjdk.org/jdk/pull/14160


More information about the core-libs-dev mailing list