New candidate JEP: 430: String Templates (Preview)

Mark Rotteveel mark at lawinegevaar.nl
Wed Sep 21 13:50:59 UTC 2022


On 20-09-2022 20:10, Mark Reinhold wrote:
> https://openjdk.org/jeps/430
> 
>    Summary: Enhance the Java programming language with string
>    templates, which are similar to string literals but contain embedded
>    expressions. A string template is interpreted at run time by replacing
>    each expression with the result of evaluating that expression, possibly
>    after further validation and transformation. This is a preview language
>    feature and API.
> 
> - Mark

I have some suggestions:

Under "Can we do better?", the example SQL uses non-standard SQL syntax 
(using a \' to escape quotes, instead of '' as defined in ISO/IEC 
9075-2:2016, section 5.3 <literal>). I suggest replacing this with 
standard syntax.

The example under "Safely composing and executing database queries" can 
be simplified by using ps.setObject(index++, value), removing the need 
for the switch (this does assume only types specified in JDBC are used, 
but on the other hand, the blanket use of String.valueOf(value) in the 
default case can cause a different set of problems).

Mark
-- 
Mark Rotteveel



More information about the jdk-dev mailing list