Java
Source
Object's methods are marked as native, so it's easy to understand they are implemented behind the scene
Kotlin
Source
public open class Any {
public open operator fun equals(other: Any?): Boolean
public open fun hashCode(): Int
public open fun toString(): String
}
Any's methods are not marked as native or abstract, so question is next:
When and how Any's methods are generated and why I can't just copy-paste Any class and compile without errors?
Any
's methods are not generated. The compiler maps Any
to java.lang.Object
, which provides the implementations of methods as part of the JDK.
The methods are not marked as abstract, because Any
is not an abstract class. The methods are not marked as native
because the mapping of Kotlin standard library classes to JDK classes is not unique to the Any
class, and other methods mapped in a similar way are not native.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With