On Thu, 25 May 2023 20:23:27 GMT, Mandy Chung <mch...@openjdk.org> wrote:
> 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`. Looks good, delaying the checking of the file system until its is needed will save on startup. src/java.base/share/classes/jdk/internal/util/ClassFileDumper.java line 136: > 134: // recursive initialization during early startup. e.g. > 135: // Enum::valueOf causes method handle to be invoked which > 136: // may cause classes to be spinned and dumped This comment could be omitted; it won't age well and is out of context for the fix. ------------- Marked as reviewed by rriggs (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/14160#pullrequestreview-1444720329 PR Review Comment: https://git.openjdk.org/jdk/pull/14160#discussion_r1206049390