<div dir="ltr"><div dir="ltr">Hi Nathan,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 30, 2022 at 1:04 PM Nathan Reynolds <<a href="mailto:numeralnathan@gmail.com">numeralnathan@gmail.com</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"><div dir="ltr"><div>
Let's say we have a constructor that calls final methods (or the class is final) that belong to
the class and don't leak "this" (or call other final methods that don't leak "this"). Would this be flagged?</div></div></blockquote><div><br></div><div>No, this would not be reported as a leak. It has to be possible that the class being analyzed could, somehow, somewhere, someday, be subclassed in some other compilation unit.</div><div><br></div><div>Also, the constructor would have to be invokable by such a subclass. So private constructors cannot leak directly. They can leak indirectly, however, if invoked from other constructors.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Let's say we have a constructor that assigns all the member fields and then leaks "this". Would this be flagged? If so, why? This doesn't seem to be a leak any more since the object is fully constructed.<br></div></blockquote><div><br></div><div>Yes, this would be flagged. The reason is that the "leak" is defined not in terms of the class being analyzed, but in terms of some theoretical subclass. In your example, even if the fields in the class being analyzed are fully initialized before the leak, no fields in a subclass could be, so from the subclass' perspective the leak still represents a threat.<br></div><div><br></div><div>-Archie<br clear="all"></div></div><br>-- <br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>