Do your javadocs get compiled into your class files?

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, 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. 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.