RFR: 7903727: Remove the reliance on String Templates feature
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon May 20 09:54:12 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/ClassSourceBuilder.java line 145:
> 143:
> 144: final void emitDefaultConstructor() {
> 145: appendIndentedLines(String.format("""
Suggestion - tweak the `appendIndentedLines` to call `String::format` inside that method, so that all clients don't have to call `String::format` manually from outside.
src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 193:
> 191: case Primitive p -> primitiveLayoutString(p, align);
> 192: case Declared d when Utils.isEnum(d) -> layoutString(((Constant)d.tree().members().get(0)).type(), align);
> 193: case Declared d when Utils.isStructOrUnion(d) -> alignIfNeeded(String.format("%s.layout()", JavaName.getFullNameOrThrow(d.tree())), ClangAlignOf.getOrThrow(d.tree()) / 8, align);
Same thing here - if all calls to `alignIfNeeded` end up with `String::format`, considering moving `String::format` there
-------------
PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1606529144
PR Review Comment: https://git.openjdk.org/jextract/pull/244#discussion_r1606530581
More information about the jextract-dev
mailing list