<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Dec 30, 2022, at 12:20 PM, Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com" class="">archie.cobbs@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">On Fri, Dec 30, 2022 at 10:48 AM Brian Goetz <<a href="mailto:brian.goetz@oracle.com" class="">brian.goetz@oracle.com</a>> wrote:</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 style="overflow-wrap: break-word;" class="">One thing that makes me a little uncomfortable is that @SW usually is used to say “the compiler can’t prove this is safe, but I am asserting it is.”  But this is different; the compiler has discovered the class
 is unsafe, and @SW is saying “I know, I know, stop telling me.”  So I think there’s an additional documentation opportunity here where, for the classes we had to annotate with @SW, we include an additional @apiNote of the form “This class behaves badly, oops”,
 with a link to a common doc page explaining the problem.  (While we don’t have to do this necessarily immediately, the chance of it falling on the floor if we don’t are higher.). Basically, what you’ve identified is that there are a  number of classes in the
 JDK which fail to follow best practices with regard to self-use from constructors.  We can’t turn back the clock, but we can mark these as “don’t code like my brother”, so people see these patterns of coding and realize they are not to be emulated.
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Good point.</div>
<div class=""><br class="">
</div>
<div class="">I think it's also worth considering which scenarios require such documentation. We have drawn the "boundary lines" at the compilation unit boundary, but this means (for example) there are package-private classes that generate warnings. Because
 these classes will end up in a module, which requires special effort to crack open, the warnings only really apply to JDK developers working in that same package.<br class="">
</div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>For package-private classes, we should know all the subclasses, and therefore may have the opportunity to seal it.  Then we are not subject to “arbitrary subclass might do X”, but only “these specific subclasses do X.”  So perhaps this is an opportunity
 to make final / seal some package-private classes that don’t need extensibility.</div>
<br class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<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 style="overflow-wrap: break-word;" class="">
<div class=""><br class="">
I also see in the code that there are two separate categories, LeakingThisInConstructor and this-escape; what’s the difference?</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Great question. I was surprised to stumble across existing code with
<span style="font-family:monospace" class=""><a class="gmail_plusreply" id="plusReplyChip-5">@SuppressWarnings("LeakingThisInConstructor")</a></span> annotations.</div>
<div class=""><br class="">
</div>
<div class="">From what I can tell, these are leftovers from about 10 years ago when some developers were using NetBeans, which had just such a warning. I don't think they are relevant any more but I didn't want to presume anything so I left them in there.</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>So, LTIC is not a lint category of javac?  When Jan gets back from break, maybe he can shed some more light on this.  But unless we have a good reason to keep the LTICs, we should consider garbage-collecting them.  </div>
<br class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_quote">
<div class="">Thinking about them more, we should probably just replace them because otherwise they will just continue to confuse...</div>
<div class=""><br class="">
</div>
<div class="">-Archie<br class="">
</div>
<div class=""><br class="">
</div>
</div>
-- <br class="">
<div dir="ltr" class="gmail_signature">Archie L. Cobbs<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>