Skip to content

Instantly share code, notes, and snippets.

@lrytz
Created September 17, 2015 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrytz/9d3fe4bb688c9a0f4691 to your computer and use it in GitHub Desktop.
Save lrytz/9d3fe4bb688c9a0f4691 to your computer and use it in GitHub Desktop.
inliner bug
➜ sandbox git:(opt/heuristicsPerf) ✗ cat A.scala
object A {
@inline def inner: String = try { throw null } catch { case _: NullPointerException => "npe" }
def foo = try inner catch { case e: Throwable => throw e }
def main(args: Array[String]): Unit = {
println(foo)
}
}
➜ sandbox git:(opt/heuristicsPerf) ✗ qsc A.scala && qs A
npe
➜ sandbox git:(opt/heuristicsPerf) ✗ qsc -Yopt:l:classpath A.scala && qs A
java.lang.NullPointerException
at A$.foo(A.scala:2)
at A$.main(A.scala:6)
➜ sandbox git:(opt/heuristicsPerf) ✗ asm -a A\$.class
➜ sandbox git:(opt/heuristicsPerf) ✗ cat A\$.asm
[...]
// access flags 0x1
public foo()Ljava/lang/String;
TRYCATCHBLOCK L0 L1 L2 java/lang/Throwable
TRYCATCHBLOCK L3 L4 L4 java/lang/NullPointerException
L0
LINENUMBER 3 L0
ALOAD 0
ASTORE 2
L3
LINENUMBER 2 L3
ACONST_NULL
ATHROW
L4
FRAME FULL [A$ T A$] [java/lang/NullPointerException]
POP
LDC "npe"
ASTORE 3
ALOAD 3
L1
ARETURN
L2
FRAME FULL [A$] [java/lang/Throwable]
ASTORE 1
ALOAD 1
ATHROW
L5
LOCALVARIABLE e Ljava/lang/Throwable; L2 L5 1
LOCALVARIABLE this LA$; L0 L5 0
MAXSTACK = 1
MAXLOCALS = 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment