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 /*
?
No. There are several debug options that affect the size of a class file but the comments are never part of the resulting .class
file.
Some estimate:
-g:line
just adds line number information (a few bytes)-g:vars
includes the full names of all variables. This is usually the most expensive option.-g:source
just adds the name of the source file (without path).Note: -parameters
makes names of method parameter accessible via reflection. This is independent of -g:vars
.
Comments (and therefore JavaDoc) are never added to the bytecode.
To see what ends up in the .class
file, use javap -v
plus the path of the file.