Does Java do anything to prevent files from changing out from under it?

Peter B. Kessler Peter.Kessler at Sun.COM
Wed May 14 22:05:56 UTC 2008

Thanks all for the definitive responses.

			... peter

Alan Bateman wrote:
> Peter B. Kessler wrote:
>> Does the Java platform do anything to prevent files from changing
>> out from under it?  E.g., once one has opened a jar file for class
>> loading, could a malicious (or oblivious) user write to the jar
>> file and disturb the VM?  Or is that all relegated to "the operating
>> system", file system permissions, etc.?
>>             ... peter
> There isn't anything special so files that are open can be changed or 
> replaced by an attacker or unintentionally assuming they have 
> appropriate permissions. It's harder to replace files on Windows due to 
> file locking. When a file is replaced then for regular I/O we will 
> continue to access the original file until it is closed. As you mention 
> JAR files then I wonder if you might be thinking about mmap'ed files? 
> Are you looking at an error log with a SIGBUS by any chance :-)   I 
> believe we currently mmap the central directory of JAR/zip files. Dave 
> or Martin may want to say more about this but periodically people try to 
> replace JARs on the file system and wonder why the VM falls over soon 
> afterwards.
> -Alan.

More information about the core-libs-dev mailing list