On Fri, 13 Dec 2024 05:46:28 GMT, Jan Lahoda <jlah...@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.

Marked as reviewed by erikj (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/22731#pullrequestreview-2502373685

Reply via email to