RFR: 7903637: Use holder classes for string constants [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jan 22 19:29:58 UTC 2024


On Mon, 22 Jan 2024 19:02:06 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Use holder class idiom for string constants (See JBS issue for motivation).
>> 
>> The code in `emitConstant` is a bit copy-pasty. We need to strike a balance between giving a clear picture of the generated code by using a single string template as much as possible, and reducing duplication by splitting the templates up and weaving in more control flow.
>> 
>> I went with the repeated, but clearer approach here of having 2 separate templates. Let me know if you'd like me to change that.
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review comments

Marked as reviewed by mcimadamore (Reviewer).

src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 425:

> 423:         if (type == MemorySegment.class) {
> 424:             return STR."MemorySegment.ofAddress(\{((Number)value).longValue()}L)";
> 425:         } else {

Can we beef up this method with something like `if (value instanceof Number) <current logic> else throw UOE` ?

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

PR Review: https://git.openjdk.org/jextract/pull/191#pullrequestreview-1837205278
PR Review Comment: https://git.openjdk.org/jextract/pull/191#discussion_r1462310261


More information about the jextract-dev mailing list