- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
more error message toys I wrote this weekend
Mon, 2010-05-17, 04:57
** Demo 1 **
% SOURCEPATH=/scala/trunk/src scala -Yrich-exceptions
Welcome to Scala version 2.8.0.r21946-b20100516204551 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_17).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Nil(-1)
java.lang.IndexOutOfBoundsException
[LinearSeqOptimized.apply]
50: def apply(n: Int): A = {
51: val rest = drop(n)
52: if (n < 0 || rest.isEmpty) throw new IndexOutOfBoundsException
*53: rest.head
54: }
55:
56: override /*IterableLike*/
[List.apply]
42: * @define willNotTerminateInf
43: */
44: sealed abstract class List[+A] extends LinearSeq[A]
*45: with Product
46: with GenericTraversableTemplate[A, List]
47: with LinearSeqOptimized[A, List[A]] {
48: override def companion: GenericCompanion[List] = List
// I snip the remainder
** Demo 2 **
Crasher taken from: https://lampsvn.epfl.ch/trac/scala/ticket/3431
scala> val url = new java.net.URL( "http://www.sciss.de/index.html" )
url: java.net.URL = http://www.sciss.de/index.html
scala> val is = url.openStream
is: java.io.InputStream = sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@5bc935cc
scala> is.
assertion failed: class HttpURLConnection: package http
[searching sources for exception contexts...]
[Predef.assert]
89: def assert(assertion: Boolean, message: => Any) {
90: if (!assertion)
91: throw new java.lang.AssertionError("assertion failed: "+ message)
*92: }
93:
94: /** Tests an expression, throwing an AssertionError if false.
95: * This method differs from assert only in the intent expressed:
[ClassfileParser.parseMethod]
600: val newParams = innerClasses.get(externalName) match {
601: case Some(entry) if !isScalaRaw && !isStatic(entry.jflags) =>
602: assert(params.head.tpe.typeSymbol == clazz.owner, params.head.tpe.typeSymbol + ": " + clazz.owner)
*603: params.tail
604: case _ =>
605: params
606: }
[ClassfileParser.apply$mcVI$sp]
522: sawPrivateConstructor = false
523: val methodCount = in.nextChar
524: for (i <- 0 until methodCount) parseMethod()
*525: if (!sawPrivateConstructor &&
526: (instanceDefs.lookup(nme.CONSTRUCTOR) == NoSymbol &&
527: (sflags & INTERFACE) == 0L))
528: {
[ClassfileParser.apply]
522: sawPrivateConstructor = false
523: val methodCount = in.nextChar
524: for (i <- 0 until methodCount) parseMethod()
*525: if (!sawPrivateConstructor &&
526: (instanceDefs.lookup(nme.CONSTRUCTOR) == NoSymbol &&
527: (sflags & INTERFACE) == 0L))
528: {
// I snip the remainder
** Demo 3 - same REPL session where the compiler just exploded **
Attempting recovery...
Replaying: val url = new java.net.URL( "http://www.sciss.de/index.html" )
url: java.net.URL = http://www.sciss.de/index.html
** (Tangential) Demo 4 - hey it's not a crasher anymore **
scala> val is = url.openStream
is: java.io.InputStream = sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@5bc935cc
scala> is.
asInstanceOf available close isInstanceOf mark
markSupported read reset skip toString
Mon, 2010-05-17, 15:07
#2
Re: more error message toys I wrote this weekend
On Mon, May 17, 2010 at 08:52:44AM +0200, Johannes Rudolph wrote:
> Note the try/catch block skipping all those cases where I got similar
> errors. When you try the same query several times in row you've got a
> always varying number of elements you can (and cannot) traverse (and
> IIRC the number is not monotonically rising as you would perhaps
> expect it if it just were a simple loading order issue).
You may recall this thread:
http://article.gmane.org/gmane.comp.lang.scala.internals/3010
It looks like more of the same category of issue.
On Mon, May 17, 2010 at 5:57 AM, Paul Phillips wrote:
> ** (Tangential) Demo 4 - hey it's not a crasher anymore **
Yes, I found that as well. Here's some (trivial) code to walk the
complete symbol table:
http://github.com/jrudolph/scala-stuff/commit/51dc213117d543f5d1c9c548a7...
Note the try/catch block skipping all those cases where I got similar
errors. When you try the same query several times in row you've got a
always varying number of elements you can (and cannot) traverse (and
IIRC the number is not monotonically rising as you would perhaps
expect it if it just were a simple loading order issue).
Great work with the exceptions btw.