<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Menlo;
panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";
mso-ligatures:none;}
p.p1, li.p1, div.p1
{mso-style-name:p1;
margin:0in;
font-size:8.5pt;
font-family:Menlo;
color:black;}
span.s1
{mso-style-name:s1;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi team,<o:p></o:p></p>
<p class="MsoNormal">Reading the JEP 459 spec, I see this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The static members <code><span style="font-size:10.0pt">STR</span></code> and
<code><span style="font-size:10.0pt">RAW</span></code> declared in the predefined interface
<code><span style="font-size:10.0pt">StringTemplate</span></code>, as if the declarations
<code><span style="font-size:10.0pt">import static java.lang.StringTemplate.STR;</span></code> and
<code><span style="font-size:10.0pt">import static java.lang.StringTemplate.RAW;</span></code> appeared at the beginning of each compilation unit immediately after any
<code><span style="font-size:10.0pt">package</span></code> declaration.<o:p></o:p></p>
<p class="MsoNormal">As a result, the names of all <strong><span style="font-family:"Calibri",sans-serif">implicitly imported</span></strong> <strong><span style="font-family:"Calibri",sans-serif">classes, interfaces and static fields</span></strong> are
available as simple names in every compilation unit.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So, I assume this should work:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-ligatures:none">package
</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none">test</span><span style="font-size:10.0pt;font-family:"Courier New";color:#080808;mso-ligatures:none">;<br>
<br>
</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-ligatures:none">public class
</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none">Example
</span><span style="font-size:10.0pt;font-family:"Courier New";color:#080808;mso-ligatures:none">{<br>
<br>
</span><span style="font-size:10.0pt;font-family:"Courier New";color:#0033B3;mso-ligatures:none">public static void
</span><span style="font-size:10.0pt;font-family:"Courier New";color:#00627A;mso-ligatures:none">main</span><span style="font-size:10.0pt;font-family:"Courier New";color:#080808;mso-ligatures:none">(</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-ligatures:none">String
</span><span style="font-size:10.0pt;font-family:"Courier New";color:#080808;mso-ligatures:none">argv[]) {<o:p></o:p></span></p>
<pre style="background:white"><span style="color:#0033B3"> int </span><span style="color:black">a </span><span style="color:#080808">= </span><span style="color:#1750EB">1</span><span style="color:#080808">;<br> </span><span style="color:black">StringTemplate raw </span><span style="color:#080808">= RAW.</span><span style="color:#067D17">"<span style="background:#FFCCCC">\{</span>a}"</span><span style="color:#080808">;<br> }<br>}<o:p></o:p></span></pre>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal">But I get <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="p1"><span class="s1">java:7: error: cannot find symbol</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">StringTemplate raw = RAW."\{a + b}";</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span>
<span class="s1">^</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">symbol:
</span><span class="apple-converted-space"> </span><span class="s1">variable RAW</span><o:p></o:p></p>
<p class="p1"><span class="apple-converted-space"> </span><span class="s1">location: class Example</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="p1"><span class="s1">java --version</span><o:p></o:p></p>
<p class="p1"><span class="s1">java 22-internal 2024-03-19</span><o:p></o:p></p>
<p class="p1"><span class="s1">Java(TM) SE Runtime Environment (build 22-internal-2023-11-03-1839366.james.laskey.open)</span><o:p></o:p></p>
<p class="p1"><span class="s1">Java HotSpot(TM) 64-Bit Server VM (build 22-internal-2023-11-03-1839366.james.laskey.open, mixed mode, sharing)</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This code compiles if I add a static import <code><span style="font-size:10.0pt">import static java.lang.StringTemplate.RAW;<o:p></o:p></span></code></p>
<p class="MsoNormal">STR is available through static import, so it’s only RAW that causes issues.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Could it be a bug in JDK?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you,<o:p></o:p></p>
<p class="MsoNormal">Ella Ananeva<o:p></o:p></p>
</div>
</body>
</html>