@@ -18,31 +18,25 @@ package com.twitter.chill
1818
1919import scala .collection .mutable .{WrappedArray , WrappedArrayBuilder }
2020
21- class WrappedArraySerializer [T ] extends KSerializer [WrappedArray [T ]] {
21+ class WrappedArraySerializer [T : ClassManifest ] extends KSerializer [WrappedArray [T ]] {
2222
2323 def write (kser : Kryo , out : Output , obj : WrappedArray [T ]) {
24- // Write the class-manifest, we don't use writeClass because it
25- // uses the registration system, and this class might not be registered
26- kser.writeObject(out, obj.elemManifest.erasure)
2724 out.writeInt(obj.size, true )
2825 obj.foreach { t =>
2926 val tRef = t.asInstanceOf [AnyRef ]
30- kser.writeObject (out, tRef)
27+ kser.writeClassAndObject (out, tRef)
3128 // After each intermediate object, flush
32- out.flush
29+ out.flush()
3330 }
3431 }
3532
3633 def read (kser : Kryo , in : Input , cls : Class [WrappedArray [T ]]) = {
37- // Write the class-manifest, we don't use writeClass because it
38- // uses the registration system, and this class might not be registered
39- val clazz = kser.readObject(in, classOf [Class [T ]]).asInstanceOf [Class [T ]]
4034 val size = in.readInt(true )
41- val bldr = new WrappedArrayBuilder [T ](ClassManifest .fromClass [T ](clazz) )
35+ val bldr = new WrappedArrayBuilder [T ](classManifest [T ])
4236 bldr.sizeHint(size)
4337 (0 until size).foreach { idx =>
44- bldr += kser.readObject (in, clazz)
38+ bldr += kser.readClassAndObject (in). asInstanceOf [ T ]
4539 }
46- bldr.result
40+ bldr.result()
4741 }
4842}
0 commit comments