As I was looking through the Java source code, I found some unusual files, mostly related to ByteBuffer
s in the java.nio
package which had a very messy source code and were labelled This file was mechanically generated: Do not edit!
.
These files also contained large portions of blank lines (some even in the middle of javadocs (!!?)), presumably to prevent the line numbers from changing. I have also seen a few java decompilers, such as procyon-decompiler
, which have an option to keep line numbers, but I doubt that's the case, because putting blank lines before the final accolade changes nothing.
Here are a few of these files (I couldn't find any links to them online and didn't pastebin them because I don't want to break any copyright, but you can find them in the src.zip
folder at the root of your JDK installation folder):
- java.nio.ByteBuffer
- java.nio.DirectByteBufferR
- java.nio.Bits
- java.nio.BufferOverflowException
I'd be curious to know:
- Which tool generated these files?
- Why does the tool keep the line numbers the same? Is it to make debugging (stacktraces) easier?
- Why would a tool be used to generate them, while all other classes are programmed by humans?
- Why would the tool put blank lines randomly inside parentheses, before the final accolade, or even in javadocs?