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 /*
?
To create a JavaDoc you do not need to compile the java file. To create the Java documentation API, you need to write Javadoc followed by file name. After successful execution of the above command, a number of HTML files will be created, open the file named index to see all the information about classes.
You can not compile a *.class file, Its already compiled code (bytecode) for its *.java source. I think you need to copy the code from JD Decompiler's editor to a java source file. i.e. copy the source code from JD's editor for Hello.class into a file named Hello.java .
It has two parts: – a description which is followed by block tags. To create a JavaDoc you do not need to compile the java file. To create the Java documentation API, you need to write Javadoc followed by file name.
As we know that a single Java programming language source file ( or we can say .java file) may contain one class or more than one class. So if a .java file has more than one class then each class will compile into a separate class files. For Example: Save this below code as Test.java on your system.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With