javascalascala-java-interop

is it possible to have a circular dependency between .java and .scala classes?


Lets say I have class A defined in .java file, and class B defined in .scala file.
class A use class B and class B use class A.
If I use java compiler I will have a compilation error because class B is not compiled yet. If I use scala compiler class A will not be found. Is there a compiler that can compile both together?


Solution

  • I thought that Scala 2.7.2 introduced a joint compilation mode to do exactly this?

    Which version of scalac are you using, and is it running with this mode disabled?

    Edit: Wait a second, when you say scalac leads to Class A not being found - did you realise that you still need to compile the pure Java files with javac afterwards? Scalac's joint compilation mode doesn't actually produce *.class output for the Java files, merely compiles the Scala classes against their signatures. Hence you still need to compile the Java files afterwards, though this shouldn't be a problem for javac now that the Scala classes have been compiled.