Aladdin - Scala Bugtracking
[#161] project: compiler priority: high category: bug
submitter assigned to status date submitted
Burak Michel won't fix 2003-09-30 12:37:54.0
subject handling of main
code
object bugMain {
  def main( args:Array[String] ) = {
    System.out.println("yo!");
  }
}
// if you omit the following, no problem
class bugMain {
  val foo:String = "bum rush the show";
}
what happened
/tmp> scalac bugMain.scala 
/tmp> java bugMain
Exception in thread "main" java.lang.NoSuchMethodError: main
what expected that class bugMain does not interfere with object bugMain.
[back to overview]
Changes of this bug report
Michel  edited on  2003-09-30 13:17:39.0
It is a known limitation which has to be documented, because there is no workaround. When you have an object and a class with the same name, the compiler does not (because it cannot) create the "mirroring" class for the object which makes it possible to use the object from Java (that includes using it as an executable, as here).

In other words, if you have both an object and a class with the same name, you cannot access the object's methods through Java.