Does Java include comments on the compiled code?
Well, the title is self-explanatory. I wondered this while compiling a project which has a lot of lines comme开发者_高级运维nted. It's a bit silly because the jar file wouldn't increase much (some bytes) but I'm curious if this could affect a program with a lot of code and comments.
Thanks
No, comments normally are stripped out in any language (not just in Java). They have no representative in byte code. What stays in there, is annotated stuff and such
It would not affect the execution or performance (unless you have commented out the wrong statements :-)
But it definitely would affect readability. There is no reason to have large blocks of commented out code (in production), version control is the way to go
See this question also.Question closed.
No, documentation isn't included in the compiled class file.
The javadocs can be generated with the javadoc
program. All javadoc will be converterd to HTML.
No, this is not added.
However, you should consider to kill dead code (i.e. commented code, but also unused code). If you think that "maybe I will need that method again", simply delete the method, and if you really need this method some day, use you SCM tool (Subversion, Git, CVS or whatever) to retrieve this old code...
Yes, you are right. No, you miss something.
Yes, you are right. In my opinion, unnecessary old code fragments that have nothing to do with the program should not be stored in the source code as comments.
No, you are not right, because you have not noticed the completely obvious things. The old code as a comment may be evidence in matters related to copyright. Simply if you remove the old code from the program before the code is exposed as open source (or given to the recipient), then there will be no trace of the old code and it will be more difficult to prove that it ever existed at all. Let's imagine that we have fragment A, which we replaced with a (much better) fragment B. By publishing the code with both of them we show that we are the authors of solution A and solution B. By removing the old code A, we lose the possibility of referring to the fact that code A was created by us. Even if A is worse than B, it may still be good enough to want to protect our rights to it.
精彩评论