|
1 | 1 | package sbt.internal.inc.bloop.internal |
2 | 2 |
|
3 | 3 | import java.io.File |
| 4 | +import java.nio.file.FileSystem |
| 5 | +import java.nio.file.FileSystems |
4 | 6 | import java.nio.file.Path |
5 | 7 | import java.{util => ju} |
6 | 8 |
|
@@ -75,6 +77,7 @@ final class BloopAnalysisCallback( |
75 | 77 | private[this] val reportedProblems = new mutable.HashMap[Path, mutable.ListBuffer[Problem]] |
76 | 78 | private[this] val mainClasses = new mutable.HashMap[Path, mutable.ListBuffer[String]] |
77 | 79 | private[this] val binaryDeps = new mutable.HashMap[Path, mutable.HashSet[Path]] |
| 80 | + private[this] val binaryDepsZips = new mutable.HashMap[String, FileSystem] |
78 | 81 |
|
79 | 82 | // source file to set of generated (class file, binary class name); only non local classes are stored here |
80 | 83 | private[this] val nonLocalClasses = new mutable.HashMap[Path, mutable.HashSet[(Path, String)]] |
@@ -139,13 +142,28 @@ final class BloopAnalysisCallback( |
139 | 142 | add(intSrcDeps, sourceClassName, InternalDependency.of(sourceClassName, onClassName, context)) |
140 | 143 | } |
141 | 144 |
|
| 145 | + private[this] def safePath(path: Path): Path = |
| 146 | + path.getFileSystem match { |
| 147 | + case fs if fs.getClass.getName == "jdk.nio.zipfs.ZipFileSystem" => |
| 148 | + // The FileSystem of path might be closed when we read path later on, so |
| 149 | + // we try to duplicate it with a FileSystem instance of our own, that we know |
| 150 | + // won't be closed by then. |
| 151 | + val fs0 = binaryDepsZips.getOrElseUpdate( |
| 152 | + fs.toString, |
| 153 | + // Resource management: we let those be closed upon GC… Hope this isn't a problem on Windows… |
| 154 | + FileSystems.newFileSystem(java.nio.file.Paths.get(fs.toString)) |
| 155 | + ) |
| 156 | + fs0.getPath(path.toString) |
| 157 | + case _ => path |
| 158 | + } |
| 159 | + |
142 | 160 | private[this] def externalBinaryDependency( |
143 | 161 | binary: Path, |
144 | 162 | className: String, |
145 | 163 | source: VirtualFileRef |
146 | 164 | ): Unit = { |
147 | | - binaryClassName.put(binary, className) |
148 | | - add(binaryDeps, converter.toPath(source), binary) |
| 165 | + binaryClassName.put(safePath(binary), className) |
| 166 | + add(binaryDeps, converter.toPath(source), safePath(binary)) |
149 | 167 | } |
150 | 168 |
|
151 | 169 | private[this] def externalSourceDependency( |
|
0 commit comments