RFR: 7903727: Remove the reliance on String Templates feature [v7]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jun 5 13:28:11 UTC 2024


On Wed, 5 Jun 2024 11:26:38 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> This PR aims to replace the usage of string templates with `String::format`, since there will be no string template feature in JDK 23.
>> I tried to keep similar indentation and convert them in-place, to make reviewing the changes easier.
>
> Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision:
> 
>   - remove whitespace
>   - fix doc comment

src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 172:

> 170:              * }
> 171:              */
> 172:             """, !header.isEmpty() ? String.format(" * %1$s\n", header) : "", declarationComment(decl));

optional comment: we could add a `format` method (which just calls String::format) and then implement `appendIndentedLines` on top. I guess what I wonder is if, at some point (not in this PR), it might make sense to create a more specialized format syntax for jextract use to make `%1$s` a bit more readable.

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

PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1627783065


More information about the jextract-dev mailing list