<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi Archie,</p>
    <p>Without actually checking if this is the case, if "sourcefile"
      could also mean the class file a type was constructed from, then
      nested types would have a different sourcefile field than the
      top-level type.<br>
      <br>
      HTH,<br>
    </p>
    <p>-Joe<br>
    </p>
    <div class="moz-cite-prefix">On 1/30/2025 8:18 AM, Archie Cobbs
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CANSoFxsRJ1HGKaufh8bfLom4tLQYpQMnUp4KFQNumUW2fM3pmQ@mail.gmail.com">
      
      <div dir="ltr">
        <div dir="ltr">
          <div>In JavaCompiler.java, there is code that looks like this:<br>
          </div>
          <div><br>
          </div>
          <div><span style="font-family:monospace">       
              JavaFileObject prev = log.useSource(<b>env.enclClass.sym.sourcefile
                != null ?<br>
                                                           
                env.enclClass.sym.sourcefile :<br>
                                                           
                env.toplevel.sourcefile</b>);</span></div>
          <div><span style="font-family:monospace">        try {</span></div>
          <div><span style="font-family:monospace">            ... do
              something ...<br>
            </span></div>
          <div><span style="font-family:monospace">        } finally {<br>
            </span></div>
          <div><span style="font-family:monospace">           
              log.useSource(prev);<br>
            </span></div>
          <div><span style="font-family:monospace">        }</span></div>
          <div><br>
          </div>
          <div>I don't understand why the boldface part is needed. How
            would it ever be possible for a class A to have an enclosing
            class B that exists in a different source file?</div>
          <div><br>
          </div>
          <div>Put another way, isn't <span style="font-family:monospace">env.toplevel.sourcefile</span>
            always the source file that corresponds to any class being
            compiled?<br>
          </div>
          <div><br>
          </div>
          <div>Thanks for any clarifications.</div>
          <div><br>
          </div>
          <div>-Archie<br>
          </div>
          <div><br>
          </div>
          <span class="gmail_signature_prefix">-- </span><br>
          <div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Archie L. Cobbs<br>
          </div>
        </div>
      </div>
    </blockquote>
  </body>
</html>