javajavadoc

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, if you have large javadocs, does it effect the overall size of your class file? Or does the compiler ignore everything beginning with // and /* ?


Solution

  • 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:

    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.