As "Programming in Scala: A comprehensive step-by-step Guide" states, in Scala there are not basic types values, just objects: Integers are Int
instances and doubles are Double
instances. I assume that these classes map to Java's Integer
, Double
... classes and, therefore, are mapped as Object
subclasses.
In the book, the following type hierarchy (classes as types) is presented:
Few pages after this graph is presented, you can read:
What somehow troubles me is: If Scala´s Double
maps to Java's Double
which is an specification of java.lang.Object
and AnyRef
is an alias for java.lang.Object
too, should't AnyVal
be a subclass of AnyRef
?
EDIT
Few pages after that I read that primitive types are not mapped to Java's primitive types wrapper classes unless their "boxed" versions are required; but I am still confused since it seems to me that not all Scala's objects are java.lang.Object
sublcasses instances. That is: There are classes in Scala which could be not translated in the JVM as Object
subclasses.