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

Undefined properties return 'null' when looked up by a variable

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      For Java objects being used from JavaScript, accessing an undefined property using a variable returns 'null' whereas it should returned 'undefined'.

      jjs> var point = new java.awt.Point(2,3)
      jjs> point['x']
      2
      jjs> var propertyName = 'x'
      jjs> point[propertyName]
      2
      jjs> propertyName = 'foo'
      foo
      jjs> point[propertyName] === undefined
      false
      jjs> point[propertyName]
      null
      jjs> point['foo'] === undefined
      true
      jjs>

      JavaScript objects behave correctly.

      jjs> var point = {x:2, y:3}
      jjs> var propertyName = 'foo'
      jjs> point[propertyName] === undefined
      true
      jjs>


      REPRODUCIBILITY :
      This bug can be reproduced always.

            hannesw Hannes Wallnoefer
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: