diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-07 05:17:12 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-07 05:17:12 -0700 |
commit | cd5153503da73c45c12cbac5e70aad9f90d8cd5c (patch) | |
tree | 589160db06d58680d2b2ad40c8c7c11bea1b03a2 | |
parent | 114367c0b2ce5f48186d4270c1724090fd77877b (diff) | |
parent | c2bb028deb7a03acb5dcf2fa905a466fef8be1a6 (diff) | |
download | scala-cd5153503da73c45c12cbac5e70aad9f90d8cd5c.tar.gz scala-cd5153503da73c45c12cbac5e70aad9f90d8cd5c.tar.bz2 scala-cd5153503da73c45c12cbac5e70aad9f90d8cd5c.zip |
Merge pull request #1066 from magarciaEPFL/ticket-SI-6102
SI-6102 Wrong bytecode in lazyval + no-op finally clause
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala | 13 | ||||
-rw-r--r-- | test/files/run/t6102.check | 1 | ||||
-rw-r--r-- | test/files/run/t6102.flags | 1 | ||||
-rw-r--r-- | test/files/run/t6102.scala | 13 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index a804cc92d3..7627edb79d 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -2565,6 +2565,19 @@ abstract class GenASM extends SubComponent with BytecodeWriters { case JUMP(whereto) => if (nextBlock != whereto) { jcode goTo labels(whereto) + } else if(m.exh.exists(eh => eh.covers(b))) { + // SI-6102: Determine whether eliding this JUMP results in an empty range being covered by some EH. + // If so, emit a NOP in place of the elided JUMP, to avoid "java.lang.ClassFormatError: Illegal exception table range" + val isSthgLeft = b.toList.exists { + case _: LOAD_EXCEPTION => false + case _: SCOPE_ENTER => false + case _: SCOPE_EXIT => false + case _: JUMP => false + case _ => true + } + if(!isSthgLeft) { + emit(asm.Opcodes.NOP) + } } case CJUMP(success, failure, cond, kind) => diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check new file mode 100644 index 0000000000..b6fc4c620b --- /dev/null +++ b/test/files/run/t6102.check @@ -0,0 +1 @@ +hello
\ No newline at end of file diff --git a/test/files/run/t6102.flags b/test/files/run/t6102.flags new file mode 100644 index 0000000000..e35535c8ea --- /dev/null +++ b/test/files/run/t6102.flags @@ -0,0 +1 @@ + -Ydead-code diff --git a/test/files/run/t6102.scala b/test/files/run/t6102.scala new file mode 100644 index 0000000000..53584055bb --- /dev/null +++ b/test/files/run/t6102.scala @@ -0,0 +1,13 @@ +// SI-6102 Wrong bytecode in lazyval + no-op finally clause + +object Test { + + def main(args: Array[String]) { + try { + val x = 3 + } finally { + print("hello") + } + } +} + |