File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -798,8 +798,9 @@ class ClassfileParser(
798
798
Array .empty[Byte ]
799
799
case Some (jar : ZipArchive ) => // We are in a jar
800
800
val jarFile = JarArchive .open(io.File (jar.jpath))
801
- try readTastyForClass(jarFile.jpath.resolve(classfile.path))
802
- finally jarFile.close()
801
+ readTastyForClass(jarFile.jpath.resolve(classfile.path))
802
+ // Do not close the file system as some else might use it later. Once closed it cannot be re-opened.
803
+ // TODO find a way to safly close the file system or ose some other abstraction
803
804
case _ =>
804
805
readTastyForClass(classfile.jpath)
805
806
}
Original file line number Diff line number Diff line change 1
1
package dotty .tools .io
2
2
3
- import java .nio .file .{Files , FileSystem , FileSystems }
3
+ import java .nio .file .{FileSystemAlreadyExistsException , FileSystems }
4
4
5
5
import scala .collection .JavaConverters ._
6
6
@@ -9,7 +9,7 @@ import scala.collection.JavaConverters._
9
9
* that be can used as the compiler's output directory.
10
10
*/
11
11
class JarArchive private (root : Directory ) extends PlainDirectory (root) {
12
- def close () = jpath.getFileSystem().close()
12
+ def close (): Unit = jpath.getFileSystem().close()
13
13
}
14
14
15
15
object JarArchive {
@@ -28,8 +28,12 @@ object JarArchive {
28
28
// https://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html
29
29
val env = Map (" create" -> create.toString).asJava
30
30
val uri = java.net.URI .create(" jar:file:" + path.toAbsolute.path)
31
- val fs = FileSystems .newFileSystem(uri, env)
32
-
31
+ val fs = {
32
+ try FileSystems .newFileSystem(uri, env)
33
+ catch {
34
+ case _ : FileSystemAlreadyExistsException => FileSystems .getFileSystem(uri)
35
+ }
36
+ }
33
37
val root = fs.getRootDirectories().iterator.next()
34
38
new JarArchive (Directory (root))
35
39
}
You can’t perform that action at this time.
0 commit comments