<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=utf-8">
<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:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#467886;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@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="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi Ethan,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks for your feedback! I’ve created JBS issue
<a href="https://bugs.openjdk.org/browse/JDK-8370687">https://bugs.openjdk.org/browse/JDK-8370687</a> to track improving this error message.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Lois<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div><br>
<p style="font-family:Calibri;font-size:10pt;color:#000000;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
Confidential – Oracle Internal<br>
</p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">valhalla-dev <valhalla-dev-retn@openjdk.org> on behalf of Ethan McCue <ethan@mccue.dev><br>
<b>Date: </b>Saturday, October 25, 2025 at 11:13</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span><span style="font-size:12.0pt;color:black">PM<br>
<b>To: </b>valhalla-dev@openjdk.org <valhalla-dev@openjdk.org><br>
<b>Subject: </b>Calling instance method from value class constructor is a little confusing<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">Just a note from playing with the EA build. Minimal example:<br>
<br>
</span><span style="font-size:12.0pt;font-family:"Courier New"">import java.util.ArrayList;</span><span style="font-size:12.0pt"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Courier New"">value class HittableList2 {</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> private final ArrayList<Object> objects</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> = new ArrayList<>();</span><span style="font-size:12.0pt"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> HittableList2() {}</span><span style="font-size:12.0pt"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> HittableList2(Object object) {</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> add(object);</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> }</span><span style="font-size:12.0pt"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> void add(Object object) {</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> objects.add(object);</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> }</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New"">}</span><span style="font-size:12.0pt"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif">This gives the error <br>
<br>
</span><span style="font-size:12.0pt;font-family:"Courier New"">/Users/emccue/Development/raytracer/src/HittableList2.java:10: error: cannot reference add(Object) before constructor has been called</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> add(object);</span><span style="font-size:12.0pt"><br>
</span><span style="font-size:12.0pt;font-family:"Courier New""> ^</span><span style="font-size:12.0pt"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif">I know this means the superclass's constructor (and that I need to put an explicit
</span><span style="font-size:12.0pt;font-family:"Courier New"">super()</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif"> at the top of the method), but reading that straight "cannot reference ... before constructor has been called - I'm
in the constructor!"</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>