<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
TemplateSupport is used internally in java.lang.runtime and is package private. Nothing to see there.<br>
<div><br>
<blockquote type="cite">
<div>On Mar 27, 2023, at 11:18 AM, Brian Goetz <brian.goetz@oracle.com> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div><font size="4"><font face="monospace">Nice.<br>
<br>
So that means java.lang additions are limited to StringTemplate (with nested Processor), and public jl.runtime limited to Template{Runtime,Support}.
<br>
<br>
In the spirit of "nothing left to take away", who are the methods in TemplateSupport used by? Authors of processors? There's not too much here -- creation, interpolation, combination. Would these make sense as static helper methods on STringTemplate? They'd
be more discoverable there. <br>
<br>
</font></font><br>
<div class="moz-cite-prefix">On 3/27/2023 9:07 AM, Jim Laskey wrote:<br>
</div>
<blockquote type="cite" cite="mid:15178054-61DC-49CB-B14D-174F5A88ECD2@oracle.com">
<p style="font-size: 14px;">After the string template interface name changes, i.e., <code style="color: rgb(0, 0, 170);">TemplateProcessor</code> becoming <code style="color: rgb(0, 0, 170);">Processor</code>, the rationale for the existence of <code style="color: rgb(0, 0, 170);">SimpleProcessor </code>and <code style="color: rgb(0, 0, 170);">StringProcessor</code> has
lessened to the point where they should be dropped.</p>
<p style="font-size: 14px;"><code style="color: rgb(0, 0, 170);">SimpleProcessor</code> owed its existence to the long-winded name <code style="color: rgb(0,
0, 170);">TemplateProcessor</code> and that ugly second parameter, <code style="color: rgb(0, 0, 170);">E</code>,
in <code style="color: rgb(0, 0, 170);">Processor<R, E></code> (in a many of cases <code style="color: rgb(0, 0, 170);">E</code> will be the unchecked <code style="color: rgb(0, 0, 170);">RuntimeException</code>). <code style="color: rgb(0, 0, 170);">StringProcessor</code> existed
because most template processors will produce strings.</p>
<pre style="background-color: rgb(239, 239, 239); border: 1px solid black; padding: 8px; font-size: 14px;"><code style="color: rgb(0, 0, 170);">TemplateProcessor<JSONObject, RuntimeException> JSON = st-> new JSONObject(st.interpolate());
TemplateProcessor<String, RuntimeException> INTER = StringTemplate::interpolate;</code></pre>
<p style="font-size: 14px;">vs.</p>
<pre style="background-color: rgb(239, 239, 239); border: 1px solid black; padding: 8px; font-size: 14px;"><code style="color: rgb(0, 0, 170);">SimpleProcessor<JSONObject> JSON = st-> new JSONObject(st.interpolate());
StringProcessor INTER = StringTemplate::interpolate;</code></pre>
<p style="font-size: 14px;">It was thought that having the friendlier interfaces would provide clarity, hide <code style="color: rgb(0, 0, 170);">RuntimeException</code> and simplify explanation. The reality is that most developers will define template processors
using full class declarations. Furthermore, developers will learn to use <code style="color:
rgb(0, 0, 170);">RuntimeException</code> regularly due to the abundance of template processor examples.</p>
<pre style="background-color: rgb(239, 239, 239); border: 1px solid black; padding: 8px; font-size: 14px;"><code style="color: rgb(0, 0, 170);">public class InterpolateProcessor implements Processor<String, RuntimeException> {
@Override
public String process(StringTemplate st) {
return st.interpolate();
}
}
SimpleProcessor<String> INTER = new InterpolateProcessor();
</code></pre>
<p style="font-size: 14px;">Even after <code style="color: rgb(0,
0, 170);">SimpleProcessor</code> and <code style="color:
rgb(0, 0, 170);">StringProcessor</code> go away, developers can still use the functional interface shorthand.</p>
<pre style="background-color: rgb(239, 239, 239); border: 1px solid black; padding: 8px; font-size: 14px;"><code style="color: rgb(0, 0, 170);">Processor<JSONObject, RuntimeException> JSON = st-> new JSONObject(st.interpolate());
Processor<String, RuntimeException> INTER = StringTemplate::interpolate;</code></pre>
<p style="font-size: 14px;">And, a new factory method, <code style="color: rgb(0, 0, 170);">Processor.of</code>, will be added for fans of <code style="color: rgb(0, 0, 170);">var</code>.</p>
<pre style="background-color: rgb(239, 239, 239); border: 1px solid black; padding: 8px; font-size: 14px;"><code style="color: rgb(0, 0, 170);">var JSON = Processor.of(st-> new JSONObject(st.interpolate()));
var INTER = Processor.of(StringTemplate::interpolate);</code></pre>
<p style="font-size: 14px;">For those developers that like the notion of <code style="color: rgb(0, 0, 170);">SimpleProcessor</code> and <code style="color: rgb(0, 0, 170);">StringProcessor</code>, these interfaces can be trivially defined per project;</p>
<pre style="background-color: rgb(239, 239, 239); border: 1px solid black; padding: 8px; font-size: 14px;"><code style="color: rgb(0, 0, 170);">@FunctionalInterface
public interface SimpleProcessor<R> extends Processor<R, RuntimeException> {}
@FunctionalInterface
public interface StringProcessor extends SimpleProcessor<String> {}</code></pre>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<blockquote type="cite">
<div>On Mar 17, 2023, at 10:24 AM, Jim Laskey <a class="moz-txt-link-rfc2396E" href="mailto:james.laskey@oracle.com">
<james.laskey@oracle.com></a> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div style="overflow-wrap: break-word; -webkit-nbsp-mode:
space; line-break: after-white-space;">
<div style="font-size: 14px;">This is a heads up about some name changes coming to the string template feature with the intent of eliminating the “java.lang.template” package along with clarifying the processor hierarchy,</div>
<div><br>
</div>
<div>
<table style="border-collapse: collapse; width: 481pt;" width="641" cellspacing="0" cellpadding="0" border="0">
<colgroup><col style="width: 265pt;" width="353"><col style="width: 216pt;" width="288"></colgroup>
<tbody>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt; width:
265pt;" width="353" height="21">
<u><font face="Consolas">Old</font></u></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; width: 216pt;" width="288">
<u><font face="Consolas">New</font></u></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.Carriers*</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.Carriers*</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.ReferencedKeyMap*</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.ReferencedKeyMap*</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.ReferenceKey*</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.ReferenceKey*</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.StringTemplateImpl*</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.StringTemplateImpl*</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.StringTemplateImplFactory* </font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.StringTemplateImplFactory*</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.runtime.TemplateRuntime</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.TemplateRuntime</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.TemplateSupport*</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.runtime.TemplateSupport</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.StringTemplate</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.StringTemplate</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.ValidatingProcessor</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.StringTemplate.Processor</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.ProcessorLinkage</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.StringTemplate.Processor.Linkage</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.TemplateProcessor</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.StringTemplate.SimpleProcessor</font></td>
</tr>
<tr style="height: 16pt;" height="21">
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap; height: 16pt;" height="21">
<font face="Consolas">java.lang.template.StringProcessor</font></td>
<td style="padding-top: 1px; padding-right: 1px;
padding-left: 1px; font-size: 12pt;
vertical-align: bottom; border: none;
white-space: nowrap;">
<font face="Consolas">java.lang.StringTemplate.StringProcessor</font></td>
</tr>
</tbody>
</table>
</div>
<div><font face="Consolas"><br>
</font></div>
<div><font face="Consolas">(*) - package private</font></div>
<div><br>
</div>
<div style="font-size: 14px;"><br>
</div>
<div style="font-size: 14px;">The new processor hierarchy will be;</div>
<div style="font-size: 14px;"><br>
</div>
<div><font face="Consolas"><span style="font-style:
normal; font-size: 14px;">interface Processor<R, E></span></font></div>
<div><font face="Consolas"><span style="font-style:
normal; font-size: 14px;">interface SimpleProcessor<R> extends Processor<R, RuntimeException></span></font></div>
<div><font face="Consolas"><span style="font-style:
normal; font-size: 14px;">interface StringProcessor extends SimpleProcessor<String></span></font></div>
<div style="font-size: 14px;"><br>
</div>
<div style="font-size: 14px;">It will take me a few days to update the JEP, CSRs, PR and JLS, so stay tuned. As always, comments are welcome.</div>
<div style="font-size: 14px;"><br>
</div>
<div style="font-size: 14px;">Cheers,</div>
<div style="font-size: 14px;"><br>
</div>
<div style="font-size: 14px;">— Jim</div>
<div style="font-size: 14px;"><br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</blockquote>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</body>
</html>