In java, will inherited members(static or instance, method or field) be compiled into subclass's .class file?
Or just keep a link to the super class's relavent member?
As far as class files are concerned, inherited members are not copied into subclasses. Here is relevant documentation from Oracle (emphasis added):
fields[]Each value in the fields table must be afield_info(§4.5) structure giving a complete description of a field in this class or interface. The fields table includes only those fields that are declared by this class or interface. It does not include items representing fields that are inherited from superclasses or superinterfaces.
methods[]Each value in the methods table must be a method_info (§4.6) structure giving a complete description of a method in this class or interface. [...] Themethod_infostructures represent all methods declared by this class or interface type, including instance methods, class methods, instance initialization methods (§2.9), and any class or interface initialization method (§2.9). The methods table does not include items representing methods that are inherited from superclasses or superinterfaces.
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