sbt / zinc

Scala incremental compiler library, used by sbt and other build tools
Apache License 2.0
334 stars 121 forks source link

Use a repeatable hash code for empty files #1366

Closed szeiger closed 4 months ago

szeiger commented 4 months ago

The current emptyStampCode is a system identity hash code that changes between runs in different JVMs or ClassLoaders. This leads to unnecessary invalidations, especially when you use ConsistentAnalysisFormat and expect to get identical outputs for identical inputs. Since it is chosen arbitrarily, there is no reason not to hard-code an arbitrary value to get repeatable outputs.

(In our Bazel-based Scala tooling we currently use a copy of ClasspathCache with this fix which is wired into the build via ExternalHooks.Lookup, which adds a lot of boilerplate for such a small change.)