JDK-8080087 : Nashorn $ENV.PWD is originally undefined
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8-pool
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_8
  • CPU: x86
  • Submitted: 2015-05-10
  • Updated: 2015-09-29
  • Resolved: 2015-06-05
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 8 JDK 9
8u60Fixed 9 b69Fixed
Description
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]

A DESCRIPTION OF THE PROBLEM :
In Nashorn shell scripting, the variable $ENV.PWD contains the current working directory, that is used when executing commands. However, initially, $ENV.PWD is undefined.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save the script below to a file "test.js" and run "jjs -scripting test.js" from the command-line.

print($ENV.PWD);
$ENV.PWD = "C:\\Users";
print($ENV.PWD);


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2 lines are printed: the first is the directory where you saved the script, the second is "C:\Users"
ACTUAL -
2 lines are printed: the first is "undefined", the second is "C:\Users"

REPRODUCIBILITY :
This bug can be reproduced always.