diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-06-30 22:09:39 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-07-23 14:49:01 +0200 |
commit | 1b5772316911e68ac0fb15a17390277f520e823a (patch) | |
tree | 476b3fe10618594b150045ba8d8325320faefbe8 /src | |
parent | 8bafa8ed88da0d522425c120daf7e0a4e09f88d9 (diff) | |
download | scala-1b5772316911e68ac0fb15a17390277f520e823a.tar.gz scala-1b5772316911e68ac0fb15a17390277f520e823a.tar.bz2 scala-1b5772316911e68ac0fb15a17390277f520e823a.zip |
[backport] `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)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala | 5 |
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) |