diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java index 2fcb834310..0056b905e9 100755 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java @@ -24,6 +24,9 @@ import org.antlr.v4.runtime.misc.IntervalSet; import org.antlr.v4.runtime.misc.Pair; +import java.security.AccessController; +import java.security.PrivilegedAction; + import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; @@ -2184,11 +2187,13 @@ public Parser getParser() { public static String getSafeEnv(String envName) { try { - return System.getenv(envName); - } - catch(SecurityException e) { - // use the default value - } + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public String run() { + return System.getenv(envName); + } + }); + } catch (SecurityException e) { } return null; } }