Do your javadocs get compiled into your class files?
When you compile your java
files, does it also embed your javadocs and comments into the class file?
For example,开发者_StackOverflow社区 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, 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.
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.
精彩评论