Question about "sourcefile"
Joseph D. Darcy
joe.darcy at oracle.com
Sun Feb 2 10:52:27 UTC 2025
Hi Archie,
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.
HTH,
-Joe
On 1/30/2025 8:18 AM, Archie Cobbs wrote:
> In JavaCompiler.java, there is code that looks like this:
>
> JavaFileObject prev = log.useSource(*env.enclClass.sym.sourcefile !=
> null ?
> env.enclClass.sym.sourcefile :
> env.toplevel.sourcefile*);
> try {
> ... do something ...
> } finally {
> log.useSource(prev);
> }
>
> 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?
>
> Put another way, isn't env.toplevel.sourcefile always the source file
> that corresponds to any class being compiled?
>
> Thanks for any clarifications.
>
> -Archie
>
> --
> Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20250202/c93f72b5/attachment-0001.htm>
More information about the compiler-dev
mailing list