Skip to content

Commit

Permalink
[compiler] Avoid computing zinc stamps for JDK 9+ module .sig files/p…
Browse files Browse the repository at this point in the history
…aths #SCL-22939 fixed

- These paths really do not like being accessed through the regular Java IO means, throwing ClosedFileSystemException instances when accessed concurrently, like we do in the Scala compile server.
- sbt/zinc#1383
  • Loading branch information
vasilmkd committed Nov 26, 2024
1 parent d36d8b2 commit f8584d6
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
package org.jetbrains.jps.incremental.scala.local.zinc

import sbt.internal.inc.{PlainVirtualFileConverter, Stamps}
import xsbti.compile.analysis.ReadStamps
import sbt.internal.inc.{FarmHash, PlainVirtualFileConverter, Stamper, Stamps}
import xsbti.VirtualFileRef
import xsbti.compile.analysis.{ReadStamps, Stamp}

private[local] object StampReader {
val Instance: ReadStamps = Stamps.timeWrapBinaryStamps(PlainVirtualFileConverter.converter)

private def avoidSigs(ref: VirtualFileRef): Stamp = {
if (ref.id.endsWith(".sig")) {
val path = PlainVirtualFileConverter.converter.toPath(ref)
if (path.getClass.getName == "jdk.nio.zipfs.ZipPath")
return FarmHash.fromLong(path.##.toLong)
}
fallback(ref)
}

private def fallback(ref: VirtualFileRef): Stamp =
Stamper.forHashInRootPaths(PlainVirtualFileConverter.converter).apply(ref)

private val uncached: ReadStamps = Stamps.uncachedStamps(
avoidSigs,
Stamper.forContentHash,
avoidSigs
)

val Instance: ReadStamps = Stamps.timeWrapBinaryStamps(uncached, PlainVirtualFileConverter.converter)
}

0 comments on commit f8584d6

Please sign in to comment.