8202936: Improve script engine support

Tue, 19 Jun 2018 14:48:52 -0400

author
rpatil
date
Tue, 19 Jun 2018 14:48:52 -0400
changeset 2350
2152c4a01445
parent 2349
efdf56343d27
child 2351
41ac91662b75

8202936: Improve script engine support
Reviewed-by: sundar

src/jdk/nashorn/internal/objects/Global.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Thu Jun 14 12:37:20 2018 +0100
     1.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Tue Jun 19 14:48:52 2018 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -1427,13 +1427,14 @@
    1.11              }
    1.12          }
    1.13  
    1.14 -        switch (nameStr) {
    1.15 -        case "context":
    1.16 +        if ("context".equals(nameStr)) {
    1.17              return sctxt;
    1.18 -        case "engine":
    1.19 -            return global.engine;
    1.20 -        default:
    1.21 -            break;
    1.22 +        } else if ("engine".equals(nameStr)) {
    1.23 +            // expose "engine" variable only when there is no security manager
    1.24 +            // or when no class filter is set.
    1.25 +            if (System.getSecurityManager() == null || global.getClassFilter() == null) {
    1.26 +                return global.engine;
    1.27 +            }
    1.28          }
    1.29  
    1.30          if (self == UNDEFINED) {

mercurial