<div dir="ltr"><div>Hi Stephan,</div><div><br></div><div>We were conservative in choosing which subclasses should be considered possible "victims" in a this-escape scenario. This was done to help avoid false positives.</div><div><br></div><div>Specifically, classes in the same package are assumed to be "in the know" with respect to the leaking superclass and so we don't worry about them being "victims".</div><div><br></div><div>To put that in concrete terms: If you change your constructor Y() to be protected then you will get the warning. When it's package-only access, the compiler assumes it's not possible for there to be a true "victim".</div><div><br></div><div>There are some notes to this effect at the top of ThisEscapeAnalyzer.java.</div><div><br></div><div>-Archie</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Apr 22, 2025 at 1:59 PM Stephan Herrmann <<a href="mailto:stephan.herrmann@berlin.de">stephan.herrmann@berlin.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Just now and by chance I found <a href="https://bugs.openjdk.org/browse/JDK-8015831" rel="noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8015831</a><br>
<br>
I tried to provoke this warning in the most obvious way I could think of:<br>
<br>
public class Y {<br>
Y() {<br>
m();<br>
}<br>
void m() {}<br>
}<br>
<br>
public class X extends Y {<br>
String s = "Hello";<br>
@Override void m() {<br>
System.out.print(s);<br>
}<br>
public static void main(String... args) {<br>
System.out.print(new X().s);<br>
}<br>
}<br>
<br>
Much to my surprise javac -Xlint:all keeps quiet (all recent versions).<br>
<br>
Running java X of course demonstrates that s is read before its initialization, <br>
exactly for that reason that Y() invokes an overridable method.<br>
<br>
Where can I learn about the rules behind this validation?<br>
<br>
thanks,<br>
Stephan<br>
<br>
<br>
<br>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div>