<div dir="auto"><div>Looks great, thank you!</div><div dir="auto"><br></div><div dir="auto">Tagir<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Fri, Oct 13, 2023, 11:13 Gavin Bierman <<a href="mailto:gavin.bierman@oracle.com">gavin.bierman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Tagir,<br>
<br>
Apologies for not replying sooner. Yes, this is an excellent suggestion - improving the precision of typing template expressions is a very welcome change :-)<br>
<br>
I have updated the spec, and the compiler will be updated shortly.<br>
<br>
Thanks,<br>
Gavin<br>
<br>
> On 10 Oct 2023, at 06:33, Tagir Valeev <<a href="mailto:amaembo@gmail.com" target="_blank" rel="noreferrer">amaembo@gmail.com</a>> wrote:<br>
> <br>
> Hello, experts!<br>
> <br>
> Probably it's possible to fix the small thing I wrote before? Namely,<br>
> the type of template expression and its thrown exceptions are<br>
> determined by the template expression class signature (namely, the<br>
> instantiation of R and E generic parameters of Processor) and ignoring<br>
> the actual signature of the process() method, which may have covariant<br>
> return type and thrown exception type declared. This looks out of sync<br>
> with the rest of Java. Example:<br>
> <br>
> public final class TemplateTest {<br>
> interface AnyProcessor extends StringTemplate.Processor<Object,<br>
> Throwable> {}<br>
> <br>
> static class IntProcessor implements AnyProcessor {<br>
> @Override<br>
> public Integer process(StringTemplate stringTemplate) {<br>
> return 123;<br>
> }<br>
> }<br>
> <br>
> public static void main(String[] args) {<br>
> // error: incompatible types: java.lang.Object cannot be<br>
> converted to java.lang.Integer<br>
> Integer xyz = new IntProcessor()."hello";<br>
> // error: unreported exception java.lang.Throwable; must be<br>
> caught or declared to be thrown<br>
> Object xyz2 = new IntProcessor()."hello";<br>
> }<br>
> }<br>
> <br>
> I'm not sure whether current behavior is explicitly stated in the spec<br>
> draft, but the reference implementation behaves this way. I would<br>
> expect this code to be compilable.<br>
> <br>
> Note that we have a similar implicit method invocation construct,<br>
> try-with-resources, and it respects the actual signature of the<br>
> close() method (namely, declared exceptions). I think that similarly<br>
> we should respect the actual method signature here.<br>
> <br>
> With best regards,<br>
> Tagir Valeev.<br>
> <br>
> On Mon, Oct 9, 2023 at 4:46 PM Gavin Bierman <<a href="mailto:gavin.bierman@oracle.com" target="_blank" rel="noreferrer">gavin.bierman@oracle.com</a>> wrote:<br>
>> <br>
>> Dear experts:<br>
>> <br>
>> The first draft of a spec covering JEP 459 (String Templates (Second Preview)) is now available at:<br>
>> <br>
>> <a href="https://cr.openjdk.java.net/~gbierman/jep459/latest" rel="noreferrer noreferrer" target="_blank">https://cr.openjdk.java.net/~gbierman/jep459/latest</a><br>
>> <br>
>> Feel free to contact me directly or on this list with any comments.<br>
>> <br>
>> Thanks<br>
>> Gavin<br>
>> <br>
>> <br>
>>> On 5 Oct 2023, at 13:20, Mark Reinhold <<a href="mailto:mark.reinhold@oracle.com" target="_blank" rel="noreferrer">mark.reinhold@oracle.com</a>> wrote:<br>
>>> <br>
>>> <a href="https://openjdk.org/jeps/459" rel="noreferrer noreferrer" target="_blank">https://openjdk.org/jeps/459</a><br>
>>> <br>
>>> Summary: Enhance the Java programming language with string<br>
>>> templates. String templates complement Java's existing string literals<br>
>>> and text blocks by coupling literal text with embedded expressions and<br>
>>> template processors to produce specialized results. This is a preview<br>
>>> language feature and API.<br>
>>> <br>
>>> - Mark<br>
<br>
</blockquote></div></div></div>