summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
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)
}