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

Add a REMOVE value to jdk.dynalink.StandardOperation enum

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • None
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      As with adding a new value to any enum: code explicitly acting on previously existing enum values with the assumption it is comprehensively covering them (e.g. using negative selection criteria for a condition and presuming there are no other values than those filtered out) now runs the risk of missing the fact there's now a new value.
      Show
      As with adding a new value to any enum: code explicitly acting on previously existing enum values with the assumption it is comprehensively covering them (e.g. using negative selection criteria for a condition and presuming there are no other values than those filtered out) now runs the risk of missing the fact there's now a new value.
    • Java API
    • JDK

    Description

      Summary

      Add a new enum value REMOVE to jdk.dynalink.StandardOperation to represent removal of a named value from an object's namespace.

      Problem

      Language implementers have observed that Dynalink does not provide an operation for deleting a property of an object, or a member of a collection, something fairly common in dynamic languages (and distinct from, say, setting a property value to null). Their request to provide REMOVE as a standard operation is quite justified. If Dynalink defined a REMOVE operation, Nashorn's implementation of JavaScript delete operator would eventually also get reimplemented on top of it.

      Solution

      Add a new enum value REMOVE to jdk.dynalink.StandardOperation.

      Additionally, JavaDoc for jdk.dynalink.beans.BeansLinker class will be updated to describe it is providing default removal behavior for elements of Java Lists and Maps (removal by list index and by map key, respectively). BeansLinker provides common-sense default implementation for all standard operations on Java objects as a fallback when no other language linker provides them, so now it should provide such implementation for REMOVE as well. Since it is not possible to remove properties or methods from a POJO nor elements from an array, the only common-sense default behavior for a REMOVE operations are abovementioned removal of elements from List and Map.

      Specification

      See the newest attached webrev ZIP file. NB: not submitted as part of the specification is the actual implementation of removal operations provided by BeansLinker, as they have no publicly visible artifacts except mentioning their existence in the JavaDoc.

      Attachments

        Issue Links

          Activity

            People

              attila Attila Szegedi
              attila Attila Szegedi
              Hannes Wallnoefer, Sundararajan Athijegannathan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: