From 257a1845d3db3477a0b5939e94d77b0495d89561 Mon Sep 17 00:00:00 2001 From: mihaylov Date: Wed, 1 Nov 2006 16:03:28 +0000 Subject: Refactored portability support --- src/library/scala/Application.scala | 11 +++-- src/library/scala/Array.scala | 6 ++- src/library/scala/Console.scala | 14 +++--- src/library/scala/Iterable.scala | 2 +- src/library/scala/Iterator.scala | 1 - src/library/scala/List.scala | 3 -- src/library/scala/NotDefinedError.scala | 6 ++- src/library/scala/Option.scala | 3 +- src/library/scala/Predef.scala | 42 +++++++++++------ src/library/scala/Seq.scala | 2 +- src/library/scala/Stream.scala | 2 +- src/library/scala/collection/Map.scala | 2 +- .../scala/collection/immutable/ListMap.scala | 2 +- .../scala/collection/immutable/ListSet.scala | 2 +- src/library/scala/collection/immutable/Queue.scala | 2 +- src/library/scala/collection/immutable/Stack.scala | 2 +- src/library/scala/collection/immutable/Tree.scala | 2 +- src/library/scala/collection/mutable/Buffer.scala | 1 - .../scala/collection/mutable/ListBuffer.scala | 1 - src/library/scala/collection/mutable/Map.scala | 2 +- src/library/scala/collection/mutable/Message.scala | 2 +- .../scala/collection/mutable/MutableList.scala | 2 +- .../collection/mutable/ObservableBuffer.scala | 2 +- .../scala/collection/mutable/PriorityQueue.scala | 2 +- src/library/scala/collection/mutable/Queue.scala | 2 +- src/library/scala/collection/mutable/Set.scala | 2 - src/library/scala/collection/mutable/Stack.scala | 1 - src/library/scala/compat/Math.scala | 46 ++++++++++--------- src/library/scala/compat/Platform.scala | 33 +++++--------- src/library/scala/compat/StringBuilder.scala | 52 +++++++++++++++------- src/library/scala/concurrent/Actor.scala | 6 +-- src/library/scala/concurrent/Lock.scala | 2 +- src/library/scala/concurrent/NameServer.scala | 2 - src/library/scala/concurrent/Process.scala | 6 +-- src/library/scala/concurrent/ops.scala | 2 + src/library/scala/io/BytePickle.scala | 1 - src/library/scala/io/Position.scala | 1 - src/library/scala/io/Source.scala | 7 ++- src/library/scala/io/UTF8Codec.scala | 2 +- src/library/scala/mobile/Code.scala | 3 +- src/library/scala/mobile/Location.scala | 2 +- src/library/scala/reflect/Code.scala | 4 +- src/library/scala/runtime/BoxedAnyArray.scala | 39 ++++++++-------- src/library/scala/runtime/BoxedArray.scala | 38 +++++++++------- src/library/scala/runtime/BoxedBooleanArray.scala | 10 +++-- src/library/scala/runtime/BoxedByteArray.scala | 10 +++-- src/library/scala/runtime/BoxedCharArray.scala | 10 +++-- src/library/scala/runtime/BoxedDoubleArray.scala | 10 +++-- src/library/scala/runtime/BoxedFloatArray.scala | 10 +++-- src/library/scala/runtime/BoxedIntArray.scala | 10 +++-- src/library/scala/runtime/BoxedLongArray.scala | 10 +++-- src/library/scala/runtime/BoxedObjectArray.scala | 20 +++++---- src/library/scala/runtime/BoxedShortArray.scala | 10 +++-- .../scala/runtime/NonLocalReturnException.scala | 2 +- src/library/scala/runtime/RichString.scala | 13 ++++-- src/library/scala/runtime/ScalaRunTime.scala | 11 +++-- src/library/scala/testing/Benchmark.scala | 13 +++--- src/library/scala/util/Fluid.scala | 8 +++- .../scala/util/automata/BaseBerrySethi.scala | 2 - .../scala/util/parsing/SimpleTokenizer.scala | 2 +- src/library/scala/xml/Comment.scala | 2 +- src/library/scala/xml/Elem.scala | 2 - src/library/scala/xml/Group.scala | 1 - src/library/scala/xml/NamespaceBinding.scala | 2 +- src/library/scala/xml/PrefixedAttribute.scala | 1 - src/library/scala/xml/ProcInstr.scala | 1 - src/library/scala/xml/Utility.scala | 8 ++-- src/library/scala/xml/dtd/Decl.scala | 1 - src/library/scala/xml/dtd/DocType.scala | 2 - src/library/scala/xml/dtd/ExternalID.scala | 1 - src/library/scala/xml/parsing/FactoryAdapter.scala | 40 +++++++++-------- src/library/scala/xml/pull/XMLEventReader.scala | 3 ++ .../scala/xml/transform/BasicTransformer.scala | 2 - 73 files changed, 321 insertions(+), 263 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala index a289884eca..9b268abeae 100644 --- a/src/library/scala/Application.scala +++ b/src/library/scala/Application.scala @@ -12,6 +12,9 @@ package scala +import compat.Platform.currentTime +import java.lang.System.getProperty + /** The Application class can be used to quickly turn objects * into executable programs. Here is an example: *
@@ -40,16 +43,16 @@ trait Application {
 
   /** The time when execution of this program started.
    */
-  val executionStart: Long = java.lang.System.currentTimeMillis()
+  val executionStart: Long = currentTime
 
   /** The default main method.
    *
    *  @param args the arguments passed to the main method
    */
   def main(args: Array[String]) = {
-    if (java.lang.System.getProperty("scala.time") != null) {
-      val total = java.lang.System.currentTimeMillis() - executionStart
-      java.lang.System.out.println("[total " + total + "ms]")
+    if (getProperty("scala.time") != null) {
+      val total = currentTime - executionStart
+      Console.println("[total " + total + "ms]")
     }
   }
 }
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index b64df80406..a7534e31fb 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -8,8 +8,11 @@
 
 // $Id$
 
+
 package scala
 
+import compat.Platform.arraycopy
+
 /** This object ...
  *
  *  @author Martin Odersky
@@ -36,7 +39,7 @@ object Array {
         case xs: runtime.BoxedArray =>
           xs.copyFrom(src, srcPos, destPos, length)
         case _ =>
-          System.arraycopy(src, srcPos, dest, destPos, length)
+          arraycopy(src, srcPos, dest, destPos, length)
       }
   }
 
@@ -162,6 +165,7 @@ object Array {
  *  @version 1.0
  */
 final class Array[A](_length: Int) extends Seq[A] {
+  import Predef.Error
   def length: Int = throw new Error()
   def apply(i: Int): A = throw new Error()
   def update(i: Int, x: A): Unit = throw new Error()
diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala
index c1504627ef..e6fcd2130b 100644
--- a/src/library/scala/Console.scala
+++ b/src/library/scala/Console.scala
@@ -61,6 +61,8 @@ object Console {
   def out = outFluid.value
   def in = inFluid.value
 
+  val err = java.lang.System.err
+
   /** Set the default output stream.
    *
    *  @param out the new output stream.
@@ -193,27 +195,27 @@ object Console {
 
   /** Read a byte value from the terminal.
    */
-  def readByte: Byte = java.lang.Byte.decode(in.readLine()).byteValue()
+  def readByte: Byte = readLine.toByte
 
   /** Read a short value from the terminal.
    */
-  def readShort: Short = java.lang.Short.decode(in.readLine()).shortValue()
+  def readShort: Short = readLine.toByte
 
   /** Read a char value from the terminal.
    */
-  def readChar: Char = in.readLine().charAt(0)
+  def readChar: Char = readLine charAt 0
 
   /** Read an int value from the terminal.
    */
-  def readInt: Int = java.lang.Integer.decode(in.readLine()).intValue()
+  def readInt: Int = readLine.toInt
 
   /** Read a float value from the terminal.
    */
-  def readFloat: Float = compat.Platform.parseFloat(in.readLine())
+  def readFloat: Float = readLine.toFloat
 
   /** Read a double value from the terminal.
    */
-  def readDouble: Double = compat.Platform.parseDouble(in.readLine())
+  def readDouble: Double = readLine.toDouble
 
   /** Read in some structured input, specified by a format specifier.
    *  See class java.text.MessageFormat for details of
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 0545b8538e..45b67e7550 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -12,7 +12,7 @@
 package scala
 
 
-import compat.Platform.IllegalArgumentException
+import Predef.IllegalArgumentException
 
 /** This object ...
  *
diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala
index 0959dfa958..3e9dbdb957 100644
--- a/src/library/scala/Iterator.scala
+++ b/src/library/scala/Iterator.scala
@@ -13,7 +13,6 @@ package scala
 
 
 import Predef._
-import compat.Platform.NoSuchElementException
 
 /** The Iterator object provides various functions for
  *  creating specialized iterators.
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index 88e1f94574..1410068344 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -13,7 +13,6 @@ package scala
 
 import scala.collection.mutable.ListBuffer
 import Predef._
-import compat.Platform.{NoSuchElementException, UnsupportedOperationException}
 
 /** This object provides methods for creating specialized lists, and for
  *  transforming special kinds of lists (e.g. lists of lists).
@@ -547,7 +546,6 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
    *
    *  @param n the number of elements to take
    *  @return the suffix of length n of the list
-   *  @throws java.lang.RuntimeException if the list is too short.
    */
   def takeRight(n: Int): List[a] = {
     def loop(lead: List[a], lag: List[a]): List[a] = lead match {
@@ -561,7 +559,6 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
    *
    *  @param n the number of elements to take
    *  @return the suffix of length n of the list
-   *  @throws java.lang.RuntimeException if the list is too short.
    */
   def dropRight(n: Int): List[a] = {
     def loop(lead: List[a], lag: List[a]): List[a] = lead match {
diff --git a/src/library/scala/NotDefinedError.scala b/src/library/scala/NotDefinedError.scala
index 7df1c8b11b..60e61d9e89 100644
--- a/src/library/scala/NotDefinedError.scala
+++ b/src/library/scala/NotDefinedError.scala
@@ -9,7 +9,9 @@
 // $Id$
 
 
-package scala;
+package scala
 
 
-final class NotDefinedError(msg: String) extends Error("not defined: " + msg);
+import Predef.Error
+
+final class NotDefinedError(msg: String) extends Error("not defined: " + msg)
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index e140cbc6e6..9d8e547c28 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -13,7 +13,6 @@ package scala;
 
 
 import Predef._
-import compat.Platform.NoSuchElementException
 
 /** This class represents optional values. Instances of Option
  *  are either instances of case class Some or it is case
@@ -31,7 +30,7 @@ sealed abstract class Option[+A] extends Iterable[A] with CaseClass {
   }
 
   /**
-   *  @throws scala.compat.Platform.NoSuchElementException
+   *  @throws Predef.NoSuchElementException
    */
   def get: A = this match {
     case None => throw new NoSuchElementException("None.get")
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 932f45c5c9..1673ba90a1 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -21,7 +21,7 @@ object Predef {
   // classOf dummy -------------------------------------------------
 
   /** Return the runtime representation of a class type. */
-  def classOf[T]: java.lang.Class = null
+  def classOf[T]: Class = null
 
   // aliases -------------------------------------------------------
 
@@ -36,8 +36,20 @@ object Predef {
   type unit = scala.Unit
 
   type String = java.lang.String
-  type NullPointerException = java.lang.NullPointerException
+  type Class = java.lang.Class;
+
   type Throwable = java.lang.Throwable
+  type Exception = java.lang.Exception
+  type Error = java.lang.Error
+  type RuntimeException = java.lang.RuntimeException;
+  type NullPointerException = java.lang.NullPointerException
+  type ClassCastException = java.lang.ClassCastException;
+  type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException;
+  type ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException
+  type UnsupportedOperationException = java.lang.UnsupportedOperationException
+  type IllegalArgumentException = java.lang.IllegalArgumentException
+  type NoSuchElementException = java.util.NoSuchElementException
+  type NumberFormatException = java.lang.NumberFormatException
 
 /*
   type ~[a, b] = Tuple2[a, b]
@@ -63,11 +75,6 @@ object Predef {
   def Tuple[a1, a2, a3, a4, a5, a6, a7, a8](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5, x6: a6, x7: a7, x8: a8) = Tuple8(x1, x2, x3, x4, x5, x6, x7, x8)
   def Tuple[a1, a2, a3, a4, a5, a6, a7, a8, a9](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5, x6: a6, x7: a7, x8: a8, x9: a9) = Tuple9(x1, x2, x3, x4, x5, x6, x7, x8, x9)
 
-/*
-  def id[a](x: a): a = x
-  def fst[a](x: a, y: Any): a = x
-  def scd[a](x: Any, y: a): a = y
-*/
   val $scope = scala.xml.TopScope
 
   type Function[-a,+b] = Function1[a,b]
@@ -85,12 +92,12 @@ object Predef {
 
   def assert(assertion: Boolean): Unit = {
     if (!assertion)
-      throw new AssertionError("assertion failed")
+      throw new java.lang.AssertionError("assertion failed")
   }
 
   def assert(assertion: Boolean, message: Any): Unit = {
     if (!assertion)
-      throw new AssertionError("assertion failed: " + message)
+      throw new java.lang.AssertionError("assertion failed: " + message)
   }
 
   def assume(assumption: Boolean): Unit = {
@@ -107,15 +114,19 @@ object Predef {
 
   implicit def identity[a](x: a): a = x
 
-  implicit def int2ordered(x: int): Ordered[int] = new Ordered[int] with Proxy {
-    def self: Any = x
-    def compare (y: int): int = if (x < y) -1 else if (x > y) 1 else 0
-  }
 
   implicit def intWrapper(x: int) = new runtime.RichInt(x)
 
+  implicit def charWrapper(c: char) = new runtime.RichChar(c)
+
   implicit def stringWrapper(x: String) = new runtime.RichString(x)
 
+
+  implicit def int2ordered(x: int): Ordered[int] = new Ordered[int] with Proxy {
+    def self: Any = x
+    def compare (y: int): int = if (x < y) -1 else if (x > y) 1 else 0
+  }
+
   implicit def char2ordered(x: char): Ordered[char] = new Ordered[char] with Proxy {
     def self: Any = x
     def compare (y: char): int = if (x < y) -1 else if (x > y) 1 else 0
@@ -298,4 +309,9 @@ object Predef {
   implicit def float2Float(x: float) = new java.lang.Float(x)
   implicit def double2Double(x: double) = new java.lang.Double(x)
   implicit def boolean2Boolean(x: boolean) = new java.lang.Boolean(x)
+
+  //
+  def currentThread = java.lang.Thread.currentThread();
+
+
 }
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index a9fcf2524c..8879422969 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -12,7 +12,7 @@
 package scala
 
 
-import compat.Platform.IllegalArgumentException
+import Predef.IllegalArgumentException
 
 object Seq {
 
diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala
index d873502056..54bf3ae694 100644
--- a/src/library/scala/Stream.scala
+++ b/src/library/scala/Stream.scala
@@ -13,7 +13,7 @@ package scala
 
 
 import compat.StringBuilder
-import compat.Platform.NoSuchElementException
+import Predef.NoSuchElementException
 
 /**
  * The object Stream provides helper functions
diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala
index 0d21faba6c..842544b3a4 100644
--- a/src/library/scala/collection/Map.scala
+++ b/src/library/scala/collection/Map.scala
@@ -12,7 +12,7 @@
 package scala.collection
 
 
-import compat.Platform.NoSuchElementException
+//import Predef.NoSuchElementException
 
 /** This class defines the interface of collections that unambiguously map
  *  keys to values (i.e. a key is mapped to at least one value).
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 5ece1d0286..6979c973c5 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -12,7 +12,7 @@
 package scala.collection.immutable
 
 
-import compat.Platform.NoSuchElementException
+//import Predef.NoSuchElementException
 
 object ListMap {
   def Empty[A, B] = new ListMap[A, B]
diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala
index 19c74bbb27..823e3f02b3 100644
--- a/src/library/scala/collection/immutable/ListSet.scala
+++ b/src/library/scala/collection/immutable/ListSet.scala
@@ -12,7 +12,7 @@
 package scala.collection.immutable
 
 
-import compat.Platform.NoSuchElementException
+//import Predef.NoSuchElementException
 
 object ListSet {
   /** constructs an empty ListSet
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 5624a7eb21..ebfbbf7e19 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -12,7 +12,7 @@
 package scala.collection.immutable
 
 
-import compat.Platform.NoSuchElementException
+//import Predef.NoSuchElementException
 
 object Queue {
   val Empty: Queue[Nothing] = new Queue()
diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala
index 9599b40f97..fccf9197ef 100644
--- a/src/library/scala/collection/immutable/Stack.scala
+++ b/src/library/scala/collection/immutable/Stack.scala
@@ -12,7 +12,7 @@
 package scala.collection.immutable
 
 
-import compat.Platform.NoSuchElementException
+//import Predef.NoSuchElementException
 
 object Stack {
   val Empty = new Stack[Nothing]
diff --git a/src/library/scala/collection/immutable/Tree.scala b/src/library/scala/collection/immutable/Tree.scala
index 3bb0eb8ced..eef8842e39 100644
--- a/src/library/scala/collection/immutable/Tree.scala
+++ b/src/library/scala/collection/immutable/Tree.scala
@@ -40,7 +40,7 @@
 package scala.collection.immutable
 
 
-import compat.Platform.NoSuchElementException
+//import Predef.NoSuchElementException
 
 /** 

* General Balanced Trees - highly efficient functional dictionaries. diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala index c5f953cb05..02e5a2ad42 100644 --- a/src/library/scala/collection/mutable/Buffer.scala +++ b/src/library/scala/collection/mutable/Buffer.scala @@ -13,7 +13,6 @@ package scala.collection.mutable import Predef._ -import compat.Platform.UnsupportedOperationException /** Buffers are used to create sequences of elements incrementally by * appending, prepending, or inserting new elements. It is also diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index abe65019bf..0907f1f50c 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -13,7 +13,6 @@ package scala.collection.mutable import Predef._ -import compat.Platform.{IndexOutOfBoundsException, NoSuchElementException} /** The class ListBuffer .. * diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index 7106acb8a1..e1e08abd85 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -11,7 +11,7 @@ package scala.collection.mutable -import compat.Platform.UnsupportedOperationException +//import Predef.UnsupportedOperationException /** This class represents mutable maps. Concrete map implementations * just have to provide functionality for the abstract methods in diff --git a/src/library/scala/collection/mutable/Message.scala b/src/library/scala/collection/mutable/Message.scala index 337083b9e3..09b3dbd527 100644 --- a/src/library/scala/collection/mutable/Message.scala +++ b/src/library/scala/collection/mutable/Message.scala @@ -12,7 +12,7 @@ package scala.collection.mutable -import compat.Platform.UnsupportedOperationException +import Predef.UnsupportedOperationException /** Class Message represents messages that are issued by observable * collection classes whenever a data structure is changed. Class Message diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index f0349f584a..6e57074641 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -11,8 +11,8 @@ package scala.collection.mutable -import compat.Platform.NoSuchElementException +//import Predef.NoSuchElementException /** This class is used internally to represent mutable lists. It is the * basis for the implementation of the classes Buffer, diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala index a38e442468..93f325cfaa 100644 --- a/src/library/scala/collection/mutable/ObservableBuffer.scala +++ b/src/library/scala/collection/mutable/ObservableBuffer.scala @@ -12,7 +12,7 @@ package scala.collection.mutable -import compat.Platform.UnsupportedOperationException +//import Predef.UnsupportedOperationException /** This class is typically used as a mixin. It adds a subscription * mechanism to the Buffer class into which this abstract diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index d32bb60376..2eb6298141 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -12,7 +12,7 @@ package scala.collection.mutable -import compat.Platform.{NoSuchElementException, UnsupportedOperationException} +//import Predef.{NoSuchElementException, UnsupportedOperationException} /** This class implements priority queues using a heap. The * elements of the queue have to be ordered in terms of the diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala index 359f0d4c9c..3dbd38320b 100644 --- a/src/library/scala/collection/mutable/Queue.scala +++ b/src/library/scala/collection/mutable/Queue.scala @@ -12,7 +12,7 @@ package scala.collection.mutable -import compat.Platform.{NoSuchElementException, UnsupportedOperationException} +//import Predef.{NoSuchElementException, UnsupportedOperationException} /** Queue objects implement data structures that allow to * insert and retrieve elements in a first-in-first-out (FIFO) manner. diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala index 6ae94dc4f3..83133392af 100644 --- a/src/library/scala/collection/mutable/Set.scala +++ b/src/library/scala/collection/mutable/Set.scala @@ -12,8 +12,6 @@ package scala.collection.mutable -import compat.Platform.UnsupportedOperationException - /** This class represents mutable sets. Concrete set implementations * just have to provide functionality for the abstract methods in * diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala index eacf69552a..59ad02e860 100644 --- a/src/library/scala/collection/mutable/Stack.scala +++ b/src/library/scala/collection/mutable/Stack.scala @@ -11,7 +11,6 @@ package scala.collection.mutable -import compat.Platform.NoSuchElementException /** A stack implements a data structure which allows to store and retrieve * objects in a last-in-first-out (LIFO) fashion. diff --git a/src/library/scala/compat/Math.scala b/src/library/scala/compat/Math.scala index 81b5a54e00..de64dcc3c1 100644 --- a/src/library/scala/compat/Math.scala +++ b/src/library/scala/compat/Math.scala @@ -13,26 +13,28 @@ package scala.compat; object Math { - val MIN_BYTE = java.lang.Byte.MIN_VALUE; - val MAX_BYTE = java.lang.Byte.MAX_VALUE; - val MIN_SHORT = java.lang.Short.MIN_VALUE; - val MAX_SHORT = java.lang.Short.MAX_VALUE; - val MIN_CHAR = java.lang.Character.MIN_VALUE; - val MAX_CHAR = java.lang.Character.MAX_VALUE; - val MIN_INT = java.lang.Integer.MIN_VALUE; - val MAX_INT = java.lang.Integer.MAX_VALUE; - val MIN_LONG = java.lang.Long.MIN_VALUE; - val MAX_LONG = java.lang.Long.MAX_VALUE; - val MIN_FLOAT = java.lang.Float.MIN_VALUE; - val MAX_FLOAT = java.lang.Float.MIN_VALUE; - val MIN_DOUBLE = java.lang.Double.MIN_VALUE; - val MAX_DOUBLE = java.lang.Double.MAX_VALUE; - - def min(x: Int, y: Int): Int = java.lang.Math.min(x, y); - def max(x: Int, y: Int): Int = java.lang.Math.max(x, y); - - def ceil (x: Double): Double = java.lang.Math.ceil(x); - def floor(x: Double): Double = java.lang.Math.floor(x); - def log (x: Double): Double = java.lang.Math.log(x); - def sqrt (x: Double): Double = java.lang.Math.sqrt(x); + val MIN_BYTE = java.lang.Byte.MIN_VALUE + val MAX_BYTE = java.lang.Byte.MAX_VALUE + val MIN_SHORT = java.lang.Short.MIN_VALUE + val MAX_SHORT = java.lang.Short.MAX_VALUE + val MIN_CHAR = java.lang.Character.MIN_VALUE + val MAX_CHAR = java.lang.Character.MAX_VALUE + val MIN_INT = java.lang.Integer.MIN_VALUE + val MAX_INT = java.lang.Integer.MAX_VALUE + val MIN_LONG = java.lang.Long.MIN_VALUE + val MAX_LONG = java.lang.Long.MAX_VALUE + val MIN_FLOAT = java.lang.Float.MIN_VALUE + val MAX_FLOAT = java.lang.Float.MIN_VALUE + val MIN_DOUBLE = java.lang.Double.MIN_VALUE + val MAX_DOUBLE = java.lang.Double.MAX_VALUE + + val PI = java.lang.Math.PI + + def min(x: Int, y: Int): Int = java.lang.Math.min(x, y) + def max(x: Int, y: Int): Int = java.lang.Math.max(x, y) + + def ceil (x: Double): Double = java.lang.Math.ceil(x) + def floor(x: Double): Double = java.lang.Math.floor(x) + def log (x: Double): Double = java.lang.Math.log(x) + def sqrt (x: Double): Double = java.lang.Math.sqrt(x) } diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala index 08aa1f1188..fa32f93a72 100644 --- a/src/library/scala/compat/Platform.scala +++ b/src/library/scala/compat/Platform.scala @@ -12,39 +12,36 @@ package scala.compat; -object Platform { +import java.lang.System +import Predef.Class - type Class = java.lang.Class; +object Platform { type StackOverflowError = java.lang.StackOverflowError; - type ClassCastException = java.lang.ClassCastException; - type RuntimeException = java.lang.RuntimeException; - type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException; - type UnsupportedOperationException = java.lang.UnsupportedOperationException - type IllegalArgumentException = java.lang.IllegalArgumentException - type NoSuchElementException = java.util.NoSuchElementException def arraycopy(src: AnyRef, srcPos: Int, dest: AnyRef, destPos: Int, length: Int): Unit = - Array.copy(src, srcPos, dest, destPos, length) + System.arraycopy(src, srcPos, dest, destPos, length) /** create array of the same type as arrayInstance with the given length */ - def createArray(elemClass: Class, length: Int): Object = + def createArray(elemClass: Class, length: Int): AnyRef = java.lang.reflect.Array.newInstance(elemClass, length); def getClass(obj: AnyRef) = obj.getClass(); def getClassName(obj: AnyRef) = obj.getClass().getName(); def getName(cls: Class) = cls.getName(); def getElementClass(obj: AnyRef) = obj.getClass().getComponentType(); + def getClassForName(name: String): Class = java.lang.Class.forName(name); def printStackTrace(exc: java.lang.Throwable) = exc.printStackTrace(); def getMessage(exc: java.lang.Throwable) = exc.getMessage(); - private val eol = System.getProperty("line.separator", "\n") + val EOL = System.getProperty("line.separator", "\n") + def getStackTrace(exc: java.lang.Throwable): String = { val s = new StringBuilder() for (val trElem <- exc.getStackTrace()) { s.append(trElem.toString()) - s.append(eol) + s.append(EOL) } s.toString() } @@ -53,14 +50,8 @@ object Platform { str.split(separator.toString()); } - def currentThread = java.lang.Thread.currentThread(); - - def parseByte(s: String): Byte = java.lang.Byte.parseByte(s); - def parseShort(s: String): Short = java.lang.Short.parseShort(s); - def parseInt(s: String): Int = java.lang.Integer.parseInt(s); - def parseLong(s: String): Long = java.lang.Long.parseLong(s); - def parseFloat(s: String): Float = java.lang.Float.parseFloat(s); - def parseDouble(s: String): Double = java.lang.Double.parseDouble(s); + def currentTime: Long = System.currentTimeMillis() + def collectGarbage: Unit = System.gc() - def isDigit(c: Char): Boolean = java.lang.Character.isDigit(c); + //def isDigit(c: Char): Boolean = java.lang.Character.isDigit(c); } diff --git a/src/library/scala/compat/StringBuilder.scala b/src/library/scala/compat/StringBuilder.scala index a71c9004f2..d64ec65ff7 100644 --- a/src/library/scala/compat/StringBuilder.scala +++ b/src/library/scala/compat/StringBuilder.scala @@ -11,27 +11,45 @@ package scala.compat -class StringBuilder { - val str = new StringBuffer() +import java.lang.StringBuffer - def this(s: String) = { this(); str.append(s) } +final class StringBuilder(str: StringBuffer) { - def charAt(i: Int): Char = str.charAt(i) - - def append(x: Any): StringBuilder = { - str.append(x) - this - } + def this() = this(new StringBuffer()) + def this(n: Int) = this(new StringBuffer(n)) + def this(s: String) = this(new StringBuffer(s)) - def append(x: Char): StringBuilder = { - str.append(x) - this - } + def charAt(i: Int): Char = str.charAt(i) - def append(x: String): StringBuilder = { - str.append(x) - this - } + def setCharAt(index: Int, c: Char): Unit = str.setCharAt(index, c) + + def append(x: Any): StringBuilder = { str.append(x); this } + def append(x: Boolean): StringBuilder = { str.append(x); this } + def append(x: Byte): StringBuilder = { str.append(x); this } + def append(x: Short): StringBuilder = { str.append(x); this } + def append(x: Char): StringBuilder = { str.append(x); this } + def append(x: Int): StringBuilder = { str.append(x); this } + def append(x: Long): StringBuilder = { str.append(x); this } + def append(x: Float): StringBuilder = { str.append(x); this } + def append(x: Double): StringBuilder = { str.append(x); this } + def append(x: String): StringBuilder = { str.append(x); this } + def append(x: Array[Char]): StringBuilder = { str.append(x); this } + def append(x: Array[Char], start: Int, length: Int): StringBuilder = + { str.append(x, start, length); this } + + def insert(at: Int, x: Any): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Boolean): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Byte): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Short): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Char): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Int): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Long): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Float): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Double): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: String): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Array[Char]): StringBuilder = { str.insert(at, x); this } + def insert(at: Int, x: Array[Char], start: Int, length: Int): StringBuilder = + { str.insert(at, x, start, length); this } def length(): Int = str.length() diff --git a/src/library/scala/concurrent/Actor.scala b/src/library/scala/concurrent/Actor.scala index 8017ae43fb..8f2534bb95 100644 --- a/src/library/scala/concurrent/Actor.scala +++ b/src/library/scala/concurrent/Actor.scala @@ -12,7 +12,7 @@ package scala.concurrent -import compat.Platform.IllegalArgumentException +import java.lang.Thread /** * The class Actor ... @@ -27,11 +27,11 @@ abstract class Actor extends Thread { in.send(msg) def receive[a](f: PartialFunction[in.Message, a]): a = - if (Thread.currentThread() == this) in.receive(f) + if (currentThread == this) in.receive(f) else throw new IllegalArgumentException("receive called not on own process") def receiveWithin[a](msec: long)(f: PartialFunction[in.Message, a]): a = - if (Thread.currentThread() == this) in.receiveWithin(msec)(f) + if (currentThread == this) in.receiveWithin(msec)(f) else throw new IllegalArgumentException("receiveWithin called not on own process") private var pid: Pid = null diff --git a/src/library/scala/concurrent/Lock.scala b/src/library/scala/concurrent/Lock.scala index cd7371aa86..d20f3806d7 100644 --- a/src/library/scala/concurrent/Lock.scala +++ b/src/library/scala/concurrent/Lock.scala @@ -20,7 +20,7 @@ class Lock { var available = true def acquire = synchronized { - if (!available) wait() + while (!available) wait() available = false } diff --git a/src/library/scala/concurrent/NameServer.scala b/src/library/scala/concurrent/NameServer.scala index 806e864038..bb15def799 100644 --- a/src/library/scala/concurrent/NameServer.scala +++ b/src/library/scala/concurrent/NameServer.scala @@ -12,8 +12,6 @@ package scala.concurrent -import compat.Platform.IllegalArgumentException - /** * @author Erik Stenman * @version 1.0, 01/10/2003 diff --git a/src/library/scala/concurrent/Process.scala b/src/library/scala/concurrent/Process.scala index 39ce04484e..b054b23ecb 100644 --- a/src/library/scala/concurrent/Process.scala +++ b/src/library/scala/concurrent/Process.scala @@ -12,8 +12,6 @@ package scala.concurrent -import compat.Platform.UnsupportedOperationException - /** This object ... * * @author Erik Stenman @@ -43,8 +41,8 @@ object Process { * @throws scala.compat.Platform.UnsupportedOperationException */ def self: Process = - if (Thread.currentThread().isInstanceOf[Process]) - Thread.currentThread().asInstanceOf[Process] + if (currentThread.isInstanceOf[Process]) + currentThread.asInstanceOf[Process] else throw new UnsupportedOperationException("Self called outside a process") diff --git a/src/library/scala/concurrent/ops.scala b/src/library/scala/concurrent/ops.scala index e70a0ed606..73cfedc676 100644 --- a/src/library/scala/concurrent/ops.scala +++ b/src/library/scala/concurrent/ops.scala @@ -12,6 +12,8 @@ package scala.concurrent +import java.lang.Thread + /** The object ops ... * * @author Martin Odersky diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala index a2ee0d7052..ae5cd1a80c 100644 --- a/src/library/scala/io/BytePickle.scala +++ b/src/library/scala/io/BytePickle.scala @@ -13,7 +13,6 @@ package scala.io import scala.collection.mutable.{HashMap,ArrayBuffer} -import compat.Platform.IllegalArgumentException /** * Pickler combinators. diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala index 6173233176..b31b22c71c 100644 --- a/src/library/scala/io/Position.scala +++ b/src/library/scala/io/Position.scala @@ -13,7 +13,6 @@ package scala.io import compat.StringBuilder -import compat.Platform.IllegalArgumentException /**

* The object Position provides convenience methods to encode diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index faa7165ff7..dfdbd86849 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -11,11 +11,10 @@ package scala.io + import java.io.{File, FileInputStream, PrintStream} import compat.StringBuilder -import compat.Platform.IllegalArgumentException - /** This object provides convenience methods to create an iterable * representation of a source file. @@ -216,7 +215,7 @@ abstract class Source extends Iterator[Char] { * @throws scala.compat.Platform.IllegalArgumentException */ def getLine(line: Int): String = { - val buf = new StringBuffer() + val buf = new StringBuilder() val it = reset var i = 0 @@ -285,7 +284,7 @@ abstract class Source extends Iterator[Char] { * @param out ... */ def report(pos: Int, msg: String, out: PrintStream): Unit = { - val buf = new StringBuffer + val buf = new StringBuilder val line = Position.line(pos) val col = Position.column(pos) buf.append(descr + ":" + line + ":" + col + ": " + msg) diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala index 729e79586e..a1d688cb1e 100644 --- a/src/library/scala/io/UTF8Codec.scala +++ b/src/library/scala/io/UTF8Codec.scala @@ -77,7 +77,7 @@ object UTF8Codec { def decode(src: Array[Byte], from: Int, len: Int): String = { val cs = new Array[Char](len) - String.copyValueOf(cs, 0, decode(src, 0, cs, 0, len)) + new String(cs, 0, decode(src, 0, cs, 0, len)) } } diff --git a/src/library/scala/mobile/Code.scala b/src/library/scala/mobile/Code.scala index e185db0f40..e7166bfc1a 100644 --- a/src/library/scala/mobile/Code.scala +++ b/src/library/scala/mobile/Code.scala @@ -11,8 +11,9 @@ package scala.mobile -import java.lang.reflect.{Constructor, Method, Modifier} +import java.lang.reflect.{Constructor, Method, Modifier} +import java.lang.NoSuchMethodException /** The class Code provides apply methods * with different arities (actually up to 9 parameters) to invoke diff --git a/src/library/scala/mobile/Location.scala b/src/library/scala/mobile/Location.scala index 2c6aae6cae..246db26fc9 100644 --- a/src/library/scala/mobile/Location.scala +++ b/src/library/scala/mobile/Location.scala @@ -12,11 +12,11 @@ package scala.mobile +import java.lang.ClassLoader import java.net._ import scala.collection.mutable._ - /** The class Location provides a create * method to instantiate objects from a network location by * specifying the URL address of the jar/class file.

diff --git a/src/library/scala/reflect/Code.scala b/src/library/scala/reflect/Code.scala index 62f7e9b2fa..780bd5518c 100644 --- a/src/library/scala/reflect/Code.scala +++ b/src/library/scala/reflect/Code.scala @@ -12,9 +12,11 @@ package scala.reflect +import Predef.Error + class Code[Type](val tree: Tree) object Code { def lift[A](tree: A): Code[A] = throw new Error("Code was not lifted by compiler") -} \ No newline at end of file +} diff --git a/src/library/scala/runtime/BoxedAnyArray.scala b/src/library/scala/runtime/BoxedAnyArray.scala index e18ba86cca..303f25def8 100644 --- a/src/library/scala/runtime/BoxedAnyArray.scala +++ b/src/library/scala/runtime/BoxedAnyArray.scala @@ -12,6 +12,9 @@ package scala.runtime +import Predef.Class +import compat.Platform + /** * Arrays created by new Array[T](length) where T * is a type variable. @@ -19,12 +22,12 @@ package scala.runtime [serializable] final class BoxedAnyArray(val length: Int) extends BoxedArray { - private var boxed = new Array[Object](length) + private var boxed = new Array[AnyRef](length) private val hash = boxed.hashCode() - private var unboxed: Object = null + private var unboxed: AnyRef = null private var elemClass: Class = null - def apply(index: Int): Object = synchronized { + def apply(index: Int): AnyRef = synchronized { if (unboxed == null) boxed(index); else if (elemClass eq ScalaRunTime.IntTYPE) @@ -44,10 +47,10 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { else if (elemClass eq ScalaRunTime.BooleanTYPE) BoxedBoolean.box(unboxed.asInstanceOf[Array[Boolean]](index)) else - unboxed.asInstanceOf[Array[Object]](index) + unboxed.asInstanceOf[Array[AnyRef]](index) } - def update(index: Int, elem: Object): Unit = synchronized { + def update(index: Int, elem: AnyRef): Unit = synchronized { if (unboxed == null) boxed(index) = elem else if (elemClass eq ScalaRunTime.IntTYPE) @@ -67,10 +70,10 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { else if (elemClass eq ScalaRunTime.BooleanTYPE) unboxed.asInstanceOf[Array[Boolean]](index) = elem.asInstanceOf[BoxedBoolean].value else - unboxed.asInstanceOf[Array[Object]](index) = elem + unboxed.asInstanceOf[Array[AnyRef]](index) = elem } - def unbox(elemTag: String): Object = + def unbox(elemTag: String): AnyRef = if (elemTag eq ScalaRunTime.IntTag) unbox(ScalaRunTime.IntTYPE) else if (elemTag eq ScalaRunTime.DoubleTag) unbox(ScalaRunTime.DoubleTYPE) else if (elemTag eq ScalaRunTime.FloatTag) unbox(ScalaRunTime.FloatTYPE) @@ -79,9 +82,9 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { else if (elemTag eq ScalaRunTime.ByteTag) unbox(ScalaRunTime.ByteTYPE) else if (elemTag eq ScalaRunTime.ShortTag) unbox(ScalaRunTime.ShortTYPE) else if (elemTag eq ScalaRunTime.BooleanTag) unbox(ScalaRunTime.BooleanTYPE) - else unbox(Class.forName(elemTag)) + else unbox(Platform.getClassForName(elemTag)) - def unbox(elemClass: Class): Object = synchronized { + def unbox(elemClass: Class): AnyRef = synchronized { if (unboxed == null) { this.elemClass = elemClass; if (elemClass eq ScalaRunTime.IntTYPE) { @@ -157,11 +160,11 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { } unboxed = newvalue; } else if (elemClass == boxed.getClass().getComponentType()) { - // todo: replace with ScalaRunTime.Object.class + // todo: replace with ScalaRunTime.AnyRef.class unboxed = boxed } else { - unboxed = java.lang.reflect.Array.newInstance(elemClass, length); - System.arraycopy(boxed, 0, unboxed, 0, length); + unboxed = Platform.createArray(elemClass, length); + Platform.arraycopy(boxed, 0, unboxed, 0, length); } boxed = null } @@ -175,12 +178,12 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { override def hashCode(): Int = hash - def value: Object = { + def value: AnyRef = { if (unboxed == null) throw new NotDefinedError("BoxedAnyArray.value") unboxed } - private def adapt(other: Object): Object = + private def adapt(other: AnyRef): AnyRef = if (this.unboxed == null) other match { case that: BoxedAnyArray => @@ -223,23 +226,23 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { other } - override def copyFrom(src: Object, from: Int, to: Int, len: Int): Unit = { + override def copyFrom(src: AnyRef, from: Int, to: Int, len: Int): Unit = { val src1 = adapt(src) Array.copy(src1, from, if (unboxed != null) unboxed else boxed, to, len) } - override def copyTo(from: Int, dest: Object, to: Int, len: Int): Unit = { + override def copyTo(from: Int, dest: AnyRef, to: Int, len: Int): Unit = { var dest1 = adapt(dest) Array.copy(if (unboxed != null) unboxed else boxed, from, dest1, to, len) } - override def subArray(start: Int, end: Int): Object = { + override def subArray(start: Int, end: Int): AnyRef = { val result = new BoxedAnyArray(end - start); Array.copy(this, start, result, 0, end - start) result } - override def filter(p: Any => Boolean): Object = { + override def filter(p: Any => Boolean): AnyRef = { val include = new Array[Boolean](length) var len = 0 var i = 0 diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala index 7a213f05eb..7e7d2ba88e 100644 --- a/src/library/scala/runtime/BoxedArray.scala +++ b/src/library/scala/runtime/BoxedArray.scala @@ -11,56 +11,60 @@ package scala.runtime + +import Predef.Class +import Predef.Error + /** *

A class representing Array[T]

*/ -abstract class BoxedArray extends PartialFunction[Int, Object] with Seq[Object] { +abstract class BoxedArray extends PartialFunction[Int, AnyRef] with Seq[AnyRef] { /** The length of the array */ def length: Int /** The element at given index */ - def apply(index: Int): Object + def apply(index: Int): AnyRef /** Update element at given index */ - def update(index: Int, elem: Object): Unit + def update(index: Int, elem: AnyRef): Unit /** Convert to Java array. * @param elemTag Either one of the tags ".N" where N is the name of a primitive type * (@see ScalaRunTime), or a full class name. */ - def unbox(elemTag: String): Object + def unbox(elemTag: String): AnyRef - def unbox(elemClass: Class): Object + def unbox(elemClass: Class): AnyRef override def isDefinedAt(x: Int): Boolean = 0 <= x && x < length - def elements = new Iterator[Object] { + def elements = new Iterator[AnyRef] { var index = 0 def hasNext: Boolean = index < length - def next: Object = { val i = index; index = i + 1; apply(i) } + def next: AnyRef = { val i = index; index = i + 1; apply(i) } } /** The underlying array value */ - def value: Object + def value: AnyRef - def copyFrom(src: Object, from: Int, to: Int, len: Int): Unit = + def copyFrom(src: AnyRef, from: Int, to: Int, len: Int): Unit = Array.copy(src, from, value, to, len) - def copyTo(from: Int, dest: Object, to: Int, len: Int): Unit = { + def copyTo(from: Int, dest: AnyRef, to: Int, len: Int): Unit = { Array.copy(value, from, dest, to, len) } - override def toArray[b>:Object]: Array[b] = { + override def toArray[b>:AnyRef]: Array[b] = { val len = length val res = new Array[b](len) copyTo(0, res, 0, len) res } - def subArray(from: Int, end: Int): Object + def subArray(from: Int, end: Int): AnyRef - def filter(p: Any => Boolean): Object + def filter(p: Any => Boolean): AnyRef final def map[b](f: Any => b): Array[b] = { val len = length @@ -84,11 +88,11 @@ abstract class BoxedArray extends PartialFunction[Int, Object] with Seq[Object] Array.concat(tmp: _*) } - final def zip[b](that: Array[b]): Array[Tuple2[Object,b]] = { + final def zip[b](that: Array[b]): Array[Tuple2[AnyRef,b]] = { val len = length if(len != that.length) throw new Error("zipping arrays of different length") - val result = new Array[Tuple2[Object,b]](len) + val result = new Array[Tuple2[AnyRef,b]](len) var i = 0 while (i < len) { result(i) = new Tuple2(this(i), that(i)) @@ -97,9 +101,9 @@ abstract class BoxedArray extends PartialFunction[Int, Object] with Seq[Object] result } - final def zipWithIndex: Array[Tuple2[Object,Int]] = { + final def zipWithIndex: Array[Tuple2[AnyRef,Int]] = { val len = length - val result = new Array[Tuple2[Object,Int]](len) + val result = new Array[Tuple2[AnyRef,Int]](len) var i = 0 while (i < len) { result(i) = new Tuple2(this(i), i) diff --git a/src/library/scala/runtime/BoxedBooleanArray.scala b/src/library/scala/runtime/BoxedBooleanArray.scala index a11574653d..ccf3b79461 100644 --- a/src/library/scala/runtime/BoxedBooleanArray.scala +++ b/src/library/scala/runtime/BoxedBooleanArray.scala @@ -12,19 +12,21 @@ package scala.runtime +import Predef.Class + [serializable] final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedBoolean.box(value(index)) + def apply(index: Int): AnyRef = BoxedBoolean.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedBoolean].value } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedByteArray.scala b/src/library/scala/runtime/BoxedByteArray.scala index a7f5a536e3..16792d6de8 100644 --- a/src/library/scala/runtime/BoxedByteArray.scala +++ b/src/library/scala/runtime/BoxedByteArray.scala @@ -12,19 +12,21 @@ package scala.runtime +import Predef.Class + [serializable] final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedByte.box(value(index)) + def apply(index: Int): AnyRef = BoxedByte.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].byteValue() } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedCharArray.scala b/src/library/scala/runtime/BoxedCharArray.scala index fe86be40c5..928d3f67cc 100644 --- a/src/library/scala/runtime/BoxedCharArray.scala +++ b/src/library/scala/runtime/BoxedCharArray.scala @@ -12,19 +12,21 @@ package scala.runtime; +import Predef.Class + [serializable] final class BoxedCharArray(val value: Array[Char]) extends BoxedArray { def length: Int = value.length; - def apply(index: Int): Object = BoxedChar.box(value(index)); + def apply(index: Int): AnyRef = BoxedChar.box(value(index)); - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].charValue() } - def unbox(elemTag: String): Object = value; - def unbox(elemClass: Class): Object = value; + def unbox(elemTag: String): AnyRef = value; + def unbox(elemClass: Class): AnyRef = value; override def equals(other: Any) = ( value == other || diff --git a/src/library/scala/runtime/BoxedDoubleArray.scala b/src/library/scala/runtime/BoxedDoubleArray.scala index 6b22bf846b..55bcfbe520 100644 --- a/src/library/scala/runtime/BoxedDoubleArray.scala +++ b/src/library/scala/runtime/BoxedDoubleArray.scala @@ -12,19 +12,21 @@ package scala.runtime +import Predef.Class + [serializable] final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedDouble.box(value(index)) + def apply(index: Int): AnyRef = BoxedDouble.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].doubleValue() } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedFloatArray.scala b/src/library/scala/runtime/BoxedFloatArray.scala index 1ef4ade45e..a722991e9d 100644 --- a/src/library/scala/runtime/BoxedFloatArray.scala +++ b/src/library/scala/runtime/BoxedFloatArray.scala @@ -12,19 +12,21 @@ package scala.runtime +import Predef.Class + [serializable] final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedFloat.box(value(index)) + def apply(index: Int): AnyRef = BoxedFloat.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].floatValue() } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedIntArray.scala b/src/library/scala/runtime/BoxedIntArray.scala index 7cf7f48521..ad8db390d6 100644 --- a/src/library/scala/runtime/BoxedIntArray.scala +++ b/src/library/scala/runtime/BoxedIntArray.scala @@ -12,19 +12,21 @@ package scala.runtime +import Predef.Class + [serializable] final class BoxedIntArray(val value: Array[Int]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedInt.box(value(index)) + def apply(index: Int): AnyRef = BoxedInt.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].intValue() } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedLongArray.scala b/src/library/scala/runtime/BoxedLongArray.scala index 755fec8f9f..6592cc2408 100644 --- a/src/library/scala/runtime/BoxedLongArray.scala +++ b/src/library/scala/runtime/BoxedLongArray.scala @@ -12,19 +12,21 @@ package scala.runtime +import Predef.Class + [serializable] final class BoxedLongArray(val value: Array[Long]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedLong.box(value(index)) + def apply(index: Int): AnyRef = BoxedLong.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].longValue() } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedObjectArray.scala b/src/library/scala/runtime/BoxedObjectArray.scala index 7aeed09975..2e42c1c4a4 100644 --- a/src/library/scala/runtime/BoxedObjectArray.scala +++ b/src/library/scala/runtime/BoxedObjectArray.scala @@ -12,17 +12,19 @@ package scala.runtime +import Predef.Class + [serializable] -final class BoxedObjectArray(val value: Array[Object]) extends BoxedArray { +final class BoxedObjectArray(val value: Array[AnyRef]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = value(index) + def apply(index: Int): AnyRef = value(index) - def update(index: Int, elem: Object): Unit = { value(index) = elem } + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any): Boolean = value == other || @@ -30,18 +32,18 @@ final class BoxedObjectArray(val value: Array[Object]) extends BoxedArray { override def hashCode(): Int = value.hashCode() - private def create(length: Int): Array[Object] = { + private def create(length: Int): Array[AnyRef] = { val elemClass = value.getClass().getComponentType() - java.lang.reflect.Array.newInstance(elemClass, length).asInstanceOf[Array[Object]] + java.lang.reflect.Array.newInstance(elemClass, length).asInstanceOf[Array[AnyRef]] } - override def subArray(start: Int, end: Int): Array[Object] = { + override def subArray(start: Int, end: Int): Array[AnyRef] = { val result = create(end - start) Array.copy(value, start, result, 0, end - start) result } - override def filter(p: Any => Boolean): Array[Object] = { + override def filter(p: Any => Boolean): Array[AnyRef] = { val include = new Array[Boolean](value.length) var len = 0 var i = 0 diff --git a/src/library/scala/runtime/BoxedShortArray.scala b/src/library/scala/runtime/BoxedShortArray.scala index 9179178a32..f1b37ca5b0 100644 --- a/src/library/scala/runtime/BoxedShortArray.scala +++ b/src/library/scala/runtime/BoxedShortArray.scala @@ -12,19 +12,21 @@ package scala.runtime; +import Predef.Class + [serializable] final class BoxedShortArray(val value: Array[Short]) extends BoxedArray { def length: Int = value.length - def apply(index: Int): Object = BoxedShort.box(value(index)) + def apply(index: Int): AnyRef = BoxedShort.box(value(index)) - def update(index: Int, elem: Object): Unit = { + def update(index: Int, elem: AnyRef): Unit = { value(index) = elem.asInstanceOf[BoxedNumber].shortValue() } - def unbox(elemTag: String): Object = value - def unbox(elemClass: Class): Object = value + def unbox(elemTag: String): AnyRef = value + def unbox(elemClass: Class): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/NonLocalReturnException.scala b/src/library/scala/runtime/NonLocalReturnException.scala index c5051a5ed9..8043b6de81 100644 --- a/src/library/scala/runtime/NonLocalReturnException.scala +++ b/src/library/scala/runtime/NonLocalReturnException.scala @@ -12,4 +12,4 @@ package scala.runtime -class NonLocalReturnException[T](val key: Object, val value: T) extends RuntimeException +class NonLocalReturnException[T](val key: AnyRef, val value: T) extends RuntimeException diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index a052335719..d4010bd7ba 100755 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -11,8 +11,8 @@ package scala.runtime - -import compat.Platform.NoSuchElementException +import Predef._ +import compat.Math final class RichString(s: String) { @@ -117,5 +117,12 @@ final class RichString(s: String) { * */ def stripMargin: String = stripMargin('|') -} + def toByte: Byte = java.lang.Byte.parseByte(s) + def toShort: Short = java.lang.Short.parseShort(s) + def toInt: Int = java.lang.Integer.parseInt(s) + def toLong: Long = java.lang.Long.parseLong(s) + def toFloat: Float = java.lang.Float.parseFloat(s) + def toDouble: Double = java.lang.Double.parseDouble(s) + +} diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index dfd79c84f8..10d8683891 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -12,6 +12,9 @@ package scala.runtime; +import Predef.{Class, Throwable} +import java.lang.Runnable + object ScalaRunTime { /** Names for primitive types, used by array unboxing */ @@ -114,12 +117,12 @@ object ScalaRunTime { def longValue (x: BoxedNumber ): Long = if (x eq null) 0L else x.longValue(); def floatValue (x: BoxedNumber ): Float = if (x eq null) 0.0F else x.floatValue(); def doubleValue (x: BoxedNumber ): Double = if (x eq null) 0.0D else x.doubleValue(); - def arrayValue (x: BoxedArray, elemTag: String): Object = + def arrayValue (x: BoxedArray, elemTag: String): AnyRef = if (x eq null) null else x.unbox(elemTag); - def arrayValue (x: BoxedArray, elemClass: Class): Object = + def arrayValue (x: BoxedArray, elemClass: Class): AnyRef = if (x eq null) null else x.unbox(elemClass); - def boxArray(value: Object): BoxedArray = value match { + def boxArray(value: AnyRef): BoxedArray = value match { case x: Array[Byte] => new BoxedByteArray(x) case x: Array[Short] => new BoxedShortArray(x) case x: Array[Char] => new BoxedCharArray(x) @@ -128,7 +131,7 @@ object ScalaRunTime { case x: Array[Float] => new BoxedFloatArray(x) case x: Array[Double] => new BoxedDoubleArray(x) case x: Array[Boolean] => new BoxedBooleanArray(x) - case x: Array[Object] => new BoxedObjectArray(x) + case x: Array[AnyRef] => new BoxedObjectArray(x) case x: BoxedArray => x } } diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala index c3ccacb084..7f4db62de8 100644 --- a/src/library/scala/testing/Benchmark.scala +++ b/src/library/scala/testing/Benchmark.scala @@ -12,6 +12,8 @@ package scala.testing +import compat.Platform + /** Benchmark can be used to quickly turn an existing * class into a benchmark. Here is a short example: * @@ -47,10 +49,10 @@ trait Benchmark { */ def runBenchmark(noTimes: Int): List[Long] = for (val i <- List.range(1, noTimes + 1)) yield { - val startTime = System.currentTimeMillis() + val startTime = Platform.currentTime run - val stopTime = System.currentTimeMillis() - System.gc() + val stopTime = Platform.currentTime + Platform.collectGarbage stopTime - startTime } @@ -63,13 +65,12 @@ trait Benchmark { def main(args: Array[String]): Unit = { if (args.length > 1) { val logFile = new java.io.FileWriter(args(1), true) // append, not overwrite - val eol = System.getProperty("line.separator", "\n") logFile.write(getClass().getName()) - for (val t <- runBenchmark(Integer.parseInt(args(0)))) + for (val t <- runBenchmark(args(0).toInt)) logFile.write("\t\t" + t) - logFile.write(eol) + logFile.write(Platform.EOL) logFile.flush() } else Console.println("Usage: scala benchmarks.program ") diff --git a/src/library/scala/util/Fluid.scala b/src/library/scala/util/Fluid.scala index 80725d3bb3..ebfefada35 100644 --- a/src/library/scala/util/Fluid.scala +++ b/src/library/scala/util/Fluid.scala @@ -6,10 +6,14 @@ ** |/ ** \* */ -// $Id: $ +// $Id$ + package scala.util + +import java.lang.InheritableThreadLocal + /** Fluids provide a binding mechanism where the current * value is found through dynamic scope, but where * access to the fluid itself is resolved through static @@ -43,7 +47,7 @@ package scala.util */ class Fluid[T](init: T) { private val tl = new InheritableThreadLocal { - override def initialValue = init.asInstanceOf[Object] + override def initialValue = init.asInstanceOf[AnyRef] } /** Retrieve the current value */ diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala index e0198a4592..7a7a6c642f 100644 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ b/src/library/scala/util/automata/BaseBerrySethi.scala @@ -17,8 +17,6 @@ import scala.util.regexp.Base import scala.collection.mutable import scala.collection.immutable import compat.Platform -import Platform.IllegalArgumentException - /** this turns a regexp over A into a NondetWorkAutom over A using the * celebrated position automata construction (also called Berry-Sethi or diff --git a/src/library/scala/util/parsing/SimpleTokenizer.scala b/src/library/scala/util/parsing/SimpleTokenizer.scala index 7ac76fac79..b7bab36e81 100644 --- a/src/library/scala/util/parsing/SimpleTokenizer.scala +++ b/src/library/scala/util/parsing/SimpleTokenizer.scala @@ -57,7 +57,7 @@ class SimpleTokenizer(in: Iterator[char], delimiters: String) extends Iterator[S ch = nextChar } } - if (tracing) System.out.println("<" + buf.toString() + ">") + if (tracing) Console.println("<" + buf.toString() + ">") buf.toString() } } diff --git a/src/library/scala/xml/Comment.scala b/src/library/scala/xml/Comment.scala index 2574f2ef99..2f4ad96e9e 100644 --- a/src/library/scala/xml/Comment.scala +++ b/src/library/scala/xml/Comment.scala @@ -11,8 +11,8 @@ package scala.xml + import compat.StringBuilder -import compat.Platform.IllegalArgumentException /** an XML node for comments. * diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index ae79835096..96b571c505 100644 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -12,8 +12,6 @@ package scala.xml; -import compat.Platform.IllegalArgumentException - /** The case class Elem extends the Node class, * providing an immutable data object representing an XML element. * diff --git a/src/library/scala/xml/Group.scala b/src/library/scala/xml/Group.scala index 9e98408e14..fb39e060f5 100644 --- a/src/library/scala/xml/Group.scala +++ b/src/library/scala/xml/Group.scala @@ -13,7 +13,6 @@ package scala.xml import compat.StringBuilder -import compat.Platform.UnsupportedOperationException /** A hack to group XML nodes in one node for output. * diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala index f95ffbbf25..0a3f860803 100644 --- a/src/library/scala/xml/NamespaceBinding.scala +++ b/src/library/scala/xml/NamespaceBinding.scala @@ -12,8 +12,8 @@ package scala.xml +import Predef.IllegalArgumentException import compat.StringBuilder -import compat.Platform.IllegalArgumentException /** The class NamespaceBinding represents namespace bindings * and scopes. The binding for the default namespace is treated as a null diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala index 952e4474c0..96ba45c73c 100644 --- a/src/library/scala/xml/PrefixedAttribute.scala +++ b/src/library/scala/xml/PrefixedAttribute.scala @@ -12,7 +12,6 @@ package scala.xml import compat.StringBuilder -import compat.Platform.UnsupportedOperationException /** prefixed attributes always have a non-null namespace. * @param value the attribute value, which may not be null diff --git a/src/library/scala/xml/ProcInstr.scala b/src/library/scala/xml/ProcInstr.scala index daf4e7da12..a355bb3eb4 100644 --- a/src/library/scala/xml/ProcInstr.scala +++ b/src/library/scala/xml/ProcInstr.scala @@ -13,7 +13,6 @@ package scala.xml; import compat.StringBuilder -import compat.Platform.IllegalArgumentException /** an XML node for processing instructions (PI) * diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 1041faa2aa..0072f120fa 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -67,7 +67,7 @@ object Utility extends AnyRef with parsing.TokenTests { case "gt" => s.append('>') case "amp" => s.append('&') case "quot" => s.append('"') - case "apos" => s.append(''') + case "apos" => s.append('\'') case _ => null } @@ -426,20 +426,20 @@ object Utility extends AnyRef with parsing.TokenTests { while (ch() != ';') { ch() match { case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => - i = i * base + Character.digit(ch(), base) + i = i * base + ch().asDigit case 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' => if (! hex) reportSyntaxError("hex char not allowed in decimal char ref\n" + "Did you mean to write &#x ?") else - i = i * base + Character.digit(ch(), base) + i = i * base + ch().asDigit case _ => reportSyntaxError("character '" + ch() + " not allowed in char ref\n") } nextch() } - String.valueOf(i.asInstanceOf[char]) + i.asInstanceOf[char].toString() } } diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala index 5413c9d884..3a000baac5 100644 --- a/src/library/scala/xml/dtd/Decl.scala +++ b/src/library/scala/xml/dtd/Decl.scala @@ -13,7 +13,6 @@ package scala.xml.dtd; import compat.StringBuilder -import compat.Platform.IllegalArgumentException abstract class Decl; diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala index a292f715bd..e31f43990f 100644 --- a/src/library/scala/xml/dtd/DocType.scala +++ b/src/library/scala/xml/dtd/DocType.scala @@ -12,8 +12,6 @@ package scala.xml.dtd; -import compat.Platform.IllegalArgumentException - /** an XML node for document type declaration * * @author Burak Emir diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala index c6fba94e48..6fa5d4823d 100644 --- a/src/library/scala/xml/dtd/ExternalID.scala +++ b/src/library/scala/xml/dtd/ExternalID.scala @@ -13,7 +13,6 @@ package scala.xml.dtd; import compat.StringBuilder -import compat.Platform.IllegalArgumentException /** an ExternalIDs - either PublicID or SystemID * diff --git a/src/library/scala/xml/parsing/FactoryAdapter.scala b/src/library/scala/xml/parsing/FactoryAdapter.scala index 867cbc8fb6..b8eff87251 100644 --- a/src/library/scala/xml/parsing/FactoryAdapter.scala +++ b/src/library/scala/xml/parsing/FactoryAdapter.scala @@ -13,6 +13,7 @@ package scala.xml.parsing import java.io._ import scala.collection.mutable.{HashMap,Stack} +import compat.StringBuilder import org.xml.sax.Attributes import org.xml.sax.ContentHandler @@ -38,7 +39,7 @@ import javax.xml.parsers.SAXParser */ abstract class FactoryAdapter extends DefaultHandler() { - val buffer = new StringBuffer() + val buffer = new StringBuilder() val attribStack = new Stack[MetaData] val hStack = new Stack[Node] // [ element ] contains siblings val tagStack = new Stack[String] @@ -87,7 +88,7 @@ abstract class FactoryAdapter extends DefaultHandler() { var i: Int = offset var ws = false while (i < offset + length) { - if (Character.isWhitespace(ch(i))) { + if (ch(i).isWhitespace) { if (!ws) { buffer.append(' ') ws = true @@ -235,27 +236,28 @@ abstract class FactoryAdapter extends DefaultHandler() { // /** Prints the error message */ - protected def printError(errtype: String, ex: SAXParseException): Unit = { - System.err.print("[") - System.err.print(errtype) - System.err.print("] ") + protected def printError(errtype: String, ex: SAXParseException): Unit = + Console.withOut(Console.err) { + Console.print("[") + Console.print(errtype) + Console.print("] ") var systemId = ex.getSystemId() if (systemId != null) { val index = systemId.lastIndexOf('/'.asInstanceOf[Int]) if (index != -1) systemId = systemId.substring(index + 1) - //System.err.print(systemId) + //Console.print(systemId) } - System.err.print(':') - System.err.print(ex.getLineNumber()) - System.err.print(':') - System.err.print(ex.getColumnNumber()) - System.err.print(": ") - System.err.print(ex.getMessage()) - System.err.println() - System.err.flush() + Console.print(':') + Console.print(ex.getLineNumber()) + Console.print(':') + Console.print(ex.getColumnNumber()) + Console.print(": ") + Console.print(ex.getMessage()) + Console.println + Console.flush } var rootElem: Node = null:Node @@ -276,13 +278,13 @@ abstract class FactoryAdapter extends DefaultHandler() { f.newSAXParser() } catch { case e: Exception => - System.err.println("error: Unable to instantiate parser") + Console.err.println("error: Unable to instantiate parser") exit(1) } // parse file //try { - //System.err.println("[parsing \"" + source + "\"]"); + //Console.err.println("[parsing \"" + source + "\"]"); scopeStack.push(TopScope) parser.parse(source, this) scopeStack.pop @@ -292,7 +294,7 @@ abstract class FactoryAdapter extends DefaultHandler() { // ignore } case ( e:Exception ) => { - System.err.println("error: Parse error occurred - " + e.getMessage()); + Console.err.println("error: Parse error occurred - " + e.getMessage()); if (e.isInstanceOf[ SAXException ]) { (e.asInstanceOf[ SAXException ]) .getException() @@ -303,7 +305,7 @@ abstract class FactoryAdapter extends DefaultHandler() { } } // catch */ - //System.err.println("[FactoryAdapter: total #elements = "+elemCount+"]"); + //Console.err.println("[FactoryAdapter: total #elements = "+elemCount+"]"); rootElem } // loadXML diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index a8888a8b86..b89bdb764d 100644 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -11,6 +11,9 @@ package scala.xml.pull + +import java.lang.{Runnable, Thread} + import scala.io.Source import scala.xml.parsing.{MarkupParser, MarkupHandler,ExternalSources} diff --git a/src/library/scala/xml/transform/BasicTransformer.scala b/src/library/scala/xml/transform/BasicTransformer.scala index 4dab95b6f2..8364e498d4 100644 --- a/src/library/scala/xml/transform/BasicTransformer.scala +++ b/src/library/scala/xml/transform/BasicTransformer.scala @@ -12,8 +12,6 @@ package scala.xml.transform -import compat.Platform.UnsupportedOperationException - /** A class for XML transformations. * * @author Burak Emir -- cgit v1.2.3