File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
src/reflect/scala/reflect/io Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
101
101
new PlainFile (givenPath / name)
102
102
}
103
103
104
- private [scala] class PlainNioFile (nioPath : java.nio.file.Path ) extends AbstractFile {
104
+ final class PlainNioFile (val nioPath : java.nio.file.Path ) extends AbstractFile {
105
105
import java .nio .file ._
106
106
107
107
assert(nioPath ne null )
@@ -115,7 +115,29 @@ private[scala] class PlainNioFile(nioPath: java.nio.file.Path) extends AbstractF
115
115
116
116
override lazy val canonicalPath = super .canonicalPath
117
117
118
- override def underlyingSource = Some (this )
118
+ override def underlyingSource = {
119
+ val fileSystem = nioPath.getFileSystem
120
+ fileSystem.provider().getScheme match {
121
+ case " jar" =>
122
+ val fileStores = fileSystem.getFileStores.iterator()
123
+ if (fileStores.hasNext) {
124
+ val jarPath = fileStores.next().name
125
+ try {
126
+ Some (new PlainNioFile (Paths .get(jarPath.stripSuffix(fileSystem.getSeparator))))
127
+ } catch {
128
+ case _ : InvalidPathException =>
129
+ None
130
+ }
131
+ } else None
132
+ case " jrt" =>
133
+ if (nioPath.getNameCount > 2 && nioPath.startsWith(" /modules" )) {
134
+ // TODO limit this to OpenJDK based JVMs?
135
+ val moduleName = nioPath.getName(1 )
136
+ Some (new PlainNioFile (Paths .get(System .getProperty(" java.home" ), " jmods" , moduleName.toString + " .jmod" )))
137
+ } else None
138
+ case _ => None
139
+ }
140
+ }
119
141
120
142
private val fpath = nioPath.toAbsolutePath.toString
121
143
You can’t perform that action at this time.
0 commit comments