Merge

Mon, 09 Sep 2013 20:16:49 +0530

author
sundar
date
Mon, 09 Sep 2013 20:16:49 +0530
changeset 542
1eca380a221f
parent 539
9e4acaa1bb7e
parent 541
c3b6ce7b74bf
child 548
aa86166c6770

Merge

     1.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Fri Sep 06 14:20:58 2013 -0700
     1.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java	Mon Sep 09 20:16:49 2013 +0530
     1.3 @@ -315,7 +315,7 @@
     1.4              final ScriptObjectMirror mirror = (ScriptObjectMirror)thiz;
     1.5              realSelf = mirror.getScriptObject();
     1.6              realGlobal = mirror.getHomeGlobal();
     1.7 -            if (! realGlobal.isOfContext(nashornContext)) {
     1.8 +            if (! isOfContext(realGlobal, nashornContext)) {
     1.9                  throw new IllegalArgumentException(getMessage("script.object.from.another.engine"));
    1.10              }
    1.11          } else if (thiz instanceof ScriptObject) {
    1.12 @@ -326,7 +326,7 @@
    1.13                  throw new IllegalArgumentException(getMessage("no.current.nashorn.global"));
    1.14              }
    1.15  
    1.16 -            if (! realGlobal.isOfContext(nashornContext)) {
    1.17 +            if (! isOfContext(realGlobal, nashornContext)) {
    1.18                  throw new IllegalArgumentException(getMessage("script.object.from.another.engine"));
    1.19              }
    1.20          }
    1.21 @@ -394,7 +394,7 @@
    1.22      // Retrieve nashorn Global object from a given ScriptObjectMirror
    1.23      private ScriptObject globalFromMirror(final ScriptObjectMirror mirror) {
    1.24          ScriptObject sobj = mirror.getScriptObject();
    1.25 -        if (sobj instanceof GlobalObject && sobj.isOfContext(nashornContext)) {
    1.26 +        if (sobj instanceof GlobalObject && isOfContext(sobj, nashornContext)) {
    1.27              return sobj;
    1.28          }
    1.29  
    1.30 @@ -470,7 +470,7 @@
    1.31          ScriptObjectMirror selfMirror = null;
    1.32          if (selfObject instanceof ScriptObjectMirror) {
    1.33              selfMirror = (ScriptObjectMirror)selfObject;
    1.34 -            if (! selfMirror.getHomeGlobal().isOfContext(nashornContext)) {
    1.35 +            if (! isOfContext(selfMirror.getHomeGlobal(), nashornContext)) {
    1.36                  throw new IllegalArgumentException(getMessage("script.object.from.another.engine"));
    1.37              }
    1.38          } else if (selfObject instanceof ScriptObject) {
    1.39 @@ -481,7 +481,7 @@
    1.40                  throw new IllegalArgumentException(getMessage("no.current.nashorn.global"));
    1.41              }
    1.42  
    1.43 -            if (! oldGlobal.isOfContext(nashornContext)) {
    1.44 +            if (! isOfContext(oldGlobal, nashornContext)) {
    1.45                  throw new IllegalArgumentException(getMessage("script.object.from.another.engine"));
    1.46              }
    1.47  
    1.48 @@ -617,4 +617,9 @@
    1.49          }
    1.50          return true;
    1.51      }
    1.52 +
    1.53 +    private static boolean isOfContext(final ScriptObject global, final Context context) {
    1.54 +        assert global instanceof GlobalObject: "Not a Global object";
    1.55 +        return ((GlobalObject)global).isOfContext(context);
    1.56 +    }
    1.57  }
     2.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Fri Sep 06 14:20:58 2013 -0700
     2.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Mon Sep 09 20:16:49 2013 +0530
     2.3 @@ -42,6 +42,7 @@
     2.4  import java.util.concurrent.Callable;
     2.5  import javax.script.Bindings;
     2.6  import jdk.nashorn.internal.runtime.Context;
     2.7 +import jdk.nashorn.internal.runtime.GlobalObject;
     2.8  import jdk.nashorn.internal.runtime.ScriptFunction;
     2.9  import jdk.nashorn.internal.runtime.ScriptObject;
    2.10  import jdk.nashorn.internal.runtime.ScriptRuntime;
    2.11 @@ -62,6 +63,7 @@
    2.12  
    2.13      private final ScriptObject sobj;
    2.14      private final ScriptObject global;
    2.15 +    private final boolean strict;
    2.16  
    2.17      @Override
    2.18      public boolean equals(final Object other) {
    2.19 @@ -101,7 +103,7 @@
    2.20              final Object val = functionName == null? sobj : sobj.get(functionName);
    2.21              if (val instanceof ScriptFunction) {
    2.22                  final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
    2.23 -                return wrap(ScriptRuntime.checkAndApply((ScriptFunction)val, sobj, unwrapArray(modArgs, global)), global);
    2.24 +                return wrap(ScriptRuntime.apply((ScriptFunction)val, sobj, unwrapArray(modArgs, global)), global);
    2.25              } else if (val instanceof ScriptObjectMirror && ((ScriptObjectMirror)val).isFunction()) {
    2.26                  return ((ScriptObjectMirror)val).call(null, args);
    2.27              }
    2.28 @@ -131,7 +133,7 @@
    2.29              final Object val = functionName == null? sobj : sobj.get(functionName);
    2.30              if (val instanceof ScriptFunction) {
    2.31                  final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args;
    2.32 -                return wrap(ScriptRuntime.checkAndConstruct((ScriptFunction)val, unwrapArray(modArgs, global)), global);
    2.33 +                return wrap(ScriptRuntime.construct((ScriptFunction)val, unwrapArray(modArgs, global)), global);
    2.34              } else if (val instanceof ScriptObjectMirror && ((ScriptObjectMirror)val).isFunction()) {
    2.35                  return ((ScriptObjectMirror)val).newObject(null, args);
    2.36              }
    2.37 @@ -197,7 +199,7 @@
    2.38      public void setSlot(final int index, final Object value) {
    2.39          inGlobal(new Callable<Void>() {
    2.40              @Override public Void call() {
    2.41 -                sobj.set(index, unwrap(value, global), global.isStrictContext());
    2.42 +                sobj.set(index, unwrap(value, global), strict);
    2.43                  return null;
    2.44              }
    2.45          });
    2.46 @@ -209,7 +211,7 @@
    2.47      public void clear() {
    2.48          inGlobal(new Callable<Object>() {
    2.49              @Override public Object call() {
    2.50 -                sobj.clear();
    2.51 +                sobj.clear(strict);
    2.52                  return null;
    2.53              }
    2.54          });
    2.55 @@ -292,7 +294,7 @@
    2.56          return inGlobal(new Callable<Object>() {
    2.57              @Override public Object call() {
    2.58                  final Object modValue = globalChanged? wrap(value, oldGlobal) : value;
    2.59 -                return translateUndefined(wrap(sobj.put(key, unwrap(modValue, global)), global));
    2.60 +                return translateUndefined(wrap(sobj.put(key, unwrap(modValue, global), strict), global));
    2.61              }
    2.62          });
    2.63      }
    2.64 @@ -303,7 +305,6 @@
    2.65          final boolean globalChanged = (oldGlobal != global);
    2.66          inGlobal(new Callable<Object>() {
    2.67              @Override public Object call() {
    2.68 -                final boolean strict = global.isStrictContext();
    2.69                  for (final Map.Entry<? extends String, ? extends Object> entry : map.entrySet()) {
    2.70                      final Object value = entry.getValue();
    2.71                      final Object modValue = globalChanged? wrap(value, oldGlobal) : value;
    2.72 @@ -318,7 +319,7 @@
    2.73      public Object remove(final Object key) {
    2.74          return inGlobal(new Callable<Object>() {
    2.75              @Override public Object call() {
    2.76 -                return wrap(sobj.remove(unwrap(key, global)), global);
    2.77 +                return wrap(sobj.remove(unwrap(key, global), strict), global);
    2.78              }
    2.79          });
    2.80      }
    2.81 @@ -333,7 +334,7 @@
    2.82      public boolean delete(final Object key) {
    2.83          return inGlobal(new Callable<Boolean>() {
    2.84              @Override public Boolean call() {
    2.85 -                return sobj.delete(unwrap(key, global));
    2.86 +                return sobj.delete(unwrap(key, global), strict);
    2.87              }
    2.88          });
    2.89      }
    2.90 @@ -637,10 +638,11 @@
    2.91  
    2.92      ScriptObjectMirror(final ScriptObject sobj, final ScriptObject global) {
    2.93          assert sobj != null : "ScriptObjectMirror on null!";
    2.94 -        assert global != null : "null global for ScriptObjectMirror!";
    2.95 +        assert global instanceof GlobalObject : "global is not a GlobalObject";
    2.96  
    2.97          this.sobj = sobj;
    2.98          this.global = global;
    2.99 +        this.strict = ((GlobalObject)global).isStrictContext();
   2.100      }
   2.101  
   2.102      // accessors for script engine
     3.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Fri Sep 06 14:20:58 2013 -0700
     3.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Mon Sep 09 20:16:49 2013 +0530
     3.3 @@ -412,6 +412,14 @@
     3.4      // initialized by nasgen
     3.5      private static PropertyMap $nasgenmap$;
     3.6  
     3.7 +    // context to which this global belongs to
     3.8 +    private final Context context;
     3.9 +
    3.10 +    @Override
    3.11 +    protected Context getContext() {
    3.12 +        return context;
    3.13 +    }
    3.14 +
    3.15      // performs initialization checks for Global constructor and returns the
    3.16      // PropertyMap, if everything is fine.
    3.17      private static PropertyMap checkAndGetMap(final Context context) {
    3.18 @@ -439,7 +447,7 @@
    3.19       */
    3.20      public Global(final Context context) {
    3.21          super(checkAndGetMap(context));
    3.22 -        this.setContext(context);
    3.23 +        this.context = context;
    3.24          this.setIsScope();
    3.25  
    3.26          final int cacheSize = context.getEnv()._class_cache_size;
    3.27 @@ -482,6 +490,16 @@
    3.28      // GlobalObject interface implementation
    3.29  
    3.30      @Override
    3.31 +    public boolean isOfContext(final Context context) {
    3.32 +        return this.context == context;
    3.33 +    }
    3.34 +
    3.35 +    @Override
    3.36 +    public boolean isStrictContext() {
    3.37 +        return context.getEnv()._strict;
    3.38 +    }
    3.39 +
    3.40 +    @Override
    3.41      public void initBuiltinObjects() {
    3.42          if (this.builtinObject != null) {
    3.43              // already initialized, just return
    3.44 @@ -1765,7 +1783,7 @@
    3.45              // do not fill $ENV if we have a security manager around
    3.46              // Retrieve current state of ENV variables.
    3.47              final ScriptObject env = newObject();
    3.48 -            env.putAll(System.getenv());
    3.49 +            env.putAll(System.getenv(), scriptEnv._strict);
    3.50              addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
    3.51          } else {
    3.52              addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
     4.1 --- a/src/jdk/nashorn/internal/parser/Parser.java	Fri Sep 06 14:20:58 2013 -0700
     4.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java	Mon Sep 09 20:16:49 2013 +0530
     4.3 @@ -2060,7 +2060,7 @@
     4.4          case FLOATING:
     4.5              return getLiteral();
     4.6          default:
     4.7 -            return getIdentifierName();
     4.8 +            return getIdentifierName().setIsPropertyName();
     4.9          }
    4.10      }
    4.11  
     5.1 --- a/src/jdk/nashorn/internal/runtime/Context.java	Fri Sep 06 14:20:58 2013 -0700
     5.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java	Mon Sep 09 20:16:49 2013 +0530
     5.3 @@ -573,7 +573,7 @@
     5.4          setGlobalTrusted(newGlobal);
     5.5  
     5.6          final Object[] wrapped = args == null? ScriptRuntime.EMPTY_ARRAY :  ScriptObjectMirror.wrapArray(args, oldGlobal);
     5.7 -        newGlobal.put("arguments", ((GlobalObject)newGlobal).wrapAsObject(wrapped));
     5.8 +        newGlobal.put("arguments", ((GlobalObject)newGlobal).wrapAsObject(wrapped), env._strict);
     5.9  
    5.10          try {
    5.11              // wrap objects from newGlobal's world as mirrors - but if result
     6.1 --- a/src/jdk/nashorn/internal/runtime/GlobalObject.java	Fri Sep 06 14:20:58 2013 -0700
     6.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalObject.java	Mon Sep 09 20:16:49 2013 +0530
     6.3 @@ -37,6 +37,18 @@
     6.4  
     6.5  public interface GlobalObject {
     6.6      /**
     6.7 +     * Is this global of the given Context?
     6.8 +     * @return true if this global belongs to the given Context
     6.9 +     */
    6.10 +    public boolean isOfContext(Context context);
    6.11 +
    6.12 +    /**
    6.13 +     * Does this global belong to a strict Context?
    6.14 +     * @return true if this global belongs to a strict Context
    6.15 +     */
    6.16 +    public boolean isStrictContext();
    6.17 +
    6.18 +    /**
    6.19       * Initialize standard builtin objects like "Object", "Array", "Function" etc.
    6.20       * as well as our extension builtin objects like "Java", "JSAdapter" as properties
    6.21       * of the global scope object.
     7.1 --- a/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java	Fri Sep 06 14:20:58 2013 -0700
     7.2 +++ b/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java	Mon Sep 09 20:16:49 2013 +0530
     7.3 @@ -198,7 +198,7 @@
     7.4          final String propertyName = desc.getNameToken(2);
     7.5          final String fullName     = name.isEmpty() ? propertyName : name + "." + propertyName;
     7.6  
     7.7 -        final Context context = getContext();
     7.8 +        final Context context = Context.getContextTrusted();
     7.9  
    7.10          Class<?> javaClass = null;
    7.11          try {
     8.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java	Fri Sep 06 14:20:58 2013 -0700
     8.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java	Mon Sep 09 20:16:49 2013 +0530
     8.3 @@ -120,9 +120,6 @@
     8.4      /** objects proto. */
     8.5      private ScriptObject proto;
     8.6  
     8.7 -    /** Context of the object, lazily cached. */
     8.8 -    private Context context;
     8.9 -
    8.10      /** Object flags. */
    8.11      private int flags;
    8.12  
    8.13 @@ -1043,40 +1040,11 @@
    8.14      }
    8.15  
    8.16      /**
    8.17 -     * Return true if the script object context is strict
    8.18 -     * @return true if strict context
    8.19 -     */
    8.20 -    public final boolean isStrictContext() {
    8.21 -        return getContext()._strict;
    8.22 -    }
    8.23 -
    8.24 -    /**
    8.25 -     * Checks if this object belongs to the given context
    8.26 -     * @param ctx context to check against
    8.27 -     * @return true if this object belongs to the given context
    8.28 -     */
    8.29 -    public final boolean isOfContext(final Context ctx) {
    8.30 -        return context == ctx;
    8.31 -    }
    8.32 -
    8.33 -    /**
    8.34       * Return the current context from the object's map.
    8.35       * @return Current context.
    8.36       */
    8.37 -    protected final Context getContext() {
    8.38 -        if (context == null) {
    8.39 -            context = Context.fromClass(getClass());
    8.40 -        }
    8.41 -        return context;
    8.42 -    }
    8.43 -
    8.44 -    /**
    8.45 -     * Set the current context.
    8.46 -     * @param ctx context instance to set
    8.47 -     */
    8.48 -    protected final void setContext(final Context ctx) {
    8.49 -        ctx.getClass();
    8.50 -        this.context = ctx;
    8.51 +    protected Context getContext() {
    8.52 +        return Context.fromClass(getClass());
    8.53      }
    8.54  
    8.55      /**
    8.56 @@ -1482,9 +1450,10 @@
    8.57      /**
    8.58       * Clears the properties from a ScriptObject
    8.59       * (java.util.Map-like method to help ScriptObjectMirror implementation)
    8.60 +     *
    8.61 +     * @param strict strict mode or not
    8.62       */
    8.63 -    public void clear() {
    8.64 -        final boolean strict = isStrictContext();
    8.65 +    public void clear(final boolean strict) {
    8.66          final Iterator<String> iter = propertyIterator();
    8.67          while (iter.hasNext()) {
    8.68              delete(iter.next(), strict);
    8.69 @@ -1568,11 +1537,12 @@
    8.70       *
    8.71       * @param key property key
    8.72       * @param value property value
    8.73 +     * @param strict strict mode or not
    8.74       * @return oldValue if property with same key existed already
    8.75       */
    8.76 -    public Object put(final Object key, final Object value) {
    8.77 +    public Object put(final Object key, final Object value, final boolean strict) {
    8.78          final Object oldValue = get(key);
    8.79 -        set(key, value, isStrictContext());
    8.80 +        set(key, value, strict);
    8.81          return oldValue;
    8.82      }
    8.83  
    8.84 @@ -1582,9 +1552,9 @@
    8.85       * (java.util.Map-like method to help ScriptObjectMirror implementation)
    8.86       *
    8.87       * @param otherMap a {@literal <key,value>} map of properties to add
    8.88 +     * @param strict strict mode or not
    8.89       */
    8.90 -    public void putAll(final Map<?, ?> otherMap) {
    8.91 -        final boolean strict = isStrictContext();
    8.92 +    public void putAll(final Map<?, ?> otherMap, final boolean strict) {
    8.93          for (final Map.Entry<?, ?> entry : otherMap.entrySet()) {
    8.94              set(entry.getKey(), entry.getValue(), strict);
    8.95          }
    8.96 @@ -1595,26 +1565,16 @@
    8.97       * (java.util.Map-like method to help ScriptObjectMirror implementation)
    8.98       *
    8.99       * @param key the key of the property
   8.100 +     * @param strict strict mode or not
   8.101       * @return the oldValue of the removed property
   8.102       */
   8.103 -    public Object remove(final Object key) {
   8.104 +    public Object remove(final Object key, final boolean strict) {
   8.105          final Object oldValue = get(key);
   8.106 -        delete(key, isStrictContext());
   8.107 +        delete(key, strict);
   8.108          return oldValue;
   8.109      }
   8.110  
   8.111      /**
   8.112 -     * Delete a property from the ScriptObject.
   8.113 -     * (to help ScriptObjectMirror implementation)
   8.114 -     *
   8.115 -     * @param key the key of the property
   8.116 -     * @return if the delete was successful or not
   8.117 -     */
   8.118 -    public boolean delete(final Object key) {
   8.119 -        return delete(key, isStrictContext());
   8.120 -    }
   8.121 -
   8.122 -    /**
   8.123       * Return the size of the ScriptObject - i.e. the number of properties
   8.124       * it contains
   8.125       * (java.util.Map-like method to help ScriptObjectMirror implementation)
   8.126 @@ -2333,11 +2293,9 @@
   8.127             return;
   8.128         }
   8.129  
   8.130 -       final boolean isStrict = isStrictContext();
   8.131 -
   8.132         if (newLength > arrayLength) {
   8.133             setArray(getArray().ensure(newLength - 1));
   8.134 -            if (getArray().canDelete(arrayLength, (newLength - 1), isStrict)) {
   8.135 +            if (getArray().canDelete(arrayLength, (newLength - 1), false)) {
   8.136                 setArray(getArray().delete(arrayLength, (newLength - 1)));
   8.137             }
   8.138             return;
     9.1 --- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Fri Sep 06 14:20:58 2013 -0700
     9.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Mon Sep 09 20:16:49 2013 +0530
     9.3 @@ -352,35 +352,6 @@
     9.4      }
     9.5  
     9.6      /**
     9.7 -     * Check that the target function is associated with current Context. And also make sure that 'self', if
     9.8 -     * ScriptObject, is from current context.
     9.9 -     *
    9.10 -     * Call a function given self and args. If the number of the arguments is known in advance, you can likely achieve
    9.11 -     * better performance by {@link Bootstrap#createDynamicInvoker(String, Class, Class...) creating a dynamic invoker}
    9.12 -     * for operation {@code "dyn:call"}, then using its {@link MethodHandle#invokeExact(Object...)} method instead.
    9.13 -     *
    9.14 -     * @param target ScriptFunction object.
    9.15 -     * @param self   Receiver in call.
    9.16 -     * @param args   Call arguments.
    9.17 -     * @return Call result.
    9.18 -     */
    9.19 -    public static Object checkAndApply(final ScriptFunction target, final Object self, final Object... args) {
    9.20 -        final ScriptObject global = Context.getGlobalTrusted();
    9.21 -        assert (global instanceof GlobalObject): "No current global set";
    9.22 -
    9.23 -        if (target.getContext() != global.getContext()) {
    9.24 -            throw new IllegalArgumentException("'target' function is not from current Context");
    9.25 -        }
    9.26 -
    9.27 -        if (self instanceof ScriptObject && ((ScriptObject)self).getContext() != global.getContext()) {
    9.28 -            throw new IllegalArgumentException("'self' object is not from current Context");
    9.29 -        }
    9.30 -
    9.31 -        // all in order - call real 'apply'
    9.32 -        return apply(target, self, args);
    9.33 -    }
    9.34 -
    9.35 -    /**
    9.36       * Call a function given self and args. If the number of the arguments is known in advance, you can likely achieve
    9.37       * better performance by {@link Bootstrap#createDynamicInvoker(String, Class, Class...) creating a dynamic invoker}
    9.38       * for operation {@code "dyn:call"}, then using its {@link MethodHandle#invokeExact(Object...)} method instead.
    9.39 @@ -401,28 +372,6 @@
    9.40      }
    9.41  
    9.42      /**
    9.43 -     * Check that the target function is associated with current Context.
    9.44 -     * And also make sure that 'self', if ScriptObject, is from current context.
    9.45 -     *
    9.46 -     * Call a function as a constructor given args.
    9.47 -     *
    9.48 -     * @param target ScriptFunction object.
    9.49 -     * @param args   Call arguments.
    9.50 -     * @return Constructor call result.
    9.51 -     */
    9.52 -    public static Object checkAndConstruct(final ScriptFunction target, final Object... args) {
    9.53 -        final ScriptObject global = Context.getGlobalTrusted();
    9.54 -        assert (global instanceof GlobalObject): "No current global set";
    9.55 -
    9.56 -        if (target.getContext() != global.getContext()) {
    9.57 -            throw new IllegalArgumentException("'target' function is not from current Context");
    9.58 -        }
    9.59 -
    9.60 -        // all in order - call real 'construct'
    9.61 -        return construct(target, args);
    9.62 -    }
    9.63 -
    9.64 -    /**
    9.65       * Call a script function as a constructor with given args.
    9.66       *
    9.67       * @param target ScriptFunction object.
    9.68 @@ -520,9 +469,12 @@
    9.69              throw typeError(global, "cant.apply.with.to.null");
    9.70          }
    9.71  
    9.72 -        final ScriptObject withObject = new WithObject(scope, JSType.toScriptObject(global, expression));
    9.73 +        final Object wrappedExpr = JSType.toScriptObject(global, expression);
    9.74 +        if (wrappedExpr instanceof ScriptObject) {
    9.75 +            return new WithObject(scope, (ScriptObject)wrappedExpr);
    9.76 +        }
    9.77  
    9.78 -        return withObject;
    9.79 +        throw typeError(global, "cant.apply.with.to.non.scriptobject");
    9.80      }
    9.81  
    9.82      /**
    9.83 @@ -534,7 +486,7 @@
    9.84       */
    9.85      public static ScriptObject closeWith(final ScriptObject scope) {
    9.86          if (scope instanceof WithObject) {
    9.87 -            return scope.getProto();
    9.88 +            return ((WithObject)scope).getParentScope();
    9.89          }
    9.90          return scope;
    9.91      }
    10.1 --- a/src/jdk/nashorn/internal/runtime/WithObject.java	Fri Sep 06 14:20:58 2013 -0700
    10.2 +++ b/src/jdk/nashorn/internal/runtime/WithObject.java	Mon Sep 09 20:16:49 2013 +0530
    10.3 @@ -30,26 +30,26 @@
    10.4  import java.lang.invoke.MethodHandle;
    10.5  import java.lang.invoke.MethodHandles;
    10.6  import java.lang.invoke.MethodType;
    10.7 +import java.lang.invoke.SwitchPoint;
    10.8  import jdk.internal.dynalink.CallSiteDescriptor;
    10.9  import jdk.internal.dynalink.linker.GuardedInvocation;
   10.10  import jdk.internal.dynalink.linker.LinkRequest;
   10.11  import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
   10.12  import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
   10.13  
   10.14 -
   10.15  /**
   10.16   * This class supports the handling of scope in a with body.
   10.17   *
   10.18   */
   10.19  public final class WithObject extends ScriptObject implements Scope {
   10.20 -
   10.21 +    private static final MethodHandle WITHEXPRESSIONGUARD    = findOwnMH("withExpressionGuard",  boolean.class, Object.class, PropertyMap.class, SwitchPoint.class);
   10.22      private static final MethodHandle WITHEXPRESSIONFILTER   = findOwnMH("withFilterExpression", Object.class, Object.class);
   10.23      private static final MethodHandle WITHSCOPEFILTER        = findOwnMH("withFilterScope",      Object.class, Object.class);
   10.24      private static final MethodHandle BIND_TO_EXPRESSION_OBJ = findOwnMH("bindToExpression",     Object.class, Object.class, Object.class);
   10.25      private static final MethodHandle BIND_TO_EXPRESSION_FN  = findOwnMH("bindToExpression",     Object.class, ScriptFunction.class, Object.class);
   10.26  
   10.27      /** With expression object. */
   10.28 -    private final Object expression;
   10.29 +    private final ScriptObject expression;
   10.30  
   10.31      /**
   10.32       * Constructor
   10.33 @@ -57,12 +57,13 @@
   10.34       * @param scope scope object
   10.35       * @param expression with expression
   10.36       */
   10.37 -    WithObject(final ScriptObject scope, final Object expression) {
   10.38 +    WithObject(final ScriptObject scope, final ScriptObject expression) {
   10.39          super(scope, null);
   10.40          setIsScope();
   10.41          this.expression = expression;
   10.42      }
   10.43  
   10.44 +
   10.45      /**
   10.46       * Delete a property based on a key.
   10.47       * @param key Any valid JavaScript value.
   10.48 @@ -71,15 +72,13 @@
   10.49       */
   10.50      @Override
   10.51      public boolean delete(final Object key, final boolean strict) {
   10.52 -        if (expression instanceof ScriptObject) {
   10.53 -            final ScriptObject self = (ScriptObject)expression;
   10.54 -            final String propName = JSType.toString(key);
   10.55 +        final ScriptObject self = expression;
   10.56 +        final String propName = JSType.toString(key);
   10.57  
   10.58 -            final FindProperty find = self.findProperty(propName, true);
   10.59 +        final FindProperty find = self.findProperty(propName, true);
   10.60  
   10.61 -            if (find != null) {
   10.62 -                return self.delete(propName, strict);
   10.63 -            }
   10.64 +        if (find != null) {
   10.65 +            return self.delete(propName, strict);
   10.66          }
   10.67  
   10.68          return false;
   10.69 @@ -105,18 +104,16 @@
   10.70              name = null;
   10.71          }
   10.72  
   10.73 -        if (expression instanceof ScriptObject) {
   10.74 -            self = (ScriptObject)expression;
   10.75 -            if (isNamedOperation) {
   10.76 -                find = self.findProperty(name, true);
   10.77 -            }
   10.78 +        self = expression;
   10.79 +        if (isNamedOperation) {
   10.80 +             find = self.findProperty(name, true);
   10.81 +        }
   10.82  
   10.83 -            if (find != null) {
   10.84 -                link = self.lookup(desc, request);
   10.85 +        if (find != null) {
   10.86 +            link = self.lookup(desc, request);
   10.87  
   10.88 -                if (link != null) {
   10.89 -                    return fixExpressionCallSite(ndesc, link);
   10.90 -                }
   10.91 +            if (link != null) {
   10.92 +                return fixExpressionCallSite(ndesc, link);
   10.93              }
   10.94          }
   10.95  
   10.96 @@ -126,7 +123,7 @@
   10.97          }
   10.98  
   10.99          if (find != null) {
  10.100 -            return fixScopeCallSite(scope.lookup(desc, request));
  10.101 +            return fixScopeCallSite(scope.lookup(desc, request), name);
  10.102          }
  10.103  
  10.104          // the property is not found - now check for
  10.105 @@ -178,7 +175,7 @@
  10.106          link = scope.lookup(desc, request);
  10.107  
  10.108          if (link != null) {
  10.109 -            return fixScopeCallSite(link);
  10.110 +            return fixScopeCallSite(link, name);
  10.111          }
  10.112  
  10.113          return null;
  10.114 @@ -197,11 +194,9 @@
  10.115       */
  10.116      @Override
  10.117      FindProperty findProperty(final String key, final boolean deep, final boolean stopOnNonScope, final ScriptObject start) {
  10.118 -        if (expression instanceof ScriptObject) {
  10.119 -            final FindProperty exprProperty = ((ScriptObject)expression).findProperty(key, deep, stopOnNonScope, start);
  10.120 -            if(exprProperty != null) {
  10.121 -                return exprProperty;
  10.122 -            }
  10.123 +        final FindProperty exprProperty = expression.findProperty(key, deep, stopOnNonScope, start);
  10.124 +        if (exprProperty != null) {
  10.125 +             return exprProperty;
  10.126          }
  10.127          return super.findProperty(key, deep, stopOnNonScope, start);
  10.128      }
  10.129 @@ -220,16 +215,17 @@
  10.130       * Get first parent scope that is not an instance of WithObject.
  10.131       */
  10.132      private Scope getNonWithParent() {
  10.133 -        ScriptObject proto = getProto();
  10.134 +        ScriptObject proto = getParentScope();
  10.135  
  10.136          while (proto != null && proto instanceof WithObject) {
  10.137 -            proto = proto.getProto();
  10.138 +            proto = ((WithObject)proto).getParentScope();
  10.139          }
  10.140  
  10.141          assert proto instanceof Scope : "with scope without parent scope";
  10.142          return (Scope) proto;
  10.143      }
  10.144  
  10.145 +
  10.146      private static GuardedInvocation fixReceiverType(final GuardedInvocation link, final MethodHandle filter) {
  10.147          // The receiver may be an Object or a ScriptObject.
  10.148          final MethodType invType = link.getInvocation().type();
  10.149 @@ -256,9 +252,13 @@
  10.150                  filterGuard(link, WITHEXPRESSIONFILTER));
  10.151      }
  10.152  
  10.153 -    private static GuardedInvocation fixScopeCallSite(final GuardedInvocation link) {
  10.154 +    private GuardedInvocation fixScopeCallSite(final GuardedInvocation link, final String name) {
  10.155          final GuardedInvocation newLink = fixReceiverType(link, WITHSCOPEFILTER);
  10.156 -        return link.replaceMethods(filter(newLink.getInvocation(), WITHSCOPEFILTER), filterGuard(newLink, WITHSCOPEFILTER));
  10.157 +        return link.replaceMethods(filter(newLink.getInvocation(), WITHSCOPEFILTER),
  10.158 +            MH.guardWithTest(
  10.159 +                expressionGuard(name),
  10.160 +                filterGuard(newLink, WITHSCOPEFILTER),
  10.161 +                MH.dropArguments(MH.constant(boolean.class, false), 0, Object.class)));
  10.162      }
  10.163  
  10.164      private static MethodHandle filterGuard(final GuardedInvocation link, final MethodHandle filter) {
  10.165 @@ -279,7 +279,6 @@
  10.166          return ((WithObject)receiver).expression;
  10.167      }
  10.168  
  10.169 -
  10.170      @SuppressWarnings("unused")
  10.171      private static Object bindToExpression(final Object fn, final Object receiver) {
  10.172          return fn instanceof ScriptFunction ? bindToExpression((ScriptFunction) fn, receiver) : fn;
  10.173 @@ -289,6 +288,17 @@
  10.174          return fn.makeBoundFunction(withFilterExpression(receiver), new Object[0]);
  10.175      }
  10.176  
  10.177 +    private MethodHandle expressionGuard(final String name) {
  10.178 +        final PropertyMap map = expression.getMap();
  10.179 +        final SwitchPoint sp = map.getProtoGetSwitchPoint(expression.getProto(), name);
  10.180 +        return MH.insertArguments(WITHEXPRESSIONGUARD, 1, map, sp);
  10.181 +    }
  10.182 +
  10.183 +    @SuppressWarnings("unused")
  10.184 +    private static boolean withExpressionGuard(final Object receiver, final PropertyMap map, final SwitchPoint sp) {
  10.185 +        return ((WithObject)receiver).expression.getMap() == map && (sp == null || !sp.hasBeenInvalidated());
  10.186 +    }
  10.187 +
  10.188      /**
  10.189       * Drops the WithObject wrapper from the scope.
  10.190       * @param receiver WithObject wrapper.
  10.191 @@ -302,10 +312,14 @@
  10.192       * Get the with expression for this {@code WithObject}
  10.193       * @return the with expression
  10.194       */
  10.195 -    public Object getExpression() {
  10.196 +    public ScriptObject getExpression() {
  10.197          return expression;
  10.198      }
  10.199  
  10.200 +    public ScriptObject getParentScope() {
  10.201 +        return getProto();
  10.202 +    }
  10.203 +
  10.204      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
  10.205          return MH.findStatic(MethodHandles.lookup(), WithObject.class, name, MH.type(rtype, types));
  10.206      }
    11.1 --- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Fri Sep 06 14:20:58 2013 -0700
    11.2 +++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties	Mon Sep 09 20:16:49 2013 +0530
    11.3 @@ -110,6 +110,7 @@
    11.4  type.error.cannot.get.default.number=Cannot get default number value
    11.5  type.error.cant.apply.with.to.null=Cannot apply "with" to null
    11.6  type.error.cant.apply.with.to.undefined=Cannot apply "with" to undefined
    11.7 +type.error.cant.apply.with.to.non.scriptobject=Cannot apply "with" to non script object
    11.8  type.error.in.with.non.object=Right hand side of "in" cannot be non-Object, found {0}
    11.9  type.error.prototype.not.an.object="prototype" of {0} is not an Object, it is {1}
   11.10  type.error.cant.load.script=Cannot load script from {0}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/script/basic/8024180/global_var_delete.js	Mon Sep 09 20:16:49 2013 +0530
    12.3 @@ -0,0 +1,50 @@
    12.4 +/*
    12.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + * 
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + * 
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + * 
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + * 
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 +/**
   12.28 + * JDK-8024180: Incorrect handling of expression and parent scope in 'with' statements
   12.29 + *
   12.30 + * @test
   12.31 + * @run
   12.32 + */
   12.33 +
   12.34 +
   12.35 +this.x = 44;
   12.36 +
   12.37 +function func() {
   12.38 +    with({ }) {
   12.39 +        print(x);
   12.40 +    }
   12.41 +}
   12.42 +
   12.43 +func();
   12.44 +
   12.45 +// delete global 'x'
   12.46 +delete this.x;
   12.47 +
   12.48 +try {
   12.49 +    func();
   12.50 +} catch(e) {
   12.51 +    // expect ReferenceError
   12.52 +    print(e);
   12.53 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/script/basic/8024180/global_var_delete.js.EXPECTED	Mon Sep 09 20:16:49 2013 +0530
    13.3 @@ -0,0 +1,2 @@
    13.4 +44
    13.5 +ReferenceError: "x" is not defined
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/script/basic/8024180/global_var_shadow.js	Mon Sep 09 20:16:49 2013 +0530
    14.3 @@ -0,0 +1,45 @@
    14.4 +/*
    14.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + * 
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + * 
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + * 
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + * 
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +
   14.27 +/**
   14.28 + * JDK-8024180: Incorrect handling of expression and parent scope in 'with' statements
   14.29 + *
   14.30 + * @test
   14.31 + * @run
   14.32 + */
   14.33 +
   14.34 +// global variable is shadowed by with 'expression' property
   14.35 +var  user = { name: 'foo' };
   14.36 +
   14.37 +function func(locals) {
   14.38 +    with (locals) {
   14.39 +        print(user.name);
   14.40 +    }
   14.41 +}
   14.42 +
   14.43 +// global user.name 'foo' printed
   14.44 +func({});
   14.45 +
   14.46 +// local user.name 'toto' printed
   14.47 +func({ user: { name: 'toto' } });
   14.48 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/script/basic/8024180/global_var_shadow.js.EXPECTED	Mon Sep 09 20:16:49 2013 +0530
    15.3 @@ -0,0 +1,2 @@
    15.4 +foo
    15.5 +toto
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/script/basic/8024180/scope_no_such_prop.js	Mon Sep 09 20:16:49 2013 +0530
    16.3 @@ -0,0 +1,51 @@
    16.4 +/*
    16.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + * 
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + * 
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + * 
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + * 
   16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 + * or visit www.oracle.com if you need additional information or have any
   16.24 + * questions.
   16.25 + */
   16.26 +
   16.27 +/**
   16.28 + * JDK-8024180: Incorrect handling of expression and parent scope in 'with' statements
   16.29 + *
   16.30 + * @test
   16.31 + * @run
   16.32 + */
   16.33 +
   16.34 +// __noSuchProperty__ defined here confuses 'with'
   16.35 +// results in ReferenceError even when 'with' expression has
   16.36 +// the property
   16.37 +
   16.38 +load("nashorn:mozilla_compat.js")
   16.39 +
   16.40 +function func(locals) {
   16.41 +    with (locals) {
   16.42 +        print(user.name);
   16.43 +    }
   16.44 +}
   16.45 +
   16.46 +try {
   16.47 +    func({});
   16.48 +} catch (e) {
   16.49 +    print(e);
   16.50 +}
   16.51 +
   16.52 +// 'toto' expected in the call below
   16.53 +func({ user: { name: 'toto' } });
   16.54 +
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/script/basic/8024180/scope_no_such_prop.js.EXPECTED	Mon Sep 09 20:16:49 2013 +0530
    17.3 @@ -0,0 +1,2 @@
    17.4 +ReferenceError: user is not defined
    17.5 +toto
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/script/basic/8024180/with_expr_prop_add.js	Mon Sep 09 20:16:49 2013 +0530
    18.3 @@ -0,0 +1,47 @@
    18.4 +/*
    18.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + * 
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + * 
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + * 
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + * 
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +/**
   18.28 + * JDK-8024180: Incorrect handling of expression and parent scope in 'with' statements
   18.29 + *
   18.30 + * @test
   18.31 + * @run
   18.32 + */
   18.33 +
   18.34 +var obj = {};
   18.35 +var x = "global x";
   18.36 +
   18.37 +// adding property to 'with' xpression object should reflect
   18.38 +// as variable inside the 'with' block.
   18.39 +function func() {
   18.40 +    with(obj) {
   18.41 +        for (i = 0; i < 2; i++) {
   18.42 +            print(x);
   18.43 +            if (i == 0) {
   18.44 +                obj.x = "obj.x";
   18.45 +            }
   18.46 +        }
   18.47 +    }
   18.48 +}
   18.49 +
   18.50 +func();
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/script/basic/8024180/with_expr_prop_add.js.EXPECTED	Mon Sep 09 20:16:49 2013 +0530
    19.3 @@ -0,0 +1,2 @@
    19.4 +global x
    19.5 +obj.x
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/script/basic/8024180/with_expr_proto_prop_add.js	Mon Sep 09 20:16:49 2013 +0530
    20.3 @@ -0,0 +1,49 @@
    20.4 +/*
    20.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + * 
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + * 
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + * 
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + * 
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +/**
   20.28 + * JDK-8024180: Incorrect handling of expression and parent scope in 'with' statements
   20.29 + *
   20.30 + * @test
   20.31 + * @run
   20.32 + */
   20.33 +
   20.34 +var p =  { };
   20.35 +var obj = Object.create(p);
   20.36 +
   20.37 +var x = "global x";
   20.38 +
   20.39 +// adding property to __proto__ of 'with' expression should
   20.40 +// reflect as a variable immediately.
   20.41 +function func() {
   20.42 +    with(obj) {
   20.43 +        for (i = 0; i < 2; i++) {
   20.44 +            print(x);
   20.45 +            if (i == 0) {
   20.46 +                p.x = "p.x";
   20.47 +            }
   20.48 +        } 
   20.49 +    }
   20.50 +}
   20.51 +
   20.52 +func();
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/script/basic/8024180/with_expr_proto_prop_add.js.EXPECTED	Mon Sep 09 20:16:49 2013 +0530
    21.3 @@ -0,0 +1,2 @@
    21.4 +global x
    21.5 +p.x
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/script/basic/8024180/with_java_object.js	Mon Sep 09 20:16:49 2013 +0530
    22.3 @@ -0,0 +1,36 @@
    22.4 +/*
    22.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + * 
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + * 
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + * 
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + * 
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +/**
   22.28 + * JDK-8024180: Incorrect handling of expression and parent scope in 'with' statements
   22.29 + *
   22.30 + * @test
   22.31 + * @run
   22.32 + */
   22.33 +
   22.34 +// TypeError for with expression being non script object
   22.35 +try {
   22.36 +    with(new java.lang.Object()) {}
   22.37 +} catch (e) {
   22.38 +    print(e);
   22.39 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/script/basic/8024180/with_java_object.js.EXPECTED	Mon Sep 09 20:16:49 2013 +0530
    23.3 @@ -0,0 +1,1 @@
    23.4 +TypeError: Cannot apply "with" to non script object
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/script/basic/JDK-8024255.js	Mon Sep 09 20:16:49 2013 +0530
    24.3 @@ -0,0 +1,51 @@
    24.4 +/*
    24.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
    24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 + * 
    24.8 + * This code is free software; you can redistribute it and/or modify it
    24.9 + * under the terms of the GNU General Public License version 2 only, as
   24.10 + * published by the Free Software Foundation.
   24.11 + * 
   24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 + * version 2 for more details (a copy is included in the LICENSE file that
   24.16 + * accompanied this code).
   24.17 + * 
   24.18 + * You should have received a copy of the GNU General Public License version
   24.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 + * 
   24.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   24.23 + * or visit www.oracle.com if you need additional information or have any
   24.24 + * questions.
   24.25 + */
   24.26 +
   24.27 +/**
   24.28 + * JDK-8024255: When a keyword is used as object property name, the property can not be deleted
   24.29 + *
   24.30 + * @test
   24.31 + * @run
   24.32 + */
   24.33 +
   24.34 +function check(obj, name) {
   24.35 +    var desc = Object.getOwnPropertyDescriptor(obj, name);
   24.36 +    if (! desc.configurable) {
   24.37 +        fail("Property " + name + " is not configurable");
   24.38 +    }
   24.39 +
   24.40 +    if (! (delete obj[name])) {
   24.41 +        fail("Property " + name + " can not be deleted");
   24.42 +    }
   24.43 +}
   24.44 +
   24.45 +var obj = { 
   24.46 +    default: 344,
   24.47 +    in: 'hello', 
   24.48 +    if: false,
   24.49 +    class: 4.223
   24.50 +}
   24.51 +
   24.52 +for (var p in obj) {
   24.53 +    check(obj, p);
   24.54 +}
    25.1 --- a/test/src/jdk/nashorn/internal/runtime/ContextTest.java	Fri Sep 06 14:20:58 2013 -0700
    25.2 +++ b/test/src/jdk/nashorn/internal/runtime/ContextTest.java	Mon Sep 09 20:16:49 2013 +0530
    25.3 @@ -64,6 +64,7 @@
    25.4          final Options options = new Options("");
    25.5          final ErrorManager errors = new ErrorManager();
    25.6          final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
    25.7 +        final boolean strict = cx.getEnv()._strict;
    25.8          final ScriptObject oldGlobal = Context.getGlobal();
    25.9          Context.setGlobal(cx.createGlobal());
   25.10  
   25.11 @@ -95,7 +96,7 @@
   25.12              assertEquals(sobj.size(), 2);
   25.13  
   25.14              // add property
   25.15 -            sobj.put("zee", "hello");
   25.16 +            sobj.put("zee", "hello", strict);
   25.17              assertEquals(sobj.get("zee"), "hello");
   25.18              assertEquals(sobj.size(), 3);
   25.19  

mercurial