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

When script implements a Java interface, return value needs to be converted to closest Java type

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b61
    • CPU:
      generic
    • OS:
      generic

      Description

      By JavaAdapter feature, JavaScript can implement Java interface. When script implements a Java interface, return value needs to be converted to closest Java type. For eg. if script implements java.util.Comparator interface, then the return value of compare function should be converted to int.

      // a Comparator implementation that uses length comparison
      var x = new java.util.Comparator() {
          compare: function(o1, o2) {
             return o1.length - o2.length;
          }
      }

      In the above case, return value of compare method is int. So, script function's return value (of type java.lang.Double -- type used for all JavaScript numbers) should be converted to Java int (i.e., java.lang.Integer - the closest primitive wrapper type).

        Attachments

          Activity

            People

            Assignee:
            sundar Sundararajan Athijegannathan
            Reporter:
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: