문제

Why does the Java byte-code interpreter change a 'class' file when I change only symbol names (classes, interfaces, functions or variables) in the corresponding 'java' file?

I am maintaining both types under source control (GIT), and I keep seeing "twice the amount of changed files" even for cosmetic changes such as the one mentioned above.

BTW, the question is not on source-control issues, but just FYI, the reason I keep these files on GIT is in order to be able to do "clean up" (delete all unversioned files), and then run the program from a command-line without recompiling it.

If you have any idea how to achieve this functionality (run without build) otherwise, then I would be happy to hear it...

Thanks

도움이 되었습니까?

해결책 2

The JVM needs access to the symbol names, for a number of reasons, including the following.

  • The JVM uses symbol names to find classes, methods and so on.
  • The presence of symbol names enables us to write code that uses reflection.
  • Symbol names appear in stack traces when an exception is thrown.

So the symbol names need to be stored in the class path.

다른 팁

Because the class files contain the symbol names.

Generally, people do not keep their class files in source control. If someone wants an old version of a class file, they get the old source file and compile it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top