diff options
Diffstat (limited to 'src')
4 files changed, 49 insertions, 27 deletions
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index d88b4b9c15..620910caa8 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -54,6 +54,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => private var rawpos = initPos val id = { ids += 1; ids } // identity displayed when -uniqid + //assert(id != 34, initName) var validTo: Period = NoPeriod @@ -839,6 +840,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => phase = phaseOf(infos.validFrom) tp.complete(this) } finally { + if (id == 431) println("completer ran "+tp.getClass+" for "+fullName) unlock() phase = current } diff --git a/src/compiler/scala/reflect/runtime/ConversionUtil.scala b/src/compiler/scala/reflect/runtime/ConversionUtil.scala index 4213506c3b..393585da7c 100644 --- a/src/compiler/scala/reflect/runtime/ConversionUtil.scala +++ b/src/compiler/scala/reflect/runtime/ConversionUtil.scala @@ -18,6 +18,7 @@ trait ConversionUtil { self: internal.SymbolTable => private val toJavaMap = new HashMap[S, J] def enter(j: J, s: S) = { + println("cached: "+j+"/"+s) toScalaMap(j) = s toJavaMap(s) = j } diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala index b03a956fdb..87551019c0 100644 --- a/src/compiler/scala/reflect/runtime/JavaToScala.scala +++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala @@ -2,6 +2,7 @@ package scala.reflect package runtime import java.lang.{ Class => jClass, Package => jPackage } +import java.io.IOException import java.lang.reflect.{ Method => jMethod, Constructor => jConstructor, @@ -29,6 +30,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => val global: JavaToScala.this.type = self } + /** * Generate types for top-level Scala root class and root companion object * from the pickled information stored in a corresponding Java class @@ -38,29 +40,42 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => * ScalaSignature or ScalaLongSignature annotation. */ def unpickleClass(clazz: Symbol, module: Symbol, jclazz: jClass[_]): Unit = { - //println("unpickling " + clazz + " " + module)//debug - val ssig = jclazz.getAnnotation(classOf[scala.reflect.ScalaSignature]) - if (ssig != null) { - val bytes = ssig.bytes.getBytes - val len = ByteCodecs.decode(bytes) - unpickler.unpickle(bytes take len, 0, clazz, module, jclazz.getName) - } else { - val slsig = jclazz.getAnnotation(classOf[scala.reflect.ScalaLongSignature]) - if (slsig != null) { - val byteSegments = slsig.bytes map (_.getBytes) - val lens = byteSegments map ByteCodecs.decode - val bytes = Array.ofDim[Byte](lens.sum) - var len = 0 - for ((bs, l) <- byteSegments zip lens) { - bs.copyToArray(bytes, len, l) - len += l + def markAbsent(tpe: Type) = List(clazz, module, module.moduleClass) foreach (_ setInfo tpe) + try { + println("unpickling " + clazz + " " + module) //debug + markAbsent(NoType) + val ssig = jclazz.getAnnotation(classOf[scala.reflect.ScalaSignature]) + if (ssig != null) { + val bytes = ssig.bytes.getBytes + val len = ByteCodecs.decode(bytes) + println("short sig:" + len) + unpickler.unpickle(bytes take len, 0, clazz, module, jclazz.getName) + } else { + val slsig = jclazz.getAnnotation(classOf[scala.reflect.ScalaLongSignature]) + if (slsig != null) { + val byteSegments = slsig.bytes map (_.getBytes) + val lens = byteSegments map ByteCodecs.decode + val bytes = Array.ofDim[Byte](lens.sum) + var len = 0 + for ((bs, l) <- byteSegments zip lens) { + bs.copyToArray(bytes, len, l) + len += l + } + println("long sig") //debug + unpickler.unpickle(bytes, 0, clazz, module, jclazz.getName) + } else { // class does not have a Scala signature; it's a Java class + println("no sig found for " + jclazz) //debug + initClassModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz)) } - //println("long sig")//debug - unpickler.unpickle(bytes, 0, clazz, module, jclazz.getName) - } else { // class does not have a Scala signature; it's a Java class - //println("no sig found for " + jclazz)//debug - initClassModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz)) } + } catch { + case ex: IOException => + markAbsent(ErrorType) + if (settings.debug.value) ex.printStackTrace() + val msg = ex.getMessage() + throw new IOException( + if (msg eq null) "reflection error while loading " + clazz.name + else "error while loading " + clazz.name + ", " + msg) } } @@ -106,7 +121,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => */ private class FromJavaClassCompleter(clazz: Symbol, module: Symbol, jclazz: jClass[_]) extends LazyType { override def complete(sym: Symbol) = { - //println("completing from Java " + sym + "/" + clazz.fullName)//debug + println("completing from Java " + sym + "/" + clazz.fullName)//debug assert(sym == clazz || sym == module || sym == module.moduleClass, sym) val flags = toScalaFlags(jclazz.getModifiers, isClass = true) clazz setFlag (flags | JAVA) @@ -272,9 +287,11 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => case java.lang.Boolean.TYPE => BooleanClass case _ => // jclazz is top-level - get signature - val (clazz, module) = createClassModule( - sOwner(jclazz), newTypeName(jclazz.getSimpleName), new TopClassCompleter(_, _)) - clazz + sOwner(jclazz).info decl newTypeName(jclazz.getSimpleName) +// val (clazz, module) = createClassModule( +// sOwner(jclazz), newTypeName(jclazz.getSimpleName), new TopClassCompleter(_, _)) +// classCache enter (jclazz, clazz) +// clazz } } @@ -310,7 +327,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => val tparam = owner.newExistential(NoPosition, newTypeName("T$" + tparams.length)) .setInfo(TypeBounds( lub(jwild.getLowerBounds.toList map typeToScala), - glb(jwild.getUpperBounds.toList map typeToScala))) + glb(scala.tools.nsc.util.trace("glb args")(jwild.getUpperBounds.toList) map typeToScala))) tparams += tparam typeRef(NoPrefix, tparam, List()) case _ => diff --git a/src/compiler/scala/reflect/runtime/Loaders.scala b/src/compiler/scala/reflect/runtime/Loaders.scala index 9f4c02cdb3..54803a6211 100644 --- a/src/compiler/scala/reflect/runtime/Loaders.scala +++ b/src/compiler/scala/reflect/runtime/Loaders.scala @@ -29,7 +29,8 @@ trait Loaders { self: SymbolTable => } } override def complete(sym: Symbol) = { - //println("completing "+sym+"/"+clazz.fullName) //debug + println("completing "+sym+"/"+clazz.fullName+ + (if (sym == clazz) 1 else if (sym == module) 2 else if (sym == module.moduleClass) 3 else 4)) //debug assert(sym == clazz || sym == module || sym == module.moduleClass) try { unpickleClass(clazz, module, jClass.forName(clazz.fullName)) @@ -91,5 +92,6 @@ trait Loaders { self: SymbolTable => override def member(name: Name): Symbol = decl(name) override def findMember(name: Name, excludedFlags: Long, requiredFlags: Long, stableOnly: Boolean) = member(name).filter (m => m.hasAllFlags(requiredFlags) && !m.hasFlag(excludedFlags)) + override def safeToString = pkg.toString } }
\ No newline at end of file |