4

I was wondering if I put comments in my code and when someone tried to decompile it, if they could read the comments that I put?

Zach B.
  • 663
  • 1
  • 7
  • 17

4 Answers4

9

No, comments are never included as part of the compilation process. They are typically removed in some sort of pre-processing, or first-pass stage.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
5

Nope, comments are discarded by the compiler.

Paul Bellora
  • 54,340
  • 18
  • 130
  • 181
  • 1
    If your concern is to make it difficult for someone to figure out your code by decompiling it, there is also an option not to save local variable names in the compiled code. And if you really want to get tricky, there are bytecode obfuscators. – Russell Zahniser Jan 10 '12 at 02:56
2

No. And you can verify this by using DJ Java Decompiler, for example. If you also refer to the Java Class File Format, you'll see there's no construct for storing comments.

Behrang
  • 46,888
  • 25
  • 118
  • 160
1

Comments aren't included in the .class files, so a decompiler won't be able to produce them.

Ken Wayne VanderLinde
  • 18,915
  • 3
  • 47
  • 72