On Mon, 3 Apr 2023 20:24:56 GMT, Mandy Chung <mch...@openjdk.org> wrote:
>> This implements a shared utility to dump generated classes defined as >> normal/hidden classes via `Lookup` API. This replaces the implementation >> in `LambdaMetaFactory` and method handle implementation that dumps the >> hidden class bytes on disk for debugging. >> >> For classes defined via `Lookup::defineClass`, `Lookup::defineHiddenClass` >> and `Lookup::defineHiddenClassWithClassData`, by default they will be dumped >> to the path specified in `-Djava.lang.invoke.Lookup.dumpClasses=<dumpDir>` >> >> The hidden classes generated for lambdas, `LambdaForms` and method handle >> implementation use non-default dumper so that they can be controlled via a >> separate system property and path as in the current implementation. >> >> To dump lambda proxy classes, set this system property: >> -Djdk.internal.lambda.dumpProxyClasses=<dumpDir> >> >> To dump LambdaForms and method handle implementation, set this system >> property: >> -Djava.lang.invoke.MethodHandle.DUMP_CLASS_FILES=true >> >> P.S. `ProxyClassesDumper` is renamed to `ClassFileDumper` but for some >> reason, it's not shown as rename. > > Mandy Chung has updated the pull request incrementally with one additional > commit since the last revision: > > comments from Jorn Vernee src/java.base/share/classes/jdk/internal/util/ClassFileDumper.java line 199: > 197: @Override > 198: public Path run() { > 199: if (!Files.exists(path)) { I do not think this is necessary, Files.createDirectories() already only create directories if they do not exist. Moreover, someone can change the state of the files in between the two calls (Files.exists and Files.createDirectories) given that those two calls are not atomic from the filesystem POV. src/java.base/share/classes/jdk/internal/util/ClassFileDumper.java line 216: > 214: } > 215: > 216: private static HexFormat HEX = HexFormat.of().withUpperCase(); 'final' ? src/java.base/share/classes/jdk/internal/util/ClassFileDumper.java line 226: > 224: // control characters > 225: if (c <= 31 || BAD_CHARS.contains(c)) { > 226: sb.append("%"); sb.append('%') // using a character instead of a String ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13182#discussion_r1156456578 PR Review Comment: https://git.openjdk.org/jdk/pull/13182#discussion_r1156456936 PR Review Comment: https://git.openjdk.org/jdk/pull/13182#discussion_r1156457481