Review Request: JDK-8173096 jmod files are not world-readable

Alan Bateman Alan.Bateman at
Fri Jan 20 21:22:17 UTC 2017

On 20/01/2017 20:37, Peter Levart wrote:

> I guess the JmodTask is creating a temp file because it wants the file 
> to not be observed by other processes while it is being written to, 
> right? At the end when the tempTarget is fully written, it is renamed 
> to its intended name with:
> Files.move(tempTarget, target);
> ...but that operation will not be atomic since you didn't pass 
> ATOMIC_MOVE to the CopyOption... options. Even if you did, the atomic 
> move will succeed only when both tempTarget and target point to the 
> same filesystem. Since you are creating tempTarget in default 
> temporary files location (/tmp on UNIXes) this might not be the case 
> (depending on where the real target is located).
> So why don't you simply append a .tmp suffix to the intended target 
> file name when opening the JmodOutputStream. This would ensure the 
> file location will be on the same filesystem as the final target name 
> as it will be created in the same directory. Module path scanning 
> should skip files with .tmp extension then.
Module path scanning doesn't skip unrecognized files, this is because it 
allows for implementation specific packaging formats.

Mandy - a while back then Erik changed the build so that JMOD files are 
created in JMODS_TEMPDIR rather than JMODS_DIR. I think this was to 
reduce interference with concurrent execution of the `jmod` tool. This 
might mean you can avoid using /tmp.


More information about the jigsaw-dev mailing list