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

in operator should work on java objects and classes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8, 9
    • core-libs
    • None
    • b155
    • generic
    • generic

        Java objects behave much like JS objects in Nashorn in that JavaBean properties can be accessed and methods invoked just like JS properties and functions. However, the "in" operator[1] is not supported by Java objects and always evaluates to false.

        [1] http://es5.github.io/#x11.8.7

        I stumbled over this when investigating a problem running mustache.js with Nashorn reported on nashorn-dev:

        http://mail.openjdk.java.net/pipermail/nashorn-dev/2017-January/006810.html

        Since we treat java properties and methods like JS properties and functions, it seems we should also support the in operator. This would include the following:

         - instance properties and methods on java objects
         - static properties and methods on java classes
         - map keys on instances of java.util.Map
         - indices for instances of java.util.List and arrays

              hannesw Hannes Wallnoefer
              hannesw Hannes Wallnoefer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: