Questions tagged [scala-java-interop]

This pertains to calling Scala code from Java or vice-versa.

332 questions
0
votes
4 answers

How to concatenate a list to another list in scala

Here i use to concatenate 2 Lists (with same type) using this :+ and the code is testResult :+ studentsearch the length of the list get value zero in the console Controller @RequestMapping(value = Array("parent/ViewReports.html")) def…
Prasanth A R
  • 4,046
  • 9
  • 48
  • 76
0
votes
1 answer

Apache collections UnmodifiableSet to scala immutable Set

What should I do when I get this? java.lang.ClassCastException: org.apache.commons.collections.set.UnmodifiableSet cannot be cast to scala.collection.immutable.Set
Anton
  • 494
  • 5
  • 19
0
votes
3 answers

Scala function to accept Java maps from Java code

I have a mixed Scala/Java project. I'm trying to write a Scala function that would accept either Scala maps (from Scala code) or Java maps (from Java code) - java.util.HashMap for a start. Here's what I came up with (Scala code): def test[M <:…
Alex
  • 82
  • 9
0
votes
1 answer

Should I use collectionAsScalaIterable({java collection}) or Seq({java collection}).flatten?

We're starting to use Scala Test to test our Java application, and I want to test the contents of a Java Collection. We came up with 2 possibilities: JavaConversions.collectionAsScalaIterable(getJavaCollection()) must contain(allOf(item1,…
Bernie
  • 2,253
  • 1
  • 16
  • 18
0
votes
0 answers

How to access a Java inherited field with the same name as a Scala method?

I'm having a Scala trait A with an abstract method trait A[T] { def self: T } Now it happened me that I want to extends a Java class not under my control with a field with the same name: public class B { protected T self; } I'd like to…
Petr
  • 62,528
  • 13
  • 153
  • 317
0
votes
1 answer

java Constructor can not convert to scala

i know java Constructor convert into Scala code. but this is my project Generic class implementation. i am using hibernate ,spring in this project and i create genericDAO trait but can't create It's implementation or i can't convert this java…
Prasanth A R
  • 4,046
  • 9
  • 48
  • 76
0
votes
1 answer

Is there anyway to create a new Scala object from a Java Class

I have a number of use cases for this, all around the idea of interop between existing Java libraries and new Scala Code. The use case I've selected is the easiest I think. Use Case: I working on providing a JUnit Runner for some scala tests (so…
Stave Escura
  • 2,058
  • 1
  • 19
  • 24
0
votes
1 answer

Scala types/collections when interfacing with Java and vice versa

When interfacing with a scala library in java, or a java library in scala, are there certain types or collections that don't map efficiently such that you have to perform "expensive" operations to perform a conversion? e.g. memory wise you might…
loyalflow
  • 14,275
  • 27
  • 107
  • 168
0
votes
2 answers

Call Java method with alternatives from Scala

I am trying to use the put method of the ContentValues class in the Android API from Scala, but I can't figure out a way to make Scala narrow down the type of list elements. For example : val a: List[(String, Any)](...) val cv = new…
F.X.
  • 6,809
  • 3
  • 49
  • 71
0
votes
1 answer

Convert List into Seq[(String,String)]

I want to use @helper.select form Play 2 template engine where I should specify Seq[(String,String)] containing data for . But I have List. And I know rather weakly Scala. Without this helper I populate