Incremental compilation behavior question

Hi,

I am trying to understand how well incremental compilation can apply to a large Java project which uses many static public constants. This is the following behavior I am seeing, and I’d like to know if this is expected

  1. A clean build compiles ~12k classes
  2. I change a single public static constant to private in a class referenced in many places in the code
  3. The incremental compilation kicks in but ~7k classes are compiled

The class I make the change to in step 2 is referenced in about 100 classes not 7k. However, those ~100 classes reference other classes that also have public static constants.

I am surprised by the high number of classes still being compiled after a one line change. It appears that all classes with public static constants are recompiled regardless of their relationship to the changed file/class. Is this a correct understanding? And if so is there any future improvements coming in this area?

Sounds very similar to https://github.com/gradle/gradle/issues/6482

TLDR; Constants can be inlined by the compiler, which makes tracking their dependent classes problematic and results in full source set recompiles.

Yes, I came across this issue. So basically this means that any recompilation requires compiling all files that include a public constant regardless of the code changes since the last compile?