Fwd: JEP String Templates

Jonathan Locke jon at thanlocke.com
Sat Mar 19 17:07:27 UTC 2022


Hello JDK Developers,

Regarding the JEP for String Templates (https://openjdk.java.net/jeps/8273943), I thought it would be an interesting feature to allow the substitution of multiple variables at the same time:

  “\{fields:*}”

would give all the fields to the formatter, which could produce a nice “x = 5, x1 = 9” kind of output by default. 

For local variables:

  “\{locals:*}”

For both:

  “\{fields:*,locals:*}”

For and, of course, general globbing:

  “\{fields:user*}”

Would match fields starting with “user” like “userIdentifier” and “userName"

Best, 

   Jon




More information about the jdk-dev mailing list