diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-15 21:30:31 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-01-20 14:19:20 +0300 |
commit | 8c1505f1892624a8c74e63382eca161841e0bb57 (patch) | |
tree | 3454996f7a047a8d4a6b15710e3aa72b482787aa /src/reflect | |
parent | b88198ee2343ad7209d1b33ef3914da0d6be118c (diff) | |
download | scala-8c1505f1892624a8c74e63382eca161841e0bb57.tar.gz scala-8c1505f1892624a8c74e63382eca161841e0bb57.tar.bz2 scala-8c1505f1892624a8c74e63382eca161841e0bb57.zip |
FromJavaClassCompleter is now flag-agnostic
A minor evolution of the notion of completion + also a small performance
optimization.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/runtime/JavaMirrors.scala | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 7cc5176507..c8bdece272 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -42,7 +42,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni // overriden by ReflectGlobal def rootClassLoader: ClassLoader = this.getClass.getClassLoader - trait JavaClassCompleter extends FlagAssigningCompleter + trait JavaClassCompleter def runtimeMirror(cl: ClassLoader): Mirror = gilSynchronized { mirrors get cl match { @@ -655,7 +655,15 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * @param module The Scala companion object for which info is copied * @param jclazz The Java class */ - private class FromJavaClassCompleter(clazz: Symbol, module: Symbol, jclazz: jClass[_]) extends LazyType with JavaClassCompleter with FlagAssigningCompleter { + private class FromJavaClassCompleter(clazz: Symbol, module: Symbol, jclazz: jClass[_]) extends LazyType with JavaClassCompleter with FlagAgnosticCompleter { + // one doesn't need to do non-trivial computations to assign flags for Java-based reflection artifacts + // therefore I'm moving flag-assigning logic from completion to construction + val flags = jclazz.scalaFlags + clazz setFlag (flags | JAVA) + if (module != NoSymbol) { + module setFlag (flags & PRIVATE | JAVA) + module.moduleClass setFlag (flags & PRIVATE | JAVA) + } /** used to avoid cycles while initializing classes */ private var parentsLevel = 0 @@ -665,12 +673,6 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni override def load(sym: Symbol): Unit = { debugInfo("completing from Java " + sym + "/" + clazz.fullName)//debug assert(sym == clazz || (module != NoSymbol && (sym == module || sym == module.moduleClass)), sym) - val flags = jclazz.scalaFlags - clazz setFlag (flags | JAVA) - if (module != NoSymbol) { - module setFlag (flags & PRIVATE | JAVA) - module.moduleClass setFlag (flags & PRIVATE | JAVA) - } propagatePackageBoundary(jclazz, relatedSymbols: _*) copyAnnotations(clazz, jclazz) |