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
.classfile.Some estimate:
-g:linejust adds line number information (a few bytes)-g:varsincludes the full names of all variables. This is usually the most expensive option.-g:sourcejust adds the name of the source file (without path).Note:
-parametersmakes 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
.classfile, usejavap -vplus the path of the file.