I'm trying to understand how much space a java interface will take up, both on disk in the binary, and on a per instantiated object basis. Obligatory "every JVM implementation may be different" disclaimer, I am more interested not in a 100% exact answer, but in understanding the essentials of how this is handled.
If we assume a simple interface (no static final vars, no default implementations), how much space does this take in binary? I assume the human readable class name will need to be stored, for debugging/reflection, plus possibly some unique class identifier? When an object that implements this interface is instantiated, how many extra bytes of overhead does the interface add to the in-memory representation of the object, if any?
how much space a java interface will take up, both on disk in the binary, and on a per instantiated object basis.
On disk in the binary:
Definitive answer: See file size of .class
file.
Short answer: It depends, as Jim Garrison said.
Long answer: It depends on: length of package name, length of interface name, number of methods, length of method names, number of parameters, type of parameters, length of parameter names, type of return type, whether debug information is included, version of bytecode, ... and more ...
On a per instantiated object basis:
None.