Skip to content

Commit 30edcc3

Browse files
authored
Merge pull request scala/scala#9166 from regadas/2.12.x_serial_version
Add missing @serialversionuid on collections
2 parents bb9c098 + 7684328 commit 30edcc3

23 files changed

+73
-0
lines changed

library/src/scala/collection/MapLike.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ self =>
172172

173173
/** The implementation class of the set returned by `keySet`.
174174
*/
175+
@SerialVersionUID(1589106351530299313L)
175176
protected class DefaultKeySet extends AbstractSet[K] with Set[K] with Serializable {
176177
def contains(key : K) = self.contains(key)
177178
def iterator = keysIterator

library/src/scala/collection/SortedMapLike.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ self =>
3636

3737
override def keySet : SortedSet[A] = new DefaultKeySortedSet
3838

39+
@SerialVersionUID(-38666158592954763L)
3940
protected class DefaultKeySortedSet extends super.DefaultKeySet with SortedSet[A] {
4041
implicit def ordering = self.ordering
4142
override def + (elem: A): SortedSet[A] = (SortedSet[A]() ++ this + elem)

library/src/scala/collection/convert/Wrappers.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ private[collection] trait Wrappers {
2727
override def isEmpty = underlying.isEmpty
2828
}
2929

30+
@SerialVersionUID(7914730360012802566L)
3031
case class IteratorWrapper[A](underlying: Iterator[A]) extends ju.Iterator[A] with ju.Enumeration[A] {
3132
def hasNext = underlying.hasNext
3233
def next() = underlying.next()
@@ -39,34 +40,41 @@ private[collection] trait Wrappers {
3940
def asJava = new IteratorWrapper(underlying)
4041
}
4142

43+
@SerialVersionUID(-2624079708378729299L)
4244
case class JIteratorWrapper[A](underlying: ju.Iterator[A]) extends AbstractIterator[A] with Iterator[A] {
4345
def hasNext = underlying.hasNext
4446
def next() = underlying.next
4547
}
4648

49+
@SerialVersionUID(1480199642890917878L)
4750
case class JEnumerationWrapper[A](underlying: ju.Enumeration[A]) extends AbstractIterator[A] with Iterator[A] {
4851
def hasNext = underlying.hasMoreElements
4952
def next() = underlying.nextElement
5053
}
5154

55+
@SerialVersionUID(8702516763061989735L)
5256
case class IterableWrapper[A](underlying: Iterable[A]) extends ju.AbstractCollection[A] with IterableWrapperTrait[A] { }
5357

58+
@SerialVersionUID(4914368587801013118L)
5459
case class JIterableWrapper[A](underlying: jl.Iterable[A]) extends AbstractIterable[A] with Iterable[A] {
5560
def iterator = underlying.iterator
5661
def newBuilder[B] = new mutable.ArrayBuffer[B]
5762
}
5863

64+
@SerialVersionUID(-9156669203906593803L)
5965
case class JCollectionWrapper[A](underlying: ju.Collection[A]) extends AbstractIterable[A] with Iterable[A] {
6066
def iterator = underlying.iterator
6167
override def size = underlying.size
6268
override def isEmpty = underlying.isEmpty
6369
def newBuilder[B] = new mutable.ArrayBuffer[B]
6470
}
6571

72+
@SerialVersionUID(-2066086677605085135L)
6673
case class SeqWrapper[A](underlying: Seq[A]) extends ju.AbstractList[A] with IterableWrapperTrait[A] {
6774
def get(i: Int) = underlying(i)
6875
}
6976

77+
@SerialVersionUID(-3277343097189933650L)
7078
case class MutableSeqWrapper[A](underlying: mutable.Seq[A]) extends ju.AbstractList[A] with IterableWrapperTrait[A] {
7179
def get(i: Int) = underlying(i)
7280
override def set(i: Int, elem: A) = {
@@ -76,13 +84,15 @@ private[collection] trait Wrappers {
7684
}
7785
}
7886

87+
@SerialVersionUID(2065310383330290590L)
7988
case class MutableBufferWrapper[A](underlying: mutable.Buffer[A]) extends ju.AbstractList[A] with IterableWrapperTrait[A] {
8089
def get(i: Int) = underlying(i)
8190
override def set(i: Int, elem: A) = { val p = underlying(i); underlying(i) = elem; p }
8291
override def add(elem: A) = { underlying append elem; true }
8392
override def remove(i: Int) = underlying remove i
8493
}
8594

95+
@SerialVersionUID(-7340917072424655477L)
8696
case class JListWrapper[A](underlying: ju.List[A]) extends mutable.AbstractBuffer[A] with mutable.Buffer[A] {
8797
def length = underlying.size
8898
override def isEmpty = underlying.isEmpty
@@ -132,6 +142,7 @@ private[collection] trait Wrappers {
132142
}
133143
}
134144

145+
@SerialVersionUID(-4801553198679985982L)
135146
case class MutableSetWrapper[A](underlying: mutable.Set[A]) extends SetWrapper[A](underlying) {
136147
override def add(elem: A) = {
137148
val sz = underlying.size
@@ -144,6 +155,7 @@ private[collection] trait Wrappers {
144155
override def clear() = underlying.clear()
145156
}
146157

158+
@SerialVersionUID(-8813164664953372494L)
147159
case class JSetWrapper[A](underlying: ju.Set[A]) extends mutable.AbstractSet[A] with mutable.Set[A] with mutable.SetLike[A, JSetWrapper[A]] {
148160

149161
override def size = underlying.size
@@ -240,6 +252,7 @@ private[collection] trait Wrappers {
240252
}
241253
}
242254

255+
@SerialVersionUID(8668425014051911127L)
243256
case class MutableMapWrapper[A, B](underlying: mutable.Map[A, B]) extends MapWrapper[A, B](underlying) {
244257
override def put(k: A, v: B) = underlying.put(k, v) match {
245258
case Some(v1) => v1
@@ -300,10 +313,12 @@ private[collection] trait Wrappers {
300313
* This includes `get`, as `java.util.Map`'s API does not allow for an
301314
* atomic `get` when `null` values may be present.
302315
*/
316+
@SerialVersionUID(5258955232187049103L)
303317
case class JMapWrapper[A, B](underlying : ju.Map[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JMapWrapper[A, B]] {
304318
override def empty = JMapWrapper(new ju.HashMap[A, B])
305319
}
306320

321+
@SerialVersionUID(3929791676502269860L)
307322
class ConcurrentMapWrapper[A, B](override val underlying: concurrent.Map[A, B]) extends MutableMapWrapper[A, B](underlying) with juc.ConcurrentMap[A, B] {
308323

309324
override def putIfAbsent(k: A, v: B) = underlying.putIfAbsent(k, v) match {
@@ -330,6 +345,7 @@ private[collection] trait Wrappers {
330345
* access is supported; multi-element operations such as maps and filters
331346
* are not guaranteed to be atomic.
332347
*/
348+
@SerialVersionUID(-8245743033724996882L)
333349
case class JConcurrentMapWrapper[A, B](underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] {
334350
override def get(k: A) = Option(underlying get k)
335351

@@ -345,6 +361,7 @@ private[collection] trait Wrappers {
345361
underlying.replace(k, oldvalue, newvalue)
346362
}
347363

364+
@SerialVersionUID(942915481780293390L)
348365
case class DictionaryWrapper[A, B](underlying: mutable.Map[A, B]) extends ju.Dictionary[A, B] {
349366
def size: Int = underlying.size
350367
def isEmpty: Boolean = underlying.isEmpty
@@ -372,6 +389,7 @@ private[collection] trait Wrappers {
372389
}
373390
}
374391

392+
@SerialVersionUID(-5214182838863307389L)
375393
case class JDictionaryWrapper[A, B](underlying: ju.Dictionary[A, B]) extends mutable.AbstractMap[A, B] with mutable.Map[A, B] {
376394
override def size: Int = underlying.size
377395

@@ -391,6 +409,7 @@ private[collection] trait Wrappers {
391409
override def clear() = underlying.clear()
392410
}
393411

412+
@SerialVersionUID(1265445269473530406L)
394413
case class JPropertiesWrapper(underlying: ju.Properties) extends mutable.AbstractMap[String, String]
395414
with mutable.Map[String, String]
396415
with mutable.MapLike[String, String, JPropertiesWrapper] {

library/src/scala/collection/immutable/BitSet.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ object BitSet extends BitSetFactory[BitSet] {
123123
else new BitSet1(elems - java.lang.Long.lowestOneBit(elems))
124124
}
125125

126+
@SerialVersionUID(-860417644893387539L)
126127
class BitSet2(val elems0: Long, elems1: Long) extends BitSet {
127128
protected def nwords = 2
128129
protected def word(idx: Int) = if (idx == 0) elems0 else if (idx == 1) elems1 else 0L
@@ -150,6 +151,7 @@ object BitSet extends BitSetFactory[BitSet] {
150151
* implementation. Care needs to be taken not to modify the exposed
151152
* array.
152153
*/
154+
@SerialVersionUID(807040099560956194L)
153155
class BitSetN(val elems: Array[Long]) extends BitSet {
154156
protected def nwords = elems.length
155157
protected def word(idx: Int) = if (idx < nwords) elems(idx) else 0L

library/src/scala/collection/immutable/HashMap.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
347347
}
348348

349349
@deprecatedInheritance("This class will be made final in a future release.", "2.12.2")
350+
@SerialVersionUID(4549809275616486327L)
350351
class HashMap1[A,+B](private[collection] val key: A, private[collection] val hash: Int, private[collection] val value: (B @uV), private[this] var kvOrNull: (A,B @uV)) extends HashMap[A,B] {
351352
override def size = 1
352353

@@ -436,6 +437,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
436437
}
437438
}
438439

440+
@SerialVersionUID(-1917647429457579983L)
439441
private[collection] class HashMapCollision1[A, +B](private[collection] val hash: Int, val kvs: ListMap[A, B @uV])
440442
extends HashMap[A, B @uV] {
441443
// assert(kvs.size > 1)
@@ -551,6 +553,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
551553
}
552554

553555
@deprecatedInheritance("This class will be made final in a future release.", "2.12.2")
556+
@SerialVersionUID(834418348325321784L)
554557
class HashTrieMap[A, +B](
555558
private[HashMap] var bitmap0: Int,
556559
private[HashMap] var elems0: Array[HashMap[A, B @uV]],

library/src/scala/collection/immutable/HashSet.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ object HashSet extends ImmutableSetFactory[HashSet] {
259259
/**
260260
* Common superclass of HashSet1 and HashSetCollision1, which are the two possible leaves of the Trie
261261
*/
262+
@SerialVersionUID(-8788235040812980474L)
262263
private[HashSet] sealed abstract class LeafHashSet[A](private[HashSet] final val hash: Int) extends HashSet[A]
263264

265+
@SerialVersionUID(7828248784025959392L)
264266
class HashSet1[A](private[HashSet] val key: A, hash: Int) extends LeafHashSet[A](hash) {
265267
override def size = 1
266268

@@ -333,6 +335,7 @@ object HashSet extends ImmutableSetFactory[HashSet] {
333335
override def foreach[U](f: A => U): Unit = f(key)
334336
}
335337

338+
@SerialVersionUID(-4499898620567995040L)
336339
private[immutable] class HashSetCollision1[A](hash: Int, val ks: ListSet[A], override val size: Int) extends LeafHashSet[A](hash) {
337340

338341
override protected def get0(key: A, hash: Int, level: Int): Boolean =
@@ -536,6 +539,7 @@ object HashSet extends ImmutableSetFactory[HashSet] {
536539
* elems: [a,b]
537540
* children: ---b----------------a-----------
538541
*/
542+
@SerialVersionUID(-1260675327783828535L)
539543
class HashTrieSet[A](private[HashSet] var bitmap: Int, private[collection] var elems: Array[HashSet[A]], private[HashSet] var size0: Int)
540544
extends HashSet[A] {
541545
@inline override final def size = size0

library/src/scala/collection/immutable/IntMap.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ object IntMap {
6464
def apply[T](elems: (Int, T)*): IntMap[T] =
6565
elems.foldLeft(empty[T])((x, y) => x.updated(y._1, y._2))
6666

67+
@SerialVersionUID(-9137650114085457282L)
6768
private[immutable] case object Nil extends IntMap[Nothing] {
6869
// Important! Without this equals method in place, an infinite
6970
// loop from Map.equals => size => pattern-match-on-Nil => equals
@@ -76,11 +77,13 @@ object IntMap {
7677
}
7778
}
7879

80+
@SerialVersionUID(3302720273753906158L)
7981
private[immutable] case class Tip[+T](key: Int, value: T) extends IntMap[T]{
8082
def withValue[S](s: S) =
8183
if (s.asInstanceOf[AnyRef] eq value.asInstanceOf[AnyRef]) this.asInstanceOf[IntMap.Tip[S]]
8284
else IntMap.Tip(key, s)
8385
}
86+
@SerialVersionUID(-523093388545197183L)
8487
private[immutable] case class Bin[+T](prefix: Int, mask: Int, left: IntMap[T], right: IntMap[T]) extends IntMap[T] {
8588
def bin[S](left: IntMap[S], right: IntMap[S]): IntMap[S] = {
8689
if ((this.left eq left) && (this.right eq right)) this.asInstanceOf[IntMap.Bin[S]]

library/src/scala/collection/immutable/LongMap.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ object LongMap {
6262
def apply[T](elems: (Long, T)*): LongMap[T] =
6363
elems.foldLeft(empty[T])((x, y) => x.updated(y._1, y._2))
6464

65+
@SerialVersionUID(1224320979026293120L)
6566
private[immutable] case object Nil extends LongMap[Nothing] {
6667
// Important, don't remove this! See IntMap for explanation.
6768
override def equals(that : Any) = that match {
@@ -71,11 +72,13 @@ object LongMap {
7172
}
7273
}
7374

75+
@SerialVersionUID(4938010434684160500L)
7476
private[immutable] case class Tip[+T](key: Long, value: T) extends LongMap[T] {
7577
def withValue[S](s: S) =
7678
if (s.asInstanceOf[AnyRef] eq value.asInstanceOf[AnyRef]) this.asInstanceOf[LongMap.Tip[S]]
7779
else LongMap.Tip(key, s)
7880
}
81+
@SerialVersionUID(2433491195925361636L)
7982
private[immutable] case class Bin[+T](prefix: Long, mask: Long, left: LongMap[T], right: LongMap[T]) extends LongMap[T] {
8083
def bin[S](left: LongMap[S], right: LongMap[S]): LongMap[S] = {
8184
if ((this.left eq left) && (this.right eq right)) this.asInstanceOf[LongMap.Bin[S]]

library/src/scala/collection/immutable/Map.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ object Map extends ImmutableMapFactory[Map] {
9191

9292
def empty[K, V]: Map[K, V] = EmptyMap.asInstanceOf[Map[K, V]]
9393

94+
@SerialVersionUID(-7464981207502461188L)
9495
class WithDefault[K, +V](underlying: Map[K, V], d: K => V) extends scala.collection.Map.WithDefault[K, V](underlying, d) with Map[K, V] {
9596
override def empty = new WithDefault(underlying.empty, d)
9697
override def updated[V1 >: V](key: K, value: V1): WithDefault[K, V1] = new WithDefault[K, V1](underlying.updated[V1](key, value), d)

library/src/scala/collection/immutable/NumericRange.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ package immutable
3939
* @define mayNotTerminateInf
4040
* @define willNotTerminateInf
4141
*/
42+
@SerialVersionUID(-5580158174769432538L)
4243
abstract class NumericRange[T]
4344
(val start: T, val end: T, val step: T, val isInclusive: Boolean)
4445
(implicit num: Integral[T])
@@ -365,6 +366,7 @@ object NumericRange {
365366
}
366367
}
367368

369+
@SerialVersionUID(-5986512874781685419L)
368370
class Inclusive[T](start: T, end: T, step: T)(implicit num: Integral[T])
369371
extends NumericRange(start, end, step, true) {
370372
def copy(start: T, end: T, step: T): Inclusive[T] =
@@ -373,6 +375,7 @@ object NumericRange {
373375
def exclusive: Exclusive[T] = NumericRange(start, end, step)
374376
}
375377

378+
@SerialVersionUID(-7058074814271573640L)
376379
class Exclusive[T](start: T, end: T, step: T)(implicit num: Integral[T])
377380
extends NumericRange(start, end, step, false) {
378381
def copy(start: T, end: T, step: T): Exclusive[T] =

library/src/scala/collection/immutable/Range.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ object Range {
439439
def count(start: Int, end: Int, step: Int): Int =
440440
count(start, end, step, isInclusive = false)
441441

442+
@SerialVersionUID(4237131469519710909L)
442443
final class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) {
443444
// override def par = new ParRange(this)
444445
override def isInclusive = true

library/src/scala/collection/immutable/SortedMap.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ self =>
4242
override def updated [B1 >: B](key: A, value: B1): SortedMap[A, B1] = this + ((key, value))
4343
override def keySet: immutable.SortedSet[A] = new DefaultKeySortedSet
4444

45+
@SerialVersionUID(112809526508924148L)
4546
protected class DefaultKeySortedSet extends super.DefaultKeySortedSet with immutable.SortedSet[A] {
4647
override def + (elem: A): SortedSet[A] =
4748
if (this(elem)) this

library/src/scala/collection/mutable/ArrayBuilder.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import scala.reflect.ClassTag
2222
*
2323
* @tparam T the type of the elements for the builder.
2424
*/
25+
@SerialVersionUID(-4721309866680431208L)
2526
abstract class ArrayBuilder[T] extends ReusableBuilder[T, Array[T]] with Serializable
2627

2728
/** A companion object for array builders.
@@ -61,6 +62,7 @@ object ArrayBuilder {
6162
*
6263
* @tparam T type of elements for the array builder, subtype of `AnyRef` with a `ClassTag` context bound.
6364
*/
65+
@SerialVersionUID(-8376727444766075941L)
6466
final class ofRef[T <: AnyRef : ClassTag] extends ArrayBuilder[T] {
6567

6668
private var elems: Array[T] = _
@@ -126,6 +128,7 @@ object ArrayBuilder {
126128
}
127129

128130
/** A class for array builders for arrays of `byte`s. It can be reused. */
131+
@SerialVersionUID(-3484148043254823366L)
129132
final class ofByte extends ArrayBuilder[Byte] {
130133

131134
private var elems: Array[Byte] = _
@@ -191,6 +194,7 @@ object ArrayBuilder {
191194
}
192195

193196
/** A class for array builders for arrays of `short`s. It can be reused. */
197+
@SerialVersionUID(3295904306819377609L)
194198
final class ofShort extends ArrayBuilder[Short] {
195199

196200
private var elems: Array[Short] = _
@@ -256,6 +260,7 @@ object ArrayBuilder {
256260
}
257261

258262
/** A class for array builders for arrays of `char`s. It can be reused. */
263+
@SerialVersionUID(-8284807600792805165L)
259264
final class ofChar extends ArrayBuilder[Char] {
260265

261266
private var elems: Array[Char] = _
@@ -321,6 +326,7 @@ object ArrayBuilder {
321326
}
322327

323328
/** A class for array builders for arrays of `int`s. It can be reused. */
329+
@SerialVersionUID(-3033902589330485711L)
324330
final class ofInt extends ArrayBuilder[Int] {
325331

326332
private var elems: Array[Int] = _
@@ -386,6 +392,7 @@ object ArrayBuilder {
386392
}
387393

388394
/** A class for array builders for arrays of `long`s. It can be reused. */
395+
@SerialVersionUID(-4278005356053656861L)
389396
final class ofLong extends ArrayBuilder[Long] {
390397

391398
private var elems: Array[Long] = _
@@ -451,6 +458,7 @@ object ArrayBuilder {
451458
}
452459

453460
/** A class for array builders for arrays of `float`s. It can be reused. */
461+
@SerialVersionUID(-740775369715282824L)
454462
final class ofFloat extends ArrayBuilder[Float] {
455463

456464
private var elems: Array[Float] = _
@@ -516,6 +524,7 @@ object ArrayBuilder {
516524
}
517525

518526
/** A class for array builders for arrays of `double`s. It can be reused. */
527+
@SerialVersionUID(2549152794429074790L)
519528
final class ofDouble extends ArrayBuilder[Double] {
520529

521530
private var elems: Array[Double] = _
@@ -581,6 +590,7 @@ object ArrayBuilder {
581590
}
582591

583592
/** A class for array builders for arrays of `boolean`s. It can be reused. */
593+
@SerialVersionUID(-3574834070591819420L)
584594
class ofBoolean extends ArrayBuilder[Boolean] {
585595

586596
private var elems: Array[Boolean] = _
@@ -646,6 +656,7 @@ object ArrayBuilder {
646656
}
647657

648658
/** A class for array builders for arrays of `Unit` type. It can be reused. */
659+
@SerialVersionUID(1995804197797796249L)
649660
final class ofUnit extends ArrayBuilder[Unit] {
650661

651662
private var size: Int = 0

0 commit comments

Comments
 (0)