<div dir="ltr"><div dir="ltr">On Fri, Nov 4, 2022 at 11:27 AM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

  
  <div>
    <font size="4"><font face="monospace">A key aspect of this is identifying what code might be run
        during specific windows of time.  For the window between "super
        call" and "last final field assigned", we are worried about
        final field reads; for the window covering the entire ctor, we
        are worried about broader uses of `this`.</font></font></div></blockquote><div><br></div><div>Good point - they are really two separate aspects of the overall "problem".<br></div><div><br></div><div>So perhaps there are two separate warnings we should be generating, each with their own independent analysis/logic.<br></div><div><br></div><div>Doing this would also allow us to spread the "blame" more equitably.</div><div><br></div><div>So with the FilteredSet example:</div><div><ul><li><span style="font-family:monospace">FilteredSet</span>'s constructor should generate warning A for not assigning <span style="font-family:monospace">this.filter</span> prior to <span style="font-family:monospace">super()</span></li><li><span style="font-family:monospace">HashSet</span>'s constructor should generate warning B for invoking the potentially this-leaking method <span style="font-family:monospace">addAll()</span><br></li></ul></div><div>This sounds like the right logical separation. One confirmation is that correcting <i>either one</i> of the warnings would fix the bug. So each class must be independently contributing to the overall danger level.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><font size="4"><font face="monospace">To your point about "the superclass might downcast", this is
        something you can check for as something questionable to do with
        `this`.<br></font></font></div></blockquote><div><br></div>Agreed - this should also generate warning B, because it represents a possible route for 'this' to escape.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">-Archie<br clear="all"></div><br>-- <br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>