summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-10-16 22:09:12 +0000
committerPaul Phillips <paulp@improving.org>2010-10-16 22:09:12 +0000
commit080d357a3e3c88c17626c3a2ddd6fc334cb86d2e (patch)
treebe1b3394dd07957e97654c152947205302f9058b /src/compiler
parent5cdb213d7d24ae357c518823e1054cb302b250eb (diff)
downloadscala-080d357a3e3c88c17626c3a2ddd6fc334cb86d2e.tar.gz
scala-080d357a3e3c88c17626c3a2ddd6fc334cb86d2e.tar.bz2
scala-080d357a3e3c88c17626c3a2ddd6fc334cb86d2e.zip
Made some changes to fjbg so when people run in...
Made some changes to fjbg so when people run into #1133 at least it will tell them what method was the cause. The fact that ten files are touched in this commit instead of one or two is a testament to the wonder of checked exceptions. No review.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 5a02de0907..7afa36c0ba 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -15,6 +15,8 @@ import scala.tools.nsc.symtab._
import scala.tools.nsc.symtab.classfile.ClassfileConstants._
import ch.epfl.lamp.fjbg._
+import FJBGContext.FJBGWrapper
+import JCode.OffsetTooBigException
import JAccessFlags._
import JObjectType.{ JAVA_LANG_STRING, JAVA_LANG_OBJECT }
import java.io.{ DataOutputStream }
@@ -138,6 +140,15 @@ abstract class GenJVM extends SubComponent {
val emitLines = debugLevel >= 2
val emitVars = debugLevel >= 3
+ def analyzeException(culprit: String, t: Throwable): Unit = t match {
+ case x: FJBGWrapper =>
+ analyzeException(x.culprit, x.getCause())
+ case _: OffsetTooBigException =>
+ clasz.cunit.error(clasz.symbol.pos, "cannot emit bytecode for " + culprit + ": " + t.getMessage)
+ case x =>
+ throw x
+ }
+
/** Write a class to disk, adding the Scala signature (pickled type
* information) and inner classes.
*
@@ -148,8 +159,10 @@ abstract class GenJVM extends SubComponent {
addInnerClasses(jclass)
val outfile = getFile(sym, jclass, ".class")
val outstream = new DataOutputStream(outfile.bufferedOutput)
- jclass.writeTo(outstream)
- outstream.close()
+ try jclass.writeTo(outstream)
+ catch { case x => analyzeException(jclass.getName(), x) }
+ finally outstream.close()
+
informProgress("wrote " + outfile)
}