src/jdk/nashorn/internal/objects/Global.java
Print this page
@@ -1703,13 +1703,30 @@
if (env._scripting) {
initScripting(env);
}
- if (Context.DEBUG && System.getSecurityManager() == null) {
+ if (Context.DEBUG) {
+ boolean debugOkay;
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ try {
+ sm.checkPermission(new RuntimePermission(Context.NASHORN_DEBUG_MODE));
+ debugOkay = true;
+ } catch (final SecurityException ignored) {
+ // if no permission, don't initialize Debug object
+ debugOkay = false;
+ }
+
+ } else {
+ debugOkay = true;
+ }
+
+ if (debugOkay) {
initDebug();
}
+ }
copyBuiltins();
// initialized with strings so that typeof will work as expected.
this.__FILE__ = "";