JEP String Templates

Jim Laskey james.laskey at oracle.com
Sat Mar 19 17:26:02 UTC 2022


I think you are looking for a different feature which is to get a list of locals with values. This is not likely to happen due to the potential for vulnerability exploit. 

The fields solution can be handled using reflection and a template policy to display fields with values. 

— Jim

��

> On Mar 19, 2022, at 2:07 PM, Jonathan Locke <jon at thanlocke.com> wrote:
> 
> 
> 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