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`.

This pull request has now been integrated.

Changeset: de7fd1c3
Author:    Mandy Chung <mch...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/de7fd1c3061cfbfdbd5d7cc2b1ba0ee8d432ee0a
Stats:     167 lines in 6 files changed: 75 ins; 58 del; 34 mod

8307944: ClassFileDumper should only load java.nio.file.Path if enabled

Reviewed-by: rriggs

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

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

Reply via email to