RFR: JDK-8315457 Implementation of String Templates (Second Preview) [v2]

Jan Lahoda jlahoda at openjdk.org
Mon Oct 16 16:20:24 UTC 2023


On Mon, 16 Oct 2023 15:23:25 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:

>> Update String Templates for a second preview. With the addition of
>> 
>> - Expression type and throws are determined from the `process` method of the processor type and not the processor type.
>> 
>> - Qualified `STR` and `RAW` are treated the same as unqualified `STR` and `RAW` .
>> 
>> - Raw (generic) process types are no longer an error.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Revert source
>  - Revert @since 22

javac changes look reasonable to me. Added some mostly minor comments.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 1691:

> 1689:         }
> 1690: 
> 1691:         private Type getProcessMethodType(JCStringTemplate tree, Type processorType) {

This method is basically the same as in `Attr`, correct? I wonder if there's a way to avoid the duplication? One possibility would be to compute the type in `Attr`, and store it in a field on `JCStringTemplate`, and just use it in `Flow`. Alternatively, it could be shared in some class, although only `TreeInfo` and `Resolve` come to mind, and neither seem particularly suitable for that.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransLiterals.java line 257:

> 255: 
> 256:         boolean isNamedProcessor(Name name) {
> 257:             Symbol sym = switch (processor) {

Maybe `TreeInfo.symbol(processor)` here?

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

PR Review: https://git.openjdk.org/jdk/pull/16202#pullrequestreview-1680264976
PR Review Comment: https://git.openjdk.org/jdk/pull/16202#discussion_r1360841404
PR Review Comment: https://git.openjdk.org/jdk/pull/16202#discussion_r1360830232


More information about the compiler-dev mailing list