I know about the usage difference between empty-parameter and parameterless methods in scala, and my question pertains to the class file generated. When I look at these two classes in javap, they look exactly the same:
class Foo {
def bar() = 123;
}
class Foo {
def bar = 123;
}
But when I look at them in scalap, they accurately reflect the parameter lists. Where in the class file is scalac making this distinction known?
In the .class file, there is a class file attribute called
ScalaSig, which contains all of the extra information needed by Scala. It’s not really readable by humans, but it is there:See also How is the Scala signature stored? and scala.reflect.ScalaSignature, which isn’t very interesting 🙂