Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029003

setField in ScriptObject is incorrect for non extensible objects

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • core-libs
    • None
    • b02
    • generic
    • generic

        It always throws a type errors, even if we are not in strict mode. the correct behaviour here according to spec is to be a nop. The spill setters do it right.

            @SuppressWarnings("unused")
            private static void setField(final CallSiteDescriptor desc, final PropertyMap oldMap, final PropertyMap newMap, final MethodHandle setter, final Object self, final Object value) throws Throwable {
                final ScriptObject obj = (ScriptObject)self;
                final boolean isStrict = NashornCallSiteDescriptor.isStrict(desc);
                if (!obj.isExtensible()) {
                    throw typeError("object.non.extensible", desc.getNameToken(2), ScriptRuntime.safeToString(obj));
                } else if (obj.compareAndSetMap(oldMap, newMap)) {
                    setter.invokeExact(self, value);
                } else {
                    obj.set(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND), value, isStrict);
                }
            }

        As this is so small, and we haven't gotten in trouble yet, I suggest postponing to 8u20

              sundar Sundararajan Athijegannathan
              lagergren Marcus Lagergren
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: