diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-07-02 18:12:33 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-07-02 18:12:33 +0000 |
commit | 4dd14ec6f68a10792be348520cf8c078c2e2bc80 (patch) | |
tree | 3d7216421452b9340f812bee6ba97efe14722183 /src/compiler | |
parent | d9dc68cd2b4b20dae1341064cb784c9169ab162d (diff) | |
download | scala-4dd14ec6f68a10792be348520cf8c078c2e2bc80.tar.gz scala-4dd14ec6f68a10792be348520cf8c078c2e2bc80.tar.bz2 scala-4dd14ec6f68a10792be348520cf8c078c2e2bc80.zip |
Closes #2318 (spurious IllegalAccessException t...
Closes #2318 (spurious IllegalAccessException thrown by some structural
calls, caused by Java bug 4071957). Review by malayeri.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/StdNames.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/CleanUp.scala | 9 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 4f8386f335..1684b5f071 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -224,6 +224,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { lazy val SoftReferenceClass = getClass("java.lang.ref.SoftReference") lazy val WeakReferenceClass = getClass("java.lang.ref.WeakReference") lazy val MethodClass = getClass(sn.MethodAsObject) + def methodClass_setAccessible = getMember(MethodClass, nme.setAccessible) lazy val EmptyMethodCacheClass = getClass("scala.runtime.EmptyMethodCache") lazy val MethodCacheClass = getClass("scala.runtime.MethodCache") def methodCache_find = getMember(MethodCacheClass, nme.find_) diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index ed72fc16fa..8c4078e91e 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -335,6 +335,7 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable => val sameElements = newTermName("sameElements") val scala_ = newTermName("scala") val self = newTermName("self") + val setAccessible = newTermName("setAccessible") val synchronized_ = newTermName("synchronized") val tail = newTermName("tail") val toArray = newTermName("toArray") diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 9b92a230cd..9b569fa45e 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -216,13 +216,12 @@ abstract class CleanUp extends Transform with ast.TreeDSL { case POLY_CACHE => /* Implementation of the cache is as follows for method "def xyz(a: A, b: B)" - (but with the addition of a SoftReference wrapped around the MethodCache holder - so that it does not interfere with classloader garbage collection, see ticket + (SoftReference so that it does not interfere with classloader garbage collection, see ticket #2365 for details): var reflParams$Cache: Array[Class[_]] = Array[JClass](classOf[A], classOf[B]) - var reflPoly$Cache: scala.runtime.MethodCache = new EmptyMethodCache() + var reflPoly$Cache: SoftReference[scala.runtime.MethodCache] = new SoftReference(new EmptyMethodCache()) def reflMethod$Method(forReceiver: JClass[_]): JMethod = { var method: JMethod = reflPoly$Cache.find(forReceiver) @@ -230,7 +229,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL { return method else { method = forReceiver.getMethod("xyz", reflParams$Cache) - reflPoly$Cache = reflPoly$Cache.add(forReceiver, method) + method.setAccessible(true) // issue #2381 + reflPoly$Cache = new SoftReference(reflPoly$Cache.get.add(forReceiver, method)) return method } } @@ -258,6 +258,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { def cacheRHS = ((getPolyCache DOT methodCache_add)(REF(forReceiverSym), REF(methodSym))) BLOCK( REF(methodSym) === methodSymRHS, + (REF(methodSym) DOT methodClass_setAccessible)(LIT(true)), REF(reflPolyCacheSym) === gen.mkSoftRef(cacheRHS), Return(REF(methodSym)) ) |