RFR: 7903727: Remove the reliance on String Templates feature

Maurizio Cimadamore mcimadamore at openjdk.org
Mon May 20 10:05:15 UTC 2024


On Mon, 20 May 2024 09:17:22 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.

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

> 408:                 return %s.SEGMENT.get(%s.LAYOUT, 0L);
> 409:             }
> 410:             """, type.getSimpleName(), javaName, holderClass, holderClass));

In these cases, an ad-hoc formatter might work as well. Similar to `MessageFormat` which allows the user to pass arguments with indices like `{0}` and `{1}`. Example:


jshell> MessageFormat.format("{0} {0} {1}", "Hello", "World!");
$7 ==> "Hello Hello World!"

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

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


More information about the jextract-dev mailing list