3
votes

I am checking scala code base.

Something confused me is the Int class:

It's a final abstract class, so all its member methods can not be implemented by subclassing. In addition, all of these member methods are abstract def without concrete implementation.

I can not understand why these abstract method works. Where can I find the concrete definition of these methods ?

1
@AllenChou I have read that post before, I understand why we have final abstract. My question emphasizes on the implementation of member methods.Hao Ren

1 Answers

7
votes

Where can I find the concrete definition of these methods ?

You can't, because there isn't. On the Java platform, Ints are synthetic objects that are in reality backed by JVM primitive ints, which aren't objects and thus can't have methods.

These files solely exist so that you have a place to attach documentation to. That way, you can just run scaladoc, and it will generate documentation for these fictional synthetic classes just like for any other class. If these files didn't exist, scaladoc would have to know about those classes, and the documentation for those classes would have to be maintained inside of scaladoc instead of inside the Scala library where it belongs.