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

setField in ScriptObject is incorrect for non extensible objects

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b02
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        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

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: