summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2006-10-24 14:06:06 +0000
committermihaylov <mihaylov@epfl.ch>2006-10-24 14:06:06 +0000
commit7e705baa349c3fc00c6ac9a5da60db4121944d5c (patch)
tree2e3f6afcb8b64e998fe4b4b32d61c5f0d6d3dcd1 /src
parent2f5a1ddcde2ec8150b0fafec755b9f8bf14a65d6 (diff)
downloadscala-7e705baa349c3fc00c6ac9a5da60db4121944d5c.tar.gz
scala-7e705baa349c3fc00c6ac9a5da60db4121944d5c.tar.bz2
scala-7e705baa349c3fc00c6ac9a5da60db4121944d5c.zip
Mapped Java exceptions via scala.compat.Platform
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/Iterable.scala3
-rw-r--r--src/library/scala/Iterator.scala23
-rw-r--r--src/library/scala/List.scala23
-rw-r--r--src/library/scala/Option.scala6
-rw-r--r--src/library/scala/Seq.scala2
-rw-r--r--src/library/scala/Stream.scala14
-rw-r--r--src/library/scala/collection/Map.scala6
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala4
-rw-r--r--src/library/scala/collection/immutable/ListSet.scala10
-rw-r--r--src/library/scala/collection/immutable/Queue.scala10
-rw-r--r--src/library/scala/collection/immutable/Stack.scala4
-rw-r--r--src/library/scala/collection/immutable/Tree.scala3
-rw-r--r--src/library/scala/collection/mutable/Buffer.scala1
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala15
-rw-r--r--src/library/scala/collection/mutable/Map.scala2
-rw-r--r--src/library/scala/collection/mutable/Message.scala2
-rw-r--r--src/library/scala/collection/mutable/MutableList.scala5
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala2
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala6
-rw-r--r--src/library/scala/collection/mutable/Queue.scala8
-rw-r--r--src/library/scala/collection/mutable/Set.scala6
-rw-r--r--src/library/scala/collection/mutable/Stack.scala8
-rw-r--r--src/library/scala/compat/Platform.scala13
-rw-r--r--src/library/scala/concurrent/Actor.scala3
-rw-r--r--src/library/scala/concurrent/NameServer.scala3
-rw-r--r--src/library/scala/concurrent/Process.scala5
-rw-r--r--src/library/scala/io/BytePickle.scala2
-rw-r--r--src/library/scala/io/Position.scala2
-rw-r--r--src/library/scala/io/Source.scala6
-rwxr-xr-xsrc/library/scala/runtime/RichString.scala4
-rw-r--r--src/library/scala/testing/SUnit.scala11
-rw-r--r--src/library/scala/util/automata/BaseBerrySethi.scala2
-rw-r--r--src/library/scala/xml/Comment.scala1
-rw-r--r--src/library/scala/xml/Elem.scala2
-rw-r--r--src/library/scala/xml/Group.scala12
-rw-r--r--src/library/scala/xml/NamespaceBinding.scala2
-rw-r--r--src/library/scala/xml/PrefixedAttribute.scala1
-rw-r--r--src/library/scala/xml/ProcInstr.scala2
-rw-r--r--src/library/scala/xml/dtd/Decl.scala2
-rw-r--r--src/library/scala/xml/dtd/DocType.scala2
-rw-r--r--src/library/scala/xml/dtd/ExternalID.scala2
-rw-r--r--src/library/scala/xml/transform/BasicTransformer.scala4
42 files changed, 158 insertions, 86 deletions
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 2ab18f1f7b..0545b8538e 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -11,6 +11,9 @@
package scala
+
+import compat.Platform.IllegalArgumentException
+
/** This object ...
*
* @author Matthias Zenger
diff --git a/src/library/scala/Iterator.scala b/src/library/scala/Iterator.scala
index 54a3c92d62..0959dfa958 100644
--- a/src/library/scala/Iterator.scala
+++ b/src/library/scala/Iterator.scala
@@ -13,6 +13,7 @@ package scala
import Predef._
+import compat.Platform.NoSuchElementException
/** The <code>Iterator</code> object provides various functions for
* creating specialized iterators.
@@ -25,7 +26,7 @@ object Iterator {
def empty[a] = new Iterator[a] {
def hasNext: Boolean = false
- def next: a = throw new java.util.NoSuchElementException("next on empty iterator")
+ def next: a = throw new NoSuchElementException("next on empty iterator")
}
def single[a](x: a) = new Iterator[a] {
@@ -33,7 +34,7 @@ object Iterator {
def hasNext: Boolean = hasnext
def next: a =
if (hasnext) { hasnext = false; x }
- else throw new java.util.NoSuchElementException("next on empty iterator")
+ else throw new NoSuchElementException("next on empty iterator")
}
def fromValues[a](xs: a*) = xs.elements
@@ -53,9 +54,9 @@ object Iterator {
val end = if ((start + length) < xs.length) start else xs.length
def hasNext: Boolean = i < end
def next: a = if (hasNext) { val x = xs(i) ; i = i + 1 ; x }
- else throw new java.util.NoSuchElementException("next on empty iterator")
+ else throw new NoSuchElementException("next on empty iterator")
def head: a = if (hasNext) xs(i);
- else throw new java.util.NoSuchElementException("head on empty iterator")
+ else throw new NoSuchElementException("head on empty iterator")
}
def fromString(str: String): Iterator[Char] =
@@ -103,10 +104,10 @@ object Iterator {
def hasNext: Boolean = if (step > 0) i < end else i > end
def next: Int =
if (hasNext) { val j = i; i = i + step; j }
- else throw new java.util.NoSuchElementException("next on empty iterator")
+ else throw new NoSuchElementException("next on empty iterator")
def head: Int =
if (hasNext) i
- else throw new java.util.NoSuchElementException("head on empty iterator")
+ else throw new NoSuchElementException("head on empty iterator")
}
}
@@ -126,10 +127,10 @@ object Iterator {
def hasNext: Boolean = i < end
def next: Int =
if (i < end) { val j = i; i = step(i); j }
- else throw new java.util.NoSuchElementException("next on empty iterator")
+ else throw new NoSuchElementException("next on empty iterator")
def head: Int =
if (i < end) i
- else throw new java.util.NoSuchElementException("head on empty iterator")
+ else throw new NoSuchElementException("head on empty iterator")
}
/** Create an iterator with elements
@@ -203,7 +204,7 @@ trait Iterator[+A] {
def hasNext = remaining > 0 && Iterator.this.hasNext
def next: A =
if (hasNext) { remaining = remaining - 1; Iterator.this.next }
- else throw new java.util.NoSuchElementException("next on empty iterator")
+ else throw new NoSuchElementException("next on empty iterator")
}
/** Removes the first <code>n</code> elements from this iterator.
@@ -247,7 +248,7 @@ trait Iterator[+A] {
else if (Iterator.this.hasNext) {
cur = f(Iterator.this.next)
next
- } else throw new java.util.NoSuchElementException("next on empty iterator")
+ } else throw new NoSuchElementException("next on empty iterator")
}
/** Returns an iterator over all the elements of this iterator that
@@ -270,7 +271,7 @@ trait Iterator[+A] {
def hasNext: Boolean = { skip; ahead || hasMore }
def next: A =
if (hasNext) { ahead = false; hd }
- else throw new java.util.NoSuchElementException("next on empty iterator");
+ else throw new NoSuchElementException("next on empty iterator");
def head: A = { skip; hd }
}
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index 6b2c0ef1cf..88e1f94574 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -13,6 +13,7 @@ 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).
@@ -380,13 +381,13 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
/** Returns this first element of the list.
* @return the first element of this list.
- * @throws <code>java.lang.RuntimeException</code> if the list is empty.
+ * @throws <code>scala.compat.Platform.NoSuchElementException</code> if the list is empty.
*/
def head: a
/** Returns this list without its first element.
* @return this list without its first element.
- * @throws <code>java.lang.RuntimeException</code> if the list is empty.
+ * @throws <code>scala.compat.Platform.NoSuchElementException</code> if the list is empty.
*/
def tail: List[a]
@@ -472,7 +473,7 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
def hasNext: Boolean = !these.isEmpty
def next: a =
if (!hasNext)
- throw new java.util.NoSuchElementException("next on empty Iterator")
+ throw new NoSuchElementException("next on empty Iterator")
else {
val result = these.head; these = these.tail; result
}
@@ -488,7 +489,8 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
/** Returns the list without its last element.
*
* @return the list without its last element.
- * @throws <code>java.lang.RuntimeException</code> if the list is empty.
+ * @throws <code>scala.compat.Platform.UnsupportedOperationException</code>
+ * if the list is empty.
*/
def init: List[a] =
if (isEmpty) throw new UnsupportedOperationException("Nil.init")
@@ -507,7 +509,8 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
/** Returns the last element of this list.
*
* @return the last element of the list.
- * @throws <code>java.lang.RuntimeException</code> if the list is empty.
+ * @throws <code>scala.compat.Platform.UnsupportedOperationException</code>
+ * if the list is empty.
*/
def last: a =
if (isEmpty) throw new UnsupportedOperationException("Nil.last")
@@ -1090,16 +1093,10 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass {
[SerialVersionUID(0 - 8256821097970055419L)]
case object Nil extends List[Nothing] {
override def isEmpty = true
- /**
- * @throws java.util.NoSuchElementException
- */
def head: Nothing =
- throw new java.util.NoSuchElementException("head of empty list")
- /**
- * @throws java.util.NoSuchElementException
- */
+ throw new NoSuchElementException("head of empty list")
def tail: List[Nothing] =
- throw new java.util.NoSuchElementException("tail of empty list")
+ throw new NoSuchElementException("tail of empty list")
}
/** A non empty list characterized by a head and a tail.
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index 636f32d59e..e140cbc6e6 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -11,7 +11,9 @@
package scala;
+
import Predef._
+import compat.Platform.NoSuchElementException
/** This class represents optional values. Instances of <code>Option</code>
* are either instances of case class <code>Some</code> or it is case
@@ -29,10 +31,10 @@ sealed abstract class Option[+A] extends Iterable[A] with CaseClass {
}
/**
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
*/
def get: A = this match {
- case None => throw new java.util.NoSuchElementException("None.get")
+ case None => throw new NoSuchElementException("None.get")
case Some(x) => x
}
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index 8c9f896814..a9fcf2524c 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -12,6 +12,8 @@
package scala
+import compat.Platform.IllegalArgumentException
+
object Seq {
/** builds a singleton sequence
diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala
index 4634bbdb19..d873502056 100644
--- a/src/library/scala/Stream.scala
+++ b/src/library/scala/Stream.scala
@@ -11,7 +11,9 @@
package scala
+
import compat.StringBuilder
+import compat.Platform.NoSuchElementException
/**
* The object <code>Stream</code> provides helper functions
@@ -24,8 +26,8 @@ object Stream {
val empty: Stream[Nothing] = new Stream[Nothing] {
override def isEmpty = true
- def head: Nothing = throw new java.util.NoSuchElementException("head of empty stream")
- def tail: Stream[Nothing] = throw new java.util.NoSuchElementException("tail of empty stream")
+ def head: Nothing = throw new NoSuchElementException("head of empty stream")
+ def tail: Stream[Nothing] = throw new NoSuchElementException("tail of empty stream")
def printElems(buf: StringBuilder, prefix: String): StringBuilder = buf
}
@@ -163,12 +165,12 @@ trait Stream[+a] extends Seq[a] {
}
def init: Stream[a] =
- if (isEmpty) throw new java.util.NoSuchElementException("Stream.empty.init")
+ if (isEmpty) throw new NoSuchElementException("Stream.empty.init")
else if (tail.isEmpty) Stream.empty
else Stream.cons(head, tail.init)
def last: a =
- if (isEmpty) throw new java.util.NoSuchElementException("Stream.empty.last")
+ if (isEmpty) throw new NoSuchElementException("Stream.empty.last")
else {
def loop(s: Stream[a]): a = {
if (s.tail.isEmpty) s.head
@@ -251,11 +253,11 @@ trait Stream[+a] extends Seq[a] {
else f(head, tail.foldRight(z)(f))
def reduceLeft[b >: a](f: (b, b) => b): b =
- if (isEmpty) throw new java.util.NoSuchElementException("Stream.empty.reduceLeft")
+ if (isEmpty) throw new NoSuchElementException("Stream.empty.reduceLeft")
else ((tail: Stream[b]) foldLeft (head: b))(f)
def reduceRight[b >: a](f: (b, b) => b): b =
- if (isEmpty) throw new java.util.NoSuchElementException("Stream.empty.reduceRight")
+ if (isEmpty) throw new NoSuchElementException("Stream.empty.reduceRight")
else if (tail.isEmpty) head: b
else f(head, tail.reduceRight(f))
diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala
index 8d5719f5c3..5472aadd1b 100644
--- a/src/library/scala/collection/Map.scala
+++ b/src/library/scala/collection/Map.scala
@@ -11,6 +11,9 @@
package scala.collection
+
+import compat.Platform.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).
* Class <code>Map</code> may only be used for
@@ -139,6 +142,5 @@ trait Map[A, +B] extends AnyRef
* @param key ...
*/
def default(key: A): B =
- throw new java.util.NoSuchElementException("key not found: " + key)
+ throw new NoSuchElementException("key not found: " + key)
}
-
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 6ead04fdfd..5ece1d0286 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import compat.Platform.NoSuchElementException
+
object ListMap {
def Empty[A, B] = new ListMap[A, B]
}
@@ -27,8 +29,6 @@ object ListMap {
[serializable]
class ListMap[A, B] extends AnyRef with Map[A, B] {
- import java.util.NoSuchElementException
-
/** This method returns a new ListMap instance mapping keys of the
* same type to values of type <code>C</code>.
*/
diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala
index 65d5c930ed..19c74bbb27 100644
--- a/src/library/scala/collection/immutable/ListSet.scala
+++ b/src/library/scala/collection/immutable/ListSet.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import compat.Platform.NoSuchElementException
+
object ListSet {
/** constructs an empty ListSet
*/
@@ -30,8 +32,6 @@ object ListSet {
[serializable]
class ListSet[A] extends AnyRef with Set[A] {
- import java.util.NoSuchElementException
-
/** Returns the number of elements in this set.
*
* @return number of set elements.
@@ -60,7 +60,7 @@ class ListSet[A] extends AnyRef with Set[A] {
/** Creates a new iterator over all elements contained in this set.
*
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the new iterator
*/
def elements: Iterator[A] = new Iterator[A] {
@@ -82,12 +82,12 @@ class ListSet[A] extends AnyRef with Set[A] {
false
/**
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
*/
protected def elem: A = throw new NoSuchElementException("Set has no elelemnts");
/**
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
*/
protected def next: ListSet[A] = throw new NoSuchElementException("Next of an empty set");
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 88cf3d7016..46096d7e4c 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import compat.Platform.NoSuchElementException
+
object Queue {
val Empty: Queue[Nothing] = new Queue()
}
@@ -25,8 +27,6 @@ object Queue {
[serializable]
class Queue[+A](elem: A*) extends Seq[A] {
- import java.util.NoSuchElementException
-
protected val in: List[A] = Nil
protected val out: List[A] = elem.elements.toList
@@ -41,7 +41,7 @@ class Queue[+A](elem: A*) extends Seq[A] {
*
* @param n index of the element to return
* @return the element at position <code>n</code> in this queue.
- * @throws java.util.NoSuchElementException if the queue is too short.
+ * @throws scala.compat.Platform.NoSuchElementException if the queue is too short.
*/
def apply(n: Int): A = {
val len = out.length
@@ -97,7 +97,7 @@ class Queue[+A](elem: A*) extends Seq[A] {
/** Returns a tuple with the first element in the queue,
* and a new queue with this element removed.
*
- * @throws NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the first element of the queue.
*/
def dequeue: Pair[A, Queue[A]] = {
@@ -111,7 +111,7 @@ class Queue[+A](elem: A*) extends Seq[A] {
/** Returns the first element in the queue, or throws an error if there
* is no element contained in the queue.
*
- * @throws NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the first element.
*/
def front: A =
diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala
index 457efada8d..9599b40f97 100644
--- a/src/library/scala/collection/immutable/Stack.scala
+++ b/src/library/scala/collection/immutable/Stack.scala
@@ -12,6 +12,8 @@
package scala.collection.immutable
+import compat.Platform.NoSuchElementException
+
object Stack {
val Empty = new Stack[Nothing]
}
@@ -27,8 +29,6 @@ object Stack {
[serializable]
class Stack[+A] extends Seq[A] {
- import java.util.NoSuchElementException
-
/** Checks if this stack is empty.
*
* @return true, iff there is no element on the stack.
diff --git a/src/library/scala/collection/immutable/Tree.scala b/src/library/scala/collection/immutable/Tree.scala
index 96311936ba..3bb0eb8ced 100644
--- a/src/library/scala/collection/immutable/Tree.scala
+++ b/src/library/scala/collection/immutable/Tree.scala
@@ -39,7 +39,8 @@
package scala.collection.immutable
-import java.util.NoSuchElementException
+
+import compat.Platform.NoSuchElementException
/** <p>
* 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 6e1d9e4475..21bee72a02 100644
--- a/src/library/scala/collection/mutable/Buffer.scala
+++ b/src/library/scala/collection/mutable/Buffer.scala
@@ -13,6 +13,7 @@ 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 1f4a975288..47cd64c74e 100644
--- a/src/library/scala/collection/mutable/ListBuffer.scala
+++ b/src/library/scala/collection/mutable/ListBuffer.scala
@@ -13,6 +13,7 @@ package scala.collection.mutable
import Predef._
+import compat.Platform.{IndexOutOfBoundsException, NoSuchElementException}
/** The class <code>ListBuffer</code> ..
*
@@ -125,7 +126,7 @@ final class ListBuffer[A] extends Buffer[A] {
*
* @param n the position of the element to be returned.
* @return the n-th element of this buffer.
- * @throws IndexOutOfBoundsException
+ * @throws scala.compat.Platform.IndexOutOfBoundsException
*/
def apply(n: Int): A = try {
start(n)
@@ -135,11 +136,11 @@ final class ListBuffer[A] extends Buffer[A] {
}
/** Replaces element at index <code>n</code> with the new element
- * <code>newelem</code>. Throws IndexOutOfBoundsException if
- * n is out of bounds.
+ * <code>newelem</code>.
*
* @param n the index of the element to replace.
* @param x the new element.
+ * @throws scala.compat.Platform.IndexOutOfBoundsException if <code>n</code> is out of bounds.
*/
def update(n: Int, x: A): unit = try {
if (exported) copy()
@@ -168,7 +169,7 @@ final class ListBuffer[A] extends Buffer[A] {
*
* @param n the index where a new element will be inserted.
* @param iter the iterable object providing all elements to insert.
- * @throws IndexOutOfBoundsException if <code>n</code> is out of bounds.
+ * @throws scala.compat.Platform.IndexOutOfBoundsException if <code>n</code> is out of bounds.
*/
def insertAll(n: Int, iter: Iterable[A]): unit = try {
if (exported) copy()
@@ -205,7 +206,7 @@ final class ListBuffer[A] extends Buffer[A] {
* @param n the index which refers to the element to delete.
* @return n the element that was formerly at position <code>n</code>.
* @pre an element exists at position <code>n</code>
- * @throws IndexOutOfBoundsException if <code>n</code> is out of bounds.
+ * @throws scala.compat.Platform.IndexOutOfBoundsException if <code>n</code> is out of bounds.
*/
def remove(n: Int): A = try {
if (exported) copy()
@@ -239,14 +240,14 @@ final class ListBuffer[A] extends Buffer[A] {
* <code>toList.elements</code>.
* </blockquote>
*
- * @throws NoSuchElementException if buffer is empty
+ * @throws scala.compat.Platform.NoSuchElementException if buffer is empty
*/
override def elements = new Iterator[A] {
var cursor: List[A] = null
def hasNext: Boolean = !start.isEmpty && cursor != last
def next: A =
if (!hasNext) {
- throw new java.util.NoSuchElementException("next on empty Iterator")
+ throw new NoSuchElementException("next on empty Iterator")
} else {
if (cursor == null) cursor = start else cursor = cursor.tail
cursor.head
diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala
index 4b0c5e6b16..36565a0493 100644
--- a/src/library/scala/collection/mutable/Map.scala
+++ b/src/library/scala/collection/mutable/Map.scala
@@ -11,6 +11,8 @@
package scala.collection.mutable
+import compat.Platform.UnsupportedOperationException
+
/** This class represents mutable maps. Concrete map implementations
* just have to provide functionality for the abstract methods in
* <code>scala.collection.Map</code> as well as for <code>update</code>,
diff --git a/src/library/scala/collection/mutable/Message.scala b/src/library/scala/collection/mutable/Message.scala
index c5eae4eac7..337083b9e3 100644
--- a/src/library/scala/collection/mutable/Message.scala
+++ b/src/library/scala/collection/mutable/Message.scala
@@ -12,6 +12,8 @@
package scala.collection.mutable
+import compat.Platform.UnsupportedOperationException
+
/** Class <code>Message</code> represents messages that are issued by observable
* collection classes whenever a data structure is changed. Class <code>Message</code>
* has several subclasses for the various kinds of events: <code>Update</code>
diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala
index 6e5059d4a5..f0349f584a 100644
--- a/src/library/scala/collection/mutable/MutableList.scala
+++ b/src/library/scala/collection/mutable/MutableList.scala
@@ -11,6 +11,9 @@
package scala.collection.mutable
+import compat.Platform.NoSuchElementException
+
+
/** This class is used internally to represent mutable lists. It is the
* basis for the implementation of the classes <code>Buffer</code>,
* <code>Stack</code>, and <code>Queue</code>.
@@ -32,7 +35,7 @@ trait MutableList[A] extends Seq[A] with PartialFunction[Int, A] {
* yields an error if the element does not exist.
*/
def apply(n: Int): A = get(n) match {
- case None => throw new java.util.NoSuchElementException("element not found")
+ case None => throw new NoSuchElementException("element not found")
case Some(value) => value
}
diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala
index 0ec53babd2..a38e442468 100644
--- a/src/library/scala/collection/mutable/ObservableBuffer.scala
+++ b/src/library/scala/collection/mutable/ObservableBuffer.scala
@@ -12,6 +12,8 @@
package scala.collection.mutable
+import compat.Platform.UnsupportedOperationException
+
/** This class is typically used as a mixin. It adds a subscription
* mechanism to the <code>Buffer</code> class into which this abstract
* class is mixed in. Class <code>ObservableBuffer</code> publishes
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala
index 0c029dbe49..d32bb60376 100644
--- a/src/library/scala/collection/mutable/PriorityQueue.scala
+++ b/src/library/scala/collection/mutable/PriorityQueue.scala
@@ -12,6 +12,8 @@
package scala.collection.mutable
+import compat.Platform.{NoSuchElementException, UnsupportedOperationException}
+
/** This class implements priority queues using a heap. The
* elements of the queue have to be ordered in terms of the
* <code>Ordered[T]</code> class.
@@ -24,8 +26,6 @@ package scala.collection.mutable
class PriorityQueue[A <% Ordered[A]] extends ResizableArray[A] {
size = size + 1 // we do not use array(0)
- import java.util.NoSuchElementException
-
protected def fixUp(as: Array[A], m: Int): Unit = {
var k: Int = m
while ((k > 1) && (as(k / 2) < as(k))) {
@@ -91,7 +91,7 @@ class PriorityQueue[A <% Ordered[A]] extends ResizableArray[A] {
/** Returns the element with the highest priority in the queue,
* and removes this element from the queue.
*
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the element with the highest priority.
*/
def dequeue: A =
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index 36fc82cf0d..359f0d4c9c 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -12,6 +12,8 @@
package scala.collection.mutable
+import compat.Platform.{NoSuchElementException, UnsupportedOperationException}
+
/** <code>Queue</code> objects implement data structures that allow to
* insert and retrieve elements in a first-in-first-out (FIFO) manner.
*
@@ -58,12 +60,12 @@ class Queue[A] extends MutableList[A] {
/** Returns the first element in the queue, and removes this element
* from the queue.
*
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the first element of the queue.
*/
def dequeue: A =
if (first == null)
- throw new java.util.NoSuchElementException("queue empty")
+ throw new NoSuchElementException("queue empty")
else {
val res = first.elem
first = first.next
@@ -171,7 +173,7 @@ class Queue[A] extends MutableList[A] {
/** The hashCode method always yields an error, since it is not
* safe to use mutable queues as keys in hash tables.
*
- * @throws UnsupportedOperationException
+ * @throws scala.compat.Platform.UnsupportedOperationException
* @return never.
*/
override def hashCode(): Int = throw new UnsupportedOperationException("unsuitable as hash key")
diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala
index ec8dfd2fd2..20761f1068 100644
--- a/src/library/scala/collection/mutable/Set.scala
+++ b/src/library/scala/collection/mutable/Set.scala
@@ -11,6 +11,9 @@
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
* <a href="../Set.html" target="contentFrame">
@@ -104,7 +107,8 @@ trait Set[A] extends AnyRef with collection.Set[A]
/** Send a message to this scriptable object.
*
* @param cmd the message to send.
- * @throws UnsupportedOperationException if the message was not understood.
+ * @throws <code>scala.compat.Platform.UnsupportedOperationException</code>
+ * if the message was not understood.
*/
def <<(cmd: Message[A]): Unit = cmd match {
case Include(elem) => this += elem
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index cc9c262f00..eacf69552a 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -11,6 +11,8 @@
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.
*
@@ -20,8 +22,6 @@ package scala.collection.mutable
[serializable, cloneable]
class Stack[A] extends MutableList[A] {
- import java.util.NoSuchElementException
-
/** Checks if the stack is empty.
*
* @return true, iff there is no element on the stack
@@ -61,14 +61,14 @@ class Stack[A] extends MutableList[A] {
* the element from the stack. An error is signaled if there is no
* element on the stack.
*
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the top element
*/
def top: A = if (first == null) throw new NoSuchElementException("stack empty") else first.elem
/** Removes the top element from the stack.
*
- * @throws java.util.NoSuchElementException
+ * @throws scala.compat.Platform.NoSuchElementException
* @return the top element
*/
def pop: A =
diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala
index 9a579af2a1..08aa1f1188 100644
--- a/src/library/scala/compat/Platform.scala
+++ b/src/library/scala/compat/Platform.scala
@@ -20,6 +20,9 @@ object Platform {
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)
@@ -36,6 +39,16 @@ object Platform {
def printStackTrace(exc: java.lang.Throwable) = exc.printStackTrace();
def getMessage(exc: java.lang.Throwable) = exc.getMessage();
+ private 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.toString()
+ }
+
def split(str: String, separator: Char): Array[String] = {
str.split(separator.toString());
}
diff --git a/src/library/scala/concurrent/Actor.scala b/src/library/scala/concurrent/Actor.scala
index 793f2492ef..8017ae43fb 100644
--- a/src/library/scala/concurrent/Actor.scala
+++ b/src/library/scala/concurrent/Actor.scala
@@ -11,6 +11,9 @@
package scala.concurrent
+
+import compat.Platform.IllegalArgumentException
+
/**
* The class <code>Actor</code> ...
*
diff --git a/src/library/scala/concurrent/NameServer.scala b/src/library/scala/concurrent/NameServer.scala
index 2a08618508..806e864038 100644
--- a/src/library/scala/concurrent/NameServer.scala
+++ b/src/library/scala/concurrent/NameServer.scala
@@ -11,6 +11,9 @@
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 565a2e28d7..39ce04484e 100644
--- a/src/library/scala/concurrent/Process.scala
+++ b/src/library/scala/concurrent/Process.scala
@@ -11,6 +11,9 @@
package scala.concurrent
+
+import compat.Platform.UnsupportedOperationException
+
/** This object ...
*
* @author Erik Stenman
@@ -37,7 +40,7 @@ object Process {
self.receiveWithin(msec)(f)
/**
- * @throws UnsupportedOperationException
+ * @throws scala.compat.Platform.UnsupportedOperationException
*/
def self: Process =
if (Thread.currentThread().isInstanceOf[Process])
diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala
index 19d7b99bd5..a2ee0d7052 100644
--- a/src/library/scala/io/BytePickle.scala
+++ b/src/library/scala/io/BytePickle.scala
@@ -11,7 +11,9 @@
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 8993e4a812..6173233176 100644
--- a/src/library/scala/io/Position.scala
+++ b/src/library/scala/io/Position.scala
@@ -11,7 +11,9 @@
package scala.io
+
import compat.StringBuilder
+import compat.Platform.IllegalArgumentException
/** <p>
* The object <code>Position</code> provides convenience methods to encode
diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala
index 685014aa87..faa7165ff7 100644
--- a/src/library/scala/io/Source.scala
+++ b/src/library/scala/io/Source.scala
@@ -14,6 +14,8 @@ 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.
@@ -211,7 +213,7 @@ abstract class Source extends Iterator[Char] {
*
* @param line the line index.
* @return the character string of the specified line.
- * @throws IllegalArgumentException
+ * @throws scala.compat.Platform.IllegalArgumentException
*/
def getLine(line: Int): String = {
val buf = new StringBuffer()
@@ -223,7 +225,7 @@ abstract class Source extends Iterator[Char] {
i = i + 1;
if (!it.hasNext) // this should not happen
- throw new java.lang.IllegalArgumentException(
+ throw new IllegalArgumentException(
"line " + line + " does not exist?!"
);
diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala
index 97836fc54b..a052335719 100755
--- a/src/library/scala/runtime/RichString.scala
+++ b/src/library/scala/runtime/RichString.scala
@@ -12,6 +12,8 @@
package scala.runtime
+import compat.Platform.NoSuchElementException
+
final class RichString(s: String) {
private final val LF: Char = 0x0A
@@ -72,7 +74,7 @@ final class RichString(s: String) {
var index = 0
def hasNext: Boolean = index <= len
def next: String = {
- if (index >= len) throw new java.util.NoSuchElementException("next on empty iterator")
+ if (index >= len) throw new NoSuchElementException("next on empty iterator")
val start = index
while (index < len && !isLineBreak(apply(index))) index = index + 1
index = index + 1
diff --git a/src/library/scala/testing/SUnit.scala b/src/library/scala/testing/SUnit.scala
index 40db46eb81..fe1f77e170 100644
--- a/src/library/scala/testing/SUnit.scala
+++ b/src/library/scala/testing/SUnit.scala
@@ -79,21 +79,14 @@ object SUnit {
* with the thrown exception.
*/
class TestFailure(val failedTest: Test, val thrownException: Throwable) {
- private val eol = System.getProperty("line.separator", "\n")
def this(p: Pair[Test, Throwable]) = this(p._1, p._2)
override def toString() =
failedTest.toString() + " failed due to " + thrownException.toString()
- def trace(): String = {
- val s = new StringBuilder()
- for (val trElem <- thrownException.getStackTrace()) {
- s.append(trElem.toString())
- s.append(eol)
- }
- s.toString()
- }
+ def trace(): String = compat.Platform.getStackTrace(thrownException)
+
}
/** a TestResult collects the result of executing a test case */
diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala
index 7a7a6c642f..e0198a4592 100644
--- a/src/library/scala/util/automata/BaseBerrySethi.scala
+++ b/src/library/scala/util/automata/BaseBerrySethi.scala
@@ -17,6 +17,8 @@ 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/xml/Comment.scala b/src/library/scala/xml/Comment.scala
index a6228be4c7..2574f2ef99 100644
--- a/src/library/scala/xml/Comment.scala
+++ b/src/library/scala/xml/Comment.scala
@@ -12,6 +12,7 @@
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 96b571c505..ae79835096 100644
--- a/src/library/scala/xml/Elem.scala
+++ b/src/library/scala/xml/Elem.scala
@@ -12,6 +12,8 @@
package scala.xml;
+import compat.Platform.IllegalArgumentException
+
/** The case class <code>Elem</code> 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 7ca864add7..bbbed194fc 100644
--- a/src/library/scala/xml/Group.scala
+++ b/src/library/scala/xml/Group.scala
@@ -11,7 +11,9 @@
package scala.xml
+
import compat.StringBuilder
+import compat.Platform.UnsupportedOperationException
/** A hack to group XML nodes in one node for output.
*
@@ -33,31 +35,31 @@ case class Group(val nodes: Seq[Node]) extends Node {
}
/**
- * @throws UnsupportedOperationException (always)
+ * @throws scala.compat.Platform.UnsupportedOperationException (always)
*/
final def label =
throw new UnsupportedOperationException("class Group does not support method 'label'")
/**
- * @throws UnsupportedOperationException (always)
+ * @throws scala.compat.Platform.UnsupportedOperationException (always)
*/
final override def attributes =
throw new UnsupportedOperationException("class Group does not support method 'attributes'")
/**
- * @throws UnsupportedOperationException (always)
+ * @throws scala.compat.Platform.UnsupportedOperationException (always)
*/
final override def namespace =
throw new UnsupportedOperationException("class Group does not support method 'namespace'")
/**
- * @throws UnsupportedOperationException (always)
+ * @throws scala.compat.Platform.UnsupportedOperationException (always)
*/
final override def child =
throw new UnsupportedOperationException("class Group does not support method 'child'")
/**
- * @throws UnsupportedOperationException (always)
+ * @throws scala.compat.Platform.UnsupportedOperationException (always)
*/
def toString(sb: StringBuilder) =
throw new UnsupportedOperationException("class Group does not support method toString(StringBuilder)")
diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala
index cccfa893c1..f95ffbbf25 100644
--- a/src/library/scala/xml/NamespaceBinding.scala
+++ b/src/library/scala/xml/NamespaceBinding.scala
@@ -11,7 +11,9 @@
package scala.xml
+
import compat.StringBuilder
+import compat.Platform.IllegalArgumentException
/** The class <code>NamespaceBinding</code> 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 96ba45c73c..952e4474c0 100644
--- a/src/library/scala/xml/PrefixedAttribute.scala
+++ b/src/library/scala/xml/PrefixedAttribute.scala
@@ -12,6 +12,7 @@
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 4850066846..daf4e7da12 100644
--- a/src/library/scala/xml/ProcInstr.scala
+++ b/src/library/scala/xml/ProcInstr.scala
@@ -11,7 +11,9 @@
package scala.xml;
+
import compat.StringBuilder
+import compat.Platform.IllegalArgumentException
/** an XML node for processing instructions (PI)
*
diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala
index 862c48fa90..5413c9d884 100644
--- a/src/library/scala/xml/dtd/Decl.scala
+++ b/src/library/scala/xml/dtd/Decl.scala
@@ -11,7 +11,9 @@
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 e31f43990f..a292f715bd 100644
--- a/src/library/scala/xml/dtd/DocType.scala
+++ b/src/library/scala/xml/dtd/DocType.scala
@@ -12,6 +12,8 @@
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 0e8ac719ed..c6fba94e48 100644
--- a/src/library/scala/xml/dtd/ExternalID.scala
+++ b/src/library/scala/xml/dtd/ExternalID.scala
@@ -11,7 +11,9 @@
package scala.xml.dtd;
+
import compat.StringBuilder
+import compat.Platform.IllegalArgumentException
/** an ExternalIDs - either PublicID or SystemID
*
diff --git a/src/library/scala/xml/transform/BasicTransformer.scala b/src/library/scala/xml/transform/BasicTransformer.scala
index 4d3bfbe252..4dab95b6f2 100644
--- a/src/library/scala/xml/transform/BasicTransformer.scala
+++ b/src/library/scala/xml/transform/BasicTransformer.scala
@@ -8,8 +8,12 @@
// $Id$
+
package scala.xml.transform
+
+import compat.Platform.UnsupportedOperationException
+
/** A class for XML transformations.
*
* @author Burak Emir