diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-01 02:25:51 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-01 02:25:51 +0000 |
commit | caff22f1ce5ab41b0c62d5b313bd50fed7548886 (patch) | |
tree | b6d94b1e50431622c9b19ac7a0c8f2995937bf87 | |
parent | d0bb45449c1805c32aeb1a7ec4210802f5c443be (diff) | |
download | scala-caff22f1ce5ab41b0c62d5b313bd50fed7548886.tar.gz scala-caff22f1ce5ab41b0c62d5b313bd50fed7548886.tar.bz2 scala-caff22f1ce5ab41b0c62d5b313bd50fed7548886.zip |
Worked around lazyAccessor binary compatibility...
Worked around lazyAccessor binary compatibility issue with reflection.
MiMa now reports no differences between 2.8.1's library jar and 2.8.2.
-rwxr-xr-x | src/library/scala/reflect/generic/Symbols.scala | 5 | ||||
-rwxr-xr-x | src/library/scala/reflect/generic/UnPickler.scala | 13 | ||||
-rw-r--r-- | test/files/jvm/JavaInteraction.scala | 23 |
3 files changed, 10 insertions, 31 deletions
diff --git a/src/library/scala/reflect/generic/Symbols.scala b/src/library/scala/reflect/generic/Symbols.scala index a1c9a0c18d..f1226c7e19 100755 --- a/src/library/scala/reflect/generic/Symbols.scala +++ b/src/library/scala/reflect/generic/Symbols.scala @@ -107,11 +107,6 @@ trait Symbols { self: Universe => */ def moduleClass: Symbol - /** - * If symbol is a lazy val, it's lazy accessor - */ - def lazyAccessor: Symbol - // flags and kind tests def isTerm = false // to be overridden diff --git a/src/library/scala/reflect/generic/UnPickler.scala b/src/library/scala/reflect/generic/UnPickler.scala index d5e2bd9f11..b312114d20 100755 --- a/src/library/scala/reflect/generic/UnPickler.scala +++ b/src/library/scala/reflect/generic/UnPickler.scala @@ -166,6 +166,13 @@ abstract class UnPickler { } } + /** Reflection access to lazyAccessor for binary compatibility + * between 2.8.1 and 2.8.2. + */ + private def binaryCompatLazyAccessor(x: AnyRef): Symbol = + try x.getClass.getMethod("lazyAccessor").invoke(x).asInstanceOf[Symbol] + catch { case _: Exception => null } + /** Read a symbol */ protected def readSymbol(): Symbol = { val tag = readByte() @@ -197,9 +204,9 @@ abstract class UnPickler { case EXTMODCLASSref => val moduleVar = owner.info.decl(nme.moduleVarName(name)) if (moduleVar.hasFlag(LAZY)) { - val lazyAcc = moduleVar.lazyAccessor - if (lazyAcc != NoSymbol) - sym = lazyAcc.lazyAccessor + val lazyAcc = binaryCompatLazyAccessor(moduleVar) + if (lazyAcc != null) + sym = binaryCompatLazyAccessor(lazyAcc) } case _ => } diff --git a/test/files/jvm/JavaInteraction.scala b/test/files/jvm/JavaInteraction.scala deleted file mode 100644 index 1316fad5d4..0000000000 --- a/test/files/jvm/JavaInteraction.scala +++ /dev/null @@ -1,23 +0,0 @@ -//############################################################################ -// Test Java interaction -//############################################################################ - -import java.awt.Color; -import java.awt.Point; - -class ColoredPoint(x: Int, y: Int, c_ : Color) extends Point(x, y) { - val c: Color = c_; - def getC(): Color = c; -} - -object Test { - def main(args: Array[String]): Unit = { - val p = new ColoredPoint(5, 7, Color.RED); - Console.println("p.x = " + p.x); - Console.println("p.c = " + p.c); - Console.println("p.getX() = " + p.getX()); - Console.println("p.getC() = " + p.getC()); - } -} - -//############################################################################ |