summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-06-30 22:09:39 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-07-01 11:46:28 -0700
commitd2cffb9ad2e431d62c890a7fb9d56520739e07b2 (patch)
tree33b9bb7f92b72d6c51a0e517fd8865d2ffdc0537
parent373db1ed700b0098ccf0c8a6d68c34d836765344 (diff)
downloadscala-d2cffb9ad2e431d62c890a7fb9d56520739e07b2.tar.gz
scala-d2cffb9ad2e431d62c890a7fb9d56520739e07b2.tar.bz2
scala-d2cffb9ad2e431d62c890a7fb9d56520739e07b2.zip
`deserializeLambda` should not use encoded class name
`javaBinaryName` returns the internal name of a class. Also used in BTypesFromsymbols.classBTypeFromSymbol. Weirdly, this was discovered due to a bizarre osgi bnd error: ``` [bnd] # addAll '/Users/luc/scala/scala/build/pack/lib/scala-library.jar' with :, [bnd] # addAll '/Users/luc/scala/scala/build/osgi/scala-library.bnd' with , [bnd] 1 ERRORS [bnd] The default package '.' is not permitted by the Import-Package syntax. [bnd] This can be caused by compile errors in Eclipse because Eclipse creates [bnd] valid class files regardless of compile errors. [bnd] The following package(s) import from the default package [scala.collection.generic, scala.sys.process, scala.collection.parallel.mutable, scala.util, scala.collection.parallel.immutable, scala.reflect, scala.concurrent.impl, scala.util.hashing, scala.collection.parallel, scala.collection.convert, scala.io, scala, scala.collection.concurrent, scala.util.control, scala.beans, scala.concurrent.duration, scala.collection, scala.runtime, scala.math, scala.collection.mutable, scala.concurrent, scala.sys, scala.collection.immutable, scala.ref, scala.util.matching] [bnd] /Users/luc/scala/scala/build/osgi/scala-library.bnd: bnd failed ``` Lukas diagnosed it as a problem of the generated `$deserializeLambda$` function: One example is `scala/App$class`. Its bytecode contains this: ``` private static synthetic $deserializeLambda$(Ljava/lang/invoke/SerializedLambda;)Ljava/lang/Object; GETSTATIC scala$divApp$class.$deserializeLambdaCache$ : Ljava/util/Map; [...] ``` so it's a static field read of a top-level class. `$div` should obviously be `/` (which this commit rectifies)
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index 23e0a4e17a..d53e88a11c 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -715,7 +715,8 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
{
val mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC + ACC_SYNTHETIC, "$deserializeLambda$", "(Ljava/lang/invoke/SerializedLambda;)Ljava/lang/Object;", null, null)
mv.visitCode()
- mv.visitFieldInsn(GETSTATIC, clazz.javaBinaryName.encoded, "$deserializeLambdaCache$", "Ljava/util/Map;")
+ // javaBinaryName returns the internal name of a class. Also used in BTypesFromsymbols.classBTypeFromSymbol.
+ mv.visitFieldInsn(GETSTATIC, clazz.javaBinaryName.toString, "$deserializeLambdaCache$", "Ljava/util/Map;")
mv.visitVarInsn(ASTORE, 1)
mv.visitVarInsn(ALOAD, 1)
val l0 = new asm.Label()
@@ -725,7 +726,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
mv.visitMethodInsn(INVOKESPECIAL, "java/util/HashMap", "<init>", "()V", false)
mv.visitVarInsn(ASTORE, 1)
mv.visitVarInsn(ALOAD, 1)
- mv.visitFieldInsn(PUTSTATIC, clazz.javaBinaryName.encoded, "$deserializeLambdaCache$", "Ljava/util/Map;")
+ mv.visitFieldInsn(PUTSTATIC, clazz.javaBinaryName.toString, "$deserializeLambdaCache$", "Ljava/util/Map;")
mv.visitLabel(l0)
mv.visitFrame(asm.Opcodes.F_APPEND,1, Array("java/util/Map"), 0, null)
mv.visitMethodInsn(INVOKESTATIC, "java/lang/invoke/MethodHandles", "lookup", "()Ljava/lang/invoke/MethodHandles$Lookup;", false)