JDK-8194734 : Handle to jimage file inherited into child processes (win)
  • Type: Bug
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 9,10
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • CPU: x86
  • Submitted: 2018-01-06
  • Updated: 2021-08-04
  • Resolved: 2018-04-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b10Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 10, Version 1709 (OS Build 16299.125)

A DESCRIPTION OF THE PROBLEM :
- unpack the Java 9 Runtime Environment (tar.gz file) to a temporary directory
- using this JRE launch an external application, e.g. Notepad, and exit the Java application:

import java.io.*;

public class LaunchNotepad {
  public static void main(String[] args) throws IOException {
    Runtime.getRuntime().exec(new String[] {"C:\\Windows\\notepad.exe"});
  }
}

Notice, that the JRE directory can't be renamed. The reason is that according to Microsoft's ProcessExplorer the Notepad childprocess keeps lib/modules locked. This also happens when launching a second Java VM.

REGRESSION.  Last worked in version 8u144

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After the JRE 9 has exited, no launched application should lock any file inside the JRE directory structure, so the JRE directory can be renamed/removed by the launched application.
ACTUAL -
The JRE 9 can not be renamed/removed (even if the JRE has been exited) until the launched application has been exited.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;

public class LaunchNotepad {
  public static void main(String[] args) throws IOException {
    Runtime.getRuntime().exec(new String[] {"C:\\Windows\\notepad.exe"});
  }
}
---------- END SOURCE ----------


Comments
This question came up on SO too: https://stackoverflow.com/questions/48131595/java-9-why-it-keeps-lib-modules-locked-windows
08-01-2018