diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala | 19 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/LinkedHashMap.scala | 34 |
2 files changed, 52 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index c26ea38b55..833df01d83 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -108,7 +108,15 @@ abstract class Pickler extends SubComponent { entries = entries1 } entries(ep) = entry + // debug NoSuchElementException + index.saveTableStringIfResize(entry.hashCode()) + index(entry) = ep + // debug NoSuchElementException + if (index.get(entry) == None) { + println("could not add entry: "+ entry +"; "+ entry.hashCode()) + index.printHashTable(entry.hashCode()) + } ep = ep + 1 true } @@ -459,7 +467,16 @@ abstract class Pickler extends SubComponent { * * @param ref ... */ - private def writeRef(ref: AnyRef) { writeNat(index(ref)) } + private def writeRef(ref: AnyRef) { + try { + writeNat(index(ref)) + } catch { + case e: java.util.NoSuchElementException => + println("entry not found: "+ ref +"; "+ ref.hashCode()) + index.printHashTable(ref.hashCode()) + throw e + } + } private def writeRefs(refs: List[AnyRef]) { refs foreach writeRef } /** Write name, owner, flags, and info of a symbol. diff --git a/src/library/scala/collection/mutable/LinkedHashMap.scala b/src/library/scala/collection/mutable/LinkedHashMap.scala index 476bd39b7e..5c4132f72b 100644 --- a/src/library/scala/collection/mutable/LinkedHashMap.scala +++ b/src/library/scala/collection/mutable/LinkedHashMap.scala @@ -67,4 +67,38 @@ class LinkedHashMap[A, B] extends Map[A, B] } override def elements = ordered.reverse.elements map {e => (e.key, e.value)} + + // debug NoSuchElementException in Pickler + var savedTableString = "" + def saveTableStringIfResize(hcode: Int) { + savedTableString = + if (tableSize + 1 > threshold) tableString(hcode) + else "" + } + + def tableString(hcode: Int): String = { + val sb = new StringBuilder + sb.append("index: "+ index(hcode) +"\n") + for (i <- 0 until table.length) { + sb.append(""+ i +": ") + var e = table(i).asInstanceOf[Entry] + while (e != null) { + sb.append("("+ (try { e.key.toString } catch { case _ => "<..>"}) +" -> "+ e.value +"), ") + e = e.next + } + sb.append("\n") + } + sb.toString + } + + def printHashTable(hcode: Int) { + if (savedTableString != "") { + println("BEFORE (add did a resize!)") + println(savedTableString) + println("AFTER") + } else { + println("TABLE after adding (no re-size was required)") + } + println(tableString(hcode)) + } } |