Integrated: 8345942: Separate source output from class output when building microbenchmarks

Jan Lahoda jlahoda at openjdk.org
Tue Dec 17 12:34:40 UTC 2024


On Fri, 13 Dec 2024 05:46:28 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> The microbenchmarks build generates a considerable amount of (generated) sources using an annotation processor. This, by itself, is not a problem. But, it generates them into the class output, and after the microbenchmarks build has been updated to be (somewhat) incremental, the class output has been added to the classpath(*):
> https://github.com/openjdk/jdk/commit/b704bfa205bbd8c56f128ce5d727d40c8a3ec613
> 
> Then when the AP attempts to generate a new file (for a class name), javac will look for same-named classes on the classpath, and may load the source code generated by a previous rounds of builds, in case of an incremental build. And since the AP generates the considerable amount of these files, this leads to loading a considerable amounts of source code, eventually leading to memory problems ([JDK-8345302](https://bugs.openjdk.org/browse/JDK-8345302)).
> 
> The proposal herein is to split the (generated) source output from the class output. This considerably reduces the amount of memory javac uses, and generally seems like a good approach for the build.
> 
> (*) adding the class output to the classpath is usually needed when incrementally compiling code in the unnamed module, to ensure that if e.g. only one source file is being compiled, it can refer to other, already produced, classes. As a side note, this does not need to be done in named-module compilation modes, as javac automatically reads the class output when compiling the named modules. But it is not easily possible to enhance javac to do that for unnamed module, due to compatibility concerns.

This pull request has now been integrated.

Changeset: 99af595f
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/99af595fe08b374f31c9d6916f3563ba51e4b11e
Stats:     3 lines in 1 file changed: 2 ins; 0 del; 1 mod

8345942: Separate source output from class output when building microbenchmarks

Reviewed-by: shade, erikj

-------------

PR: https://git.openjdk.org/jdk/pull/22731


More information about the build-dev mailing list