scala-java-interop

Visibility of properties in scala class

I defined a property in the constructor of my class the following way: class Step(val message:String = "") When I try access to message value from Java code y get a visbility error. Why? ...

Compatibility between Scala closures and Java 8 closures

After reading some OpenJDK mailinglist entries, it seems that the Oracle developers are currently further removing things from the closure proposal, because earlier design mistakes in the Java language complicate the introduction of the Java closures. Considering that Scala closures are much more powerful than the closures planned for J...

How do you call a Scala singleton method from Java?

I'm trying to inject some Scala code into my existing Java app. (So, being said, I want some more fun). I create a singleton stuff in Scala ScalaPower.scala package org.fun class ScalaPower object ScalaPower{ def showMyPower(time:Int) = { (0 to time-1).mkString(", ") } } Now, inside OldJava.java ...

Use Scala Constants in Java

I am currently evaluating Scala for future projects and came across something strange. I created the following constant for us in a JSP: val FORMATED_TIME = "formatedTime"; And it did not work. After some experimenting I decided to decompile to get to the bottom of it: private final java.lang.String FORMATED_TIME; public java.lang.S...

Scala extra no-arg constructor plus default constructor parameters

I am using the Scala 2.8 default parameters on a constructor, and for Java compatibility reasons, I wanted a no-arg constructor that uses the default parameters. This doesn't work for very sensible reasons: class MyClass(field1: String = "foo", field2: String = "bar") { def this() = { this() // <-- Does not compile, but how...