Search code examples
javagitclassloader

Are java .class files needed after an application is running?


I had a hard time writing the title to this question, but here is my situation and what I am asking:

  • I have a Java project that I run "ant test" on to run the tests
  • The tests take about 10 minutes to run
  • Can I switch to a different Git branch in the middle of running these tests without consequences?
  • I want the tests to complete against the original code, and allow me to simply work on a different branch while that happens.

I guess the root of my question is: Are .class files needed after the application is loaded and running? Is the classes just stored in memory, and I don't need the files on the file system anymore? Or does it still access/read things on the filesystem?

Any insight or better understanding of what java needs for a running application is appreciated.


Solution

  • Classes are loaded on demand. The classloader won't attempt to load a class until that class has been referenced. Therefore, removing class files from the classpath in the middle of a run would almost certainly cause failures.