--- old/src/windows/classes/java/lang/ProcessEnvironment.java Wed Apr 13 11:09:17 2011 +++ new/src/windows/classes/java/lang/ProcessEnvironment.java Wed Apr 13 11:09:16 2011 @@ -144,6 +144,7 @@ }; } private static Map.Entry checkedEntry (Object o) { + @SuppressWarnings("unchecked") Map.Entry e = (Map.Entry) o; nonNullString(e.getKey()); nonNullString(e.getValue()); @@ -282,7 +283,7 @@ // Only for use by ProcessBuilder.environment() static Map environment() { - return (Map) theEnvironment.clone(); + return (Map) theEnvironment.clone(); } // Only for use by Runtime.exec(...String[]envp...) @@ -295,7 +296,26 @@ // Only for use by ProcessImpl.start() String toEnvironmentBlock() { // Sort Unicode-case-insensitively by name - List> list = new ArrayList<>(entrySet()); + Set> entries = entrySet(); + List> list = new ArrayList<>(entries); + + // check for "SystemRoot". Needed by MSVCRT.DLL + // Environment variable names are case-insensitive. + // So, must do an iterative search. + boolean found = false; + for (Map.Entry entry : entries) { + String key = entry.getKey(); + if (key.equalsIgnoreCase("SystemRoot")) { + found = true; + break; + } + } + if (!found) { + list.add(new AbstractMap.SimpleEntry( + "SystemRoot", getenv("SystemRoot")) + ); + } + Collections.sort(list, entryComparator); StringBuilder sb = new StringBuilder(size()*30);