[code-reflection] RFR: Experiment with replacing textual representation in classfile with method that builds the model [v2]

Paul Sandoz psandoz at openjdk.org
Fri Nov 8 22:19:32 UTC 2024


On Fri, 8 Nov 2024 09:10:12 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> Experiment with replacing textual representation in classfile with method that builds the model.
>> Note: This PR is based on changes from #272.
>
> Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Assert on the value of executing builder method
>  - Change bytecode generation for NewOp to use constructor type as owner

test/jdk/java/lang/reflect/code/writer/TestOpMethod.java line 67:

> 65: 
> 66:     @Test(dataProvider = "classes")
> 67:     void test(byte[] cd) throws Throwable {

That's a good start, but i suspect what we need here is also a main method, so we can run this over many classes via some script. Thereby we get more (albeit manual) test exposure and can get statistics class file sizes before and after i.e. we can run the script over all the compiled test class files in lang and jdk.

test/jdk/java/lang/reflect/code/writer/TestOpMethod.java line 114:

> 112:                 var lci = (ConstantInstruction.LoadConstantInstruction) prev;
> 113:                 var pe = (StringEntry) lci.constantEntry();
> 114:                 res.add(new OpFieldAndIR(fi.name().stringValue().substring(fi.name().stringValue().indexOf(':') + 2), pe.stringValue()));

Suggest you return pairs of `FieldRefEntry` (or `FieldInstruction`)  and `String`, thereby you retain the full field name for possible reduction later on if needed, and you can reuse later when removing them.

Was there an issue with using the synthetic field name as a synthetic method name?

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

PR Review Comment: https://git.openjdk.org/babylon/pull/274#discussion_r1835109445
PR Review Comment: https://git.openjdk.org/babylon/pull/274#discussion_r1835104311


More information about the babylon-dev mailing list