}
private static void defineGlobalEnvConstants(Ruby runtime) {
Map environmentVariableMap = null;
OSEnvironment environment = new OSEnvironment();
try {
environmentVariableMap = environment.getEnvironmentVariableMap(runtime);
} catch (OSEnvironmentReaderExcepton e) {
// If the environment variables are not accessible shouldn't terminate
runtime.getWarnings().warn(ID.MISCELLANEOUS, e.getMessage());
}
if (environmentVariableMap == null) {
// if the environment variables can't be obtained, define an empty ENV
environmentVariableMap = new HashMap();
}
StringOnlyRubyHash h1 = new StringOnlyRubyHash(runtime,
environmentVariableMap, runtime.getNil());
h1.getSingletonClass().defineAnnotatedMethods(StringOnlyRubyHash.class);
runtime.defineGlobalConstant("ENV", h1);
// Define System.getProperties() in ENV_JAVA
Map systemProps = environment.getSystemPropertiesMap(runtime);
runtime.defineGlobalConstant("ENV_JAVA", new StringOnlyRubyHash(
runtime, systemProps, runtime.getNil()));
}