I have a scenario where I have some objects that need to take in references from each other. The only way I can get this to compile is to use lazy
class A(b:B)
class B(a:A)
lazy val a:A = new A(b)
lazy val b:B = new B(a)
I can do the same thing using some actors, and get it to compile also
    abstract class Message
    case class Message1 extends Message
    case class Message2 extends Message
    class Actor1(otherActor:Actor) extends Actor {
        def act() {
            loop {
                react {
                    case Message1 =>
                        println("received message1")
                        otherActor ! Message2
                    case _ =>
                }
            }
        }
    }
    class Actor2(otherActor:Actor) extends Actor {
        def act() {
            loop {
                react {
                    case Message2 =>
                        println("received message2")
                        otherActor ! Message1
                    case _ =>
                }
            }
        }
    }
    lazy val actor1:Actor = new Actor1(actor2)
    lazy val actor2:Actor = new Actor2(actor1)
However, when I add the following:
    actor1.start
    actor2.start
    actor1 ! Message1
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/fictitiousCompany/stackOverflowQuestion/Test Caused by: java.lang.ClassNotFoundException: com.fictitiousCompany.stackOverflowQuestion.Test at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
I'm using the Scala Eclipse Plugin 2.8.1.