summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-18 18:23:14 +0000
committerPaul Phillips <paulp@improving.org>2011-03-18 18:23:14 +0000
commitf3b970b28cf640904fe0d340f9eb7de37514cb67 (patch)
treeb5e77b7b78ec8743c8e4e0131cc7af4eb5611f7c /src/library
parentd5d7953ab4c31b4f58f51b530ca82603f9e59b94 (diff)
downloadscala-f3b970b28cf640904fe0d340f9eb7de37514cb67.tar.gz
scala-f3b970b28cf640904fe0d340f9eb7de37514cb67.tar.bz2
scala-f3b970b28cf640904fe0d340f9eb7de37514cb67.zip
Accumulated work on fsc.
adds the following new options. -ipv4 Use IPv4 rather than IPv6 for the server socket absolute-cp Make -classpath elements absolute paths before sending to server max-idle -Set idle timeout in minutes for fsc (use 0 for no timeout) My question marks are what are the right defaults for the first two. Former behavior is to absolutize the classpath always and never prefer IPv4 sockets. I changed the default to not absolutize the classpath, with the option if you need it; I left the system default in place for the socket creation, but I have a feeling we should default to IPv4. My only hesitation is that the only way to request an IPv4 socket from java involves mutating a global system property. (Robustness FTW.) So for now, you have to give -ipv4. Closes #3626, #3785, #3788, #3789. Review by community.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/sys/BooleanProp.scala7
-rw-r--r--src/library/scala/sys/Prop.scala4
-rw-r--r--src/library/scala/sys/PropImpl.scala6
-rw-r--r--src/library/scala/sys/SystemProperties.scala14
4 files changed, 26 insertions, 5 deletions
diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala
index e598d81307..85719103de 100644
--- a/src/library/scala/sys/BooleanProp.scala
+++ b/src/library/scala/sys/BooleanProp.scala
@@ -31,7 +31,11 @@ trait BooleanProp extends Prop[Boolean] {
object BooleanProp {
private[sys]
class BooleanPropImpl(key: String, valueFn: String => Boolean) extends PropImpl(key, valueFn) with BooleanProp {
- def enable() = this set "true"
+ override def setValue[T1 >: Boolean](newValue: T1): Boolean = newValue match {
+ case x: Boolean if !x => val old = value ; clear() ; old
+ case x => super.setValue(newValue)
+ }
+ def enable() = this setValue true
def disable() = this.clear()
def toggle() = if (value) disable() else enable()
}
@@ -39,6 +43,7 @@ object BooleanProp {
class ConstantImpl(val key: String, val value: Boolean) extends BooleanProp {
val isSet = value
def set(newValue: String) = "" + value
+ def setValue[T1 >: Boolean](newValue: T1): Boolean = value
def get: String = "" + value
val clear, enable, disable, toggle = ()
protected def zero = false
diff --git a/src/library/scala/sys/Prop.scala b/src/library/scala/sys/Prop.scala
index e3cbd4e515..de38a56c73 100644
--- a/src/library/scala/sys/Prop.scala
+++ b/src/library/scala/sys/Prop.scala
@@ -43,6 +43,10 @@ trait Prop[+T] {
*/
def set(newValue: String): String
+ /** Sets the property with a value of the represented type.
+ */
+ def setValue[T1 >: T](value: T1): T
+
/** Gets the current string value if any. Will not return null: use
* `isSet` to test for existence.
* @return the current string value if any, else the empty string
diff --git a/src/library/scala/sys/PropImpl.scala b/src/library/scala/sys/PropImpl.scala
index 55073c35d3..888e9d7327 100644
--- a/src/library/scala/sys/PropImpl.scala
+++ b/src/library/scala/sys/PropImpl.scala
@@ -20,6 +20,12 @@ private[sys] class PropImpl[+T](val key: String, valueFn: String => T) extends P
underlying(key) = newValue
old
}
+ def setValue[T1 >: T](newValue: T1): T = {
+ val old = value
+ if (newValue == null) set(null)
+ else set("" + newValue)
+ old
+ }
def get: String =
if (isSet) underlying.getOrElse(key, "")
else ""
diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala
index 7c6286516b..228ca6315e 100644
--- a/src/library/scala/sys/SystemProperties.scala
+++ b/src/library/scala/sys/SystemProperties.scala
@@ -48,9 +48,14 @@ class SystemProperties extends mutable.Map[String, String] {
* }}}
*/
object SystemProperties {
+ /** An unenforceable, advisory only place to do some synchronization when
+ * mutating system properties.
+ */
+ def exclusively[T](body: => T) = this synchronized body
+
implicit def systemPropertiesToCompanion(p: SystemProperties): SystemProperties.type = this
private lazy val propertyHelp = mutable.Map[String, String]()
- private def bool(key: String, helpText: String) = {
+ private def bool(key: String, helpText: String): BooleanProp = {
val prop = (
if (key startsWith "java.") BooleanProp.valueIsTrue(key)
else BooleanProp.keyExists(key)
@@ -63,8 +68,9 @@ object SystemProperties {
// Todo: bring some sanity to the intersection of system properties aka "mutable
// state shared by everyone and everything" and the reality that there is no other
// mechanism for accomplishing some things on the jvm.
- lazy val headless = bool("java.awt.headless", "system should not utilize a display device")
- lazy val preferIPv4 = bool("java.net.preferIPv4Stack", "system should prefer IPv4 sockets")
- lazy val noTraceSupression = bool("scala.control.no-trace-suppression", "scala should not suppress any stack trace creation")
+ lazy val headless = bool("java.awt.headless", "system should not utilize a display device")
+ lazy val preferIPv4Stack = bool("java.net.preferIPv4Stack", "system should prefer IPv4 sockets")
+ lazy val preferIPv6Addresses = bool("java.net.preferIPv6Addresses", "system should prefer IPv6 addresses")
+ lazy val noTraceSupression = bool("scala.control.noTraceSuppression", "scala should not suppress any stack trace creation")
}