summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala2
-rw-r--r--src/compiler/scala/tools/nsc/io/File.scala8
-rw-r--r--src/compiler/scala/tools/nsc/io/Path.scala10
-rw-r--r--src/compiler/scala/tools/nsc/io/package.scala11
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala35
5 files changed, 26 insertions, 40 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index 6e05234892..f8d5f74f50 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -615,7 +615,7 @@ class Scalac extends ScalaMatchingTask with ScalacShared {
file
}
- val res = execWithArgFiles(java, List(writeSettings.getCanonicalPath))
+ val res = execWithArgFiles(java, List(writeSettings.getAbsolutePath))
if (failonerror && res != 0)
buildError("Compilation failed because of an internal compiler error;"+
" see the error output for details.")
diff --git a/src/compiler/scala/tools/nsc/io/File.scala b/src/compiler/scala/tools/nsc/io/File.scala
index 7086c65ea3..cc512493d9 100644
--- a/src/compiler/scala/tools/nsc/io/File.scala
+++ b/src/compiler/scala/tools/nsc/io/File.scala
@@ -17,14 +17,14 @@ import java.nio.channels.{ Channel, FileChannel }
import scala.io.Codec
object File {
- def pathSeparator = JFile.pathSeparator
- def separator = JFile.separator
+ def pathSeparator = java.io.File.pathSeparator
+ def separator = java.io.File.separator
def apply(path: Path)(implicit codec: Codec) = new File(path.jfile)(codec)
// Create a temporary file, which will be deleted upon jvm exit.
def makeTemp(prefix: String = Path.randomPrefix, suffix: String = null, dir: JFile = null) = {
- val jfile = JFile.createTempFile(prefix, suffix, dir)
+ val jfile = java.io.File.createTempFile(prefix, suffix, dir)
jfile.deleteOnExit()
apply(jfile)
}
@@ -48,7 +48,7 @@ object File {
//
// try {
// import Streamable.closing
- // val tmp = JFile.createTempFile("bug6503430", null, null)
+ // val tmp = java.io.File.createTempFile("bug6503430", null, null)
// try closing(new FileInputStream(tmp)) { in =>
// val inc = in.getChannel()
// closing(new FileOutputStream(tmp, true)) { out =>
diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala
index 86839437f4..498cb1caec 100644
--- a/src/compiler/scala/tools/nsc/io/Path.scala
+++ b/src/compiler/scala/tools/nsc/io/Path.scala
@@ -65,9 +65,9 @@ object Path {
def onlyFiles(xs: Iterator[Path]): Iterator[File] = xs filter (_.isFile) map (_.toFile)
def onlyFiles(xs: List[Path]): List[File] = xs filter (_.isFile) map (_.toFile)
- def roots: List[Path] = JFile.listRoots().toList map Path.apply
+ def roots: List[Path] = java.io.File.listRoots().toList map Path.apply
- def apply(segments: Seq[String]): Path = apply(segments mkString JFile.separator)
+ def apply(segments: Seq[String]): Path = apply(segments mkString java.io.File.separator)
def apply(path: String): Path = apply(new JFile(path))
def apply(jfile: JFile): Path =
if (jfile.isFile) new File(jfile)
@@ -84,8 +84,8 @@ import Path._
* semantics regarding how a Path might relate to the world.
*/
class Path private[io] (val jfile: JFile) {
- val separator = JFile.separatorChar
- val separatorStr = JFile.separator
+ val separator = java.io.File.separatorChar
+ val separatorStr = java.io.File.separator
// Validation: this verifies that the type of this object and the
// contents of the filesystem are in agreement. All objects are
@@ -130,7 +130,7 @@ class Path private[io] (val jfile: JFile) {
// identity
def name: String = jfile.getName()
def path: String = jfile.getPath()
- def normalize: Path = Path(jfile.getCanonicalPath())
+ def normalize: Path = Path(jfile.getAbsolutePath())
def isRootPath: Boolean = roots exists (_ isSame this)
def resolve(other: Path) = if (other.isAbsolute || isEmpty) other else /(other)
diff --git a/src/compiler/scala/tools/nsc/io/package.scala b/src/compiler/scala/tools/nsc/io/package.scala
index 29174b161f..565a3d4bcb 100644
--- a/src/compiler/scala/tools/nsc/io/package.scala
+++ b/src/compiler/scala/tools/nsc/io/package.scala
@@ -11,16 +11,7 @@ import java.util.jar.{ Attributes }
package object io {
type JManifest = java.util.jar.Manifest
- private[io] type JFile = java.io.File
- // grimly bulldozing through #4338
- private[io] object JFile {
- import java.io.{ File => JJFile } // the irony of JFile being ambiguous is not overlooked
- val createTempFile = JJFile.createTempFile(_: String, _: String, _: JFile)
- def pathSeparator = JJFile.pathSeparator
- def separator = JJFile.separator
- def separatorChar = JJFile.separatorChar
- def listRoots() = JJFile.listRoots()
- }
+ type JFile = java.io.File
private[io] implicit def installManifestOps(m: JManifest) = new ManifestOps(m)
class ManifestOps(manifest: JManifest) {
def attrs = manifest.getMainAttributes()
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 2b3aa8696c..23b53fb29f 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -165,7 +165,7 @@ object ClassPath {
class JavaContext extends ClassPathContext[AbstractFile] {
def toBinaryName(rep: AbstractFile) = {
val name = rep.name
- assert(name.length > 6 && name.substring(name.length - 6) == ".class", name)
+ assert(endsClass(name), name)
name.substring(0, name.length - 6)
}
def newClassPath(dir: AbstractFile) = new DirectoryClassPath(dir, this)
@@ -175,16 +175,18 @@ object ClassPath {
override def isValidName(name: String) = !isTraitImplementation(name)
}
+ @inline private def endsClass(s: String) = s.length > 6 && s.substring(s.length - 6) == ".class"
+ @inline private def endsScala(s: String) = s.length > 6 && s.substring(s.length - 6) == ".scala"
+ @inline private def endsJava(s: String) = s.length > 5 && s.substring(s.length - 5) == ".java"
+
/** From the source file to its identifier.
*/
def toSourceName(f: AbstractFile): String = {
val name = f.name
- if (name.length > 6 && name.substring(name.length - 6) == ".scala")
- name.substring(0, name.length - 6)
- else if (name.length > 5 && name.substring(name.length - 5) == ".java")
- name.substring(0, name.length - 5)
- else
- throw new FatalError("Unexpected source file ending: " + name)
+
+ if (endsScala(name)) name.substring(0, name.length - 6)
+ else if (endsJava(name)) name.substring(0, name.length - 5)
+ else throw new FatalError("Unexpected source file ending: " + name)
}
}
import ClassPath._
@@ -259,10 +261,9 @@ abstract class ClassPath[T] {
/** Filters for assessing validity of various entities.
*/
- def validClassFile(name: String) = (name endsWith ".class") && context.isValidName(name)
- def validPackage(name: String) = (name != "META-INF") && (name != "") && (name(0) != '.')
- def validSourceFile(name: String) = validSourceExtensions exists (name endsWith _)
- def validSourceExtensions = List(".scala", ".java")
+ def validClassFile(name: String) = endsClass(name) && context.isValidName(name)
+ def validPackage(name: String) = (name != "META-INF") && (name != "") && (name.charAt(0) != '.')
+ def validSourceFile(name: String) = endsScala(name) || endsJava(name)
/**
* Find a ClassRep given a class name of the form "package.subpackage.ClassName".
@@ -291,7 +292,7 @@ abstract class ClassPath[T] {
case x: ClassPath[_] => this.sortString == x.sortString
case _ => false
}
- override def hashCode = sortString.##
+ override def hashCode = sortString.hashCode()
}
/**
@@ -300,10 +301,7 @@ abstract class ClassPath[T] {
class SourcePath[T](dir: AbstractFile, val context: ClassPathContext[T]) extends ClassPath[T] {
def name = dir.name
override def origin = dir.underlyingSource map (_.path)
- def asURLs = dir.file match {
- case null => Nil
- case file => File(file).toURL :: Nil
- }
+ def asURLs = if (dir.file == null) Nil else List(dir.toURL)
def asClasspathString = dir.path
val sourcepaths: IndexedSeq[AbstractFile] = IndexedSeq(dir)
@@ -329,10 +327,7 @@ class SourcePath[T](dir: AbstractFile, val context: ClassPathContext[T]) extends
class DirectoryClassPath(val dir: AbstractFile, val context: ClassPathContext[AbstractFile]) extends ClassPath[AbstractFile] {
def name = dir.name
override def origin = dir.underlyingSource map (_.path)
- def asURLs = dir.file match {
- case null => Nil
- case file => File(file).toURL :: Nil
- }
+ def asURLs = if (dir.file == null) Nil else List(dir.toURL)
def asClasspathString = dir.path
val sourcepaths: IndexedSeq[AbstractFile] = IndexedSeq()