[m-rev.] for review: add missing prereqs for .class files
Zoltan Somogyi
zoltan.somogyi at runbox.com
Fri Sep 26 15:53:24 AEST 2025
On Fri, 26 Sep 2025 15:16:26 +1000, Julien Fischer <jfischer at opturion.com> wrote:
> There's an overview of Java compilation here:
> <https://openjdk.org/groups/compiler/doc/compilation-overview/index.html>
Thanks for that.
The relevant part of the introduction seems to be this:
Finally, the syntax trees created by the parser are analyzed
and translated into class files. During the course of the analysis,
references to additional classes may be found. The compiler will
check the source and class path for these classes; if they are found
on the source path, those files will be compiled as well, although
they will not be subject to annotation processing.
Without this diff, it seems javac was not finding the "additional classes",
which is why it failed. With this diff, this failure does not happen.
That's fine. What is not fine is that this says those additional classes
will also be compiled, which seems to me to be crazy. It means that
if you have a utility module (call it module_u), and a bunch of modules
(module_a, module_b, ... module_t) that all use module_u, then there
can be no separate compilation for any module except module_u,
because every time you compile e.g. module_c, module_u gets
compiled as well.
The upshot is that if you have a large project with many modules,
and some of them have changed, your automatic build tool
is leaving a LOT of performance on the table if it attempts to recompile
each changed module individually, because you can avoid redundant
codegen only if you compile all the changed modules in one invocation
of javac.
I skimmed the long detailed description that follows the introduction,
and it seems to neither confirm or deny the above. Specifically,
the item "Gen" talks about generating "code for methods", but without
specifying *which* methods. Is it just the methods in the .java files
that were originally passed to it, or does it include all the .java files
on the ToDo list, which includes the "additional classes"?
I wonder whether Oracle intentionally obfuscates their public documentation
in order to sell more consulting services :-(
Zoltan.
More information about the reviews
mailing list