Given the following class and its companion object:
class B extends A
object B extends B
Where A is an abstract class in another file:
abstract class A {
def main(args: Array[String]): Unit = println("hey")
}
The above code is packaged into an uber-jar using the sbt assembly plugin, where the entry point is object B main method inherited from class B.
The above works fine. It runs. No problem at all.
Hoewver, sbt keeps warning:
[warn] B has the main method with parameter type Array[String], but B will not be a runnable program.
[warn] Reason: companion contains its own main method, which means no static forwarder can be generated.
[warn] object B extends B
- Do you know the meaning of this warning?
- And why sbt assurance that
object Bwon't run, doesn't happen?
Thank you.