JDK-4064912 : Empty environment array for Runtime.exec does not yield an empty environment.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.0.2,1.1.5
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 1997-07-16
  • Updated: 1998-11-17
  • Resolved: 1998-11-17
Related Reports
Duplicate :  
Duplicate :  
java.lang.Runtime.exec(String[]command, String[] env) says that it will
execute the command with the given environment.  This implies that if the
environment array is empty, the command should be executed with the 
empty environment.  This does not happen; in this case it is executed with
the environment inherited from the parent process.  However, that effect 
can be achieved by passing "null" for the environment array, as compared to 
an empty array.

Currently, there is no way to execute a command with an empty environment.

Accidentally inheriting the environment of the parent process can lead to
some very strange side effects for JavaTest and JCK.

The bug exists in JDK1.0.2, through to at least 1.1.3.

PUBLIC COMMENTS Empty environment array for Runtime.exec does not yield an empty environment.

EVALUATION After talking to many people, we think the proper behavior of Runtime.exec() should be that: 1. If passing a null pointer, the child process inherits the environment varaibles of parent process; 2. If passing an empty array of length 0, the child process will get the empty environment. I think we should make the API more clear, and adjust the current implementation to follow the above behavior. ###@###.### 1998-02-09