When you compile your java
files, does it also embed your javadocs and comments into the class file?
For example, if you have large javadocs, does it effect the overall size of your class file? Or does the compiler ignore everything beginning with //
and /*
?
You can tell the compiler to include the sources in the class file (javac -g:source
). That means every bit of the source will be added. Comments, code, whitespace, everything.
If you do that, then the size of the source matters. Otherwise, it doesn't.
From a runtime perspective, the difference doesn't matter much.
No, comments are not compiled into your class files. This includes JavaDocs.
Instead, you need to use a JavaDoc tool (like Sun/Oracle's) on the source code to generate the documentation.
No, the class file is just binary data.
Annotations may be retained (depending on the annotation).
Comments won't affect the size of the class file.