On Mon, 27 Mar 2023 21:12:28 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 two additional 
> commits since the last revision:
> 
>  - move ClassFileDumper to jdk.internal.util
>  - rename the system property for dumping class files

src/java.base/share/classes/jdk/internal/util/ClassFileDumper.java line 209:

> 207:         final int len = className.length();
> 208:         StringBuilder sb = new StringBuilder(len);
> 209: 

This could be fewer lines of adhoc conversions, the replacements are hex 
encoding of the characters, so the replacement array is not needed. 
java.util.HexFormat should be used for the hex encoding. The `formatHex` 
methods append to a StringBuilder.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13182#discussion_r1151185689

Reply via email to