1

I'm getting the following error running a spark app:

 Caused by: java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [I

No, I didn't create a class named I or [I. It's kind of hard to google. Anyone know what this means?

Adair
  • 1,697
  • 18
  • 22

2 Answers2

2

It means Array[Int].

object Main extends App {
    println(classOf[Array[Int]])
}

Output:

class [I

See the Java documentation for Class.getName.

user2357112
  • 260,549
  • 28
  • 431
  • 505
1

You probably have something like this:

def retrieveArray(): Seq[Int] = Array(1)
retrieveArray().asInstanceOf[Array[Int]]

this is failing because when the Array[Int] is converted to a Seq[Int] it becomes WrappedArray[Int] that is a different type than Array[Int]

retrieveArray().toArray would make the conversion

Mikel San Vicente
  • 3,831
  • 2
  • 21
  • 39