summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authormpociecha <michal.pociecha@gmail.com>2014-11-30 23:08:10 +0100
committermpociecha <michal.pociecha@gmail.com>2014-12-05 01:21:04 +0100
commitdfc5c1d7225163994e3bc1cf67ccbee8c4de75fc (patch)
treee3a670ad49afba61837ae747ed378606407a0129 /src/compiler/scala
parent04620a0e2a0cf64f2d33e32007d85afabad5e201 (diff)
downloadscala-dfc5c1d7225163994e3bc1cf67ccbee8c4de75fc.tar.gz
scala-dfc5c1d7225163994e3bc1cf67ccbee8c4de75fc.tar.bz2
scala-dfc5c1d7225163994e3bc1cf67ccbee8c4de75fc.zip
Create possibility to skip flat classpath caching
There's added -YdisableFlatCpCaching option to ScalaSettings which allows user to disable caching of flat representation of classpath elements.
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala13
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala1
2 files changed, 10 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala b/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
index 6d8c4880d5..dba3c60b0f 100644
--- a/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
+++ b/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
@@ -11,7 +11,7 @@ import scala.tools.nsc.Settings
import FileUtils._
/**
- * A trait providing a cache for classpath entries obtained from zip and jar files.
+ * A trait providing an optional cache for classpath entries obtained from zip and jar files.
* It's possible to create such a cache assuming that entries in such files won't change (at
* least will be the same each time we'll load classpath during the lifetime of JVM process)
* - unlike class and source files in directories, which can be modified and recompiled.
@@ -22,7 +22,14 @@ trait ZipAndJarFileLookupFactory {
private val cache = collection.mutable.Map.empty[AbstractFile, FlatClassPath]
- def create(zipFile: AbstractFile, settings: Settings): FlatClassPath = cache.synchronized {
+ def create(zipFile: AbstractFile, settings: Settings): FlatClassPath = {
+ if (settings.YdisableFlatCpCaching) createForZipFile(zipFile)
+ else createUsingCache(zipFile, settings)
+ }
+
+ protected def createForZipFile(zipFile: AbstractFile): FlatClassPath
+
+ private def createUsingCache(zipFile: AbstractFile, settings: Settings): FlatClassPath = cache.synchronized {
def newClassPathInstance = {
if (settings.verbose || settings.Ylogcp)
println(s"$zipFile is not yet in the classpath cache")
@@ -30,8 +37,6 @@ trait ZipAndJarFileLookupFactory {
}
cache.getOrElseUpdate(zipFile, newClassPathInstance)
}
-
- protected def createForZipFile(zipFile: AbstractFile): FlatClassPath
}
/**
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index e259c543cf..18e639b81c 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -203,6 +203,7 @@ trait ScalaSettings extends AbsScalaSettings
val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.").withDeprecationMessage(removalIn212)
val inferByName = BooleanSetting ("-Yinfer-by-name", "Allow inference of by-name types. This is a temporary option to ease transition. See SI-7899.").withDeprecationMessage(removalIn212)
val YclasspathImpl = ChoiceSetting ("-YclasspathImpl", "implementation", "Choose classpath scanning method.", List(ClassPathRepresentationType.Recursive, ClassPathRepresentationType.Flat), ClassPathRepresentationType.Recursive)
+ val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
val YvirtClasses = false // too embryonic to even expose as a -Y //BooleanSetting ("-Yvirtual-classes", "Support virtual classes")
val YdisableUnreachablePrevention = BooleanSetting("-Ydisable-unreachable-prevention", "Disable the prevention of unreachable blocks in code generation.")