Java List Conversions and Clear Operation

36 views
Skip to first unread message

ron.difrango

unread,
May 10, 2012, 11:44:07 AM5/10/12
to scala-user
I'm working with JAXB objects for a JAX-RS based application and as
such, I have to convert between scala lists/buffers to Java ones. In
addition to this, I have one situation where I have to clear out the
list by issuing the clear operation. When I do so I get the following
exception:

java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(AbstractList.java:144)
at java.util.AbstractList$Itr.remove(AbstractList.java:360)
at java.util.AbstractList.removeRange(AbstractList.java:559)
at java.util.AbstractList.clear(AbstractList.java:217)
at scala.collection.JavaConversions
$JListWrapper.clear(JavaConversions.scala:625)

I have tried doing things like:

mutableSeqAsJavaList(mySeq)

and

asJavaList(mySeq)

And in the debugger it shows up as a JavaConversions$MutableSeqWrapper
with the underlying type being an ArrayBuffer. yet the clear still
fails.

Is there any way to solve this other than copying the Scala collection
into a Java one?

ron.difrango

unread,
May 10, 2012, 3:14:05 PM5/10/12
to scala-user
I figured it out...I had to make everything buffers. Dulp!
Reply all
Reply to author
Forward
0 new messages