JDK-8029003 : setField in ScriptObject is incorrect for non extensible objects
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-11-22
  • Updated: 2014-07-29
  • Resolved: 2014-01-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u20Fixed 9 b02Fixed
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

Comments
Fix pushed to nashorn/jdk9 forest: changeset: 687:d6e66fef38eb tag: tip user: sundar date: Tue Jan 07 18:14:18 2014 +0530 summary: 8029003: setField in ScriptObject is incorrect for non extensible objects
07-01-2014