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

__noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b136
    • CPU:
      generic
    • OS:
      generic

      Description

      While the test runs fine in its entirety in both configurations, a subsection of it that I whittled down to reproduce another bug does not.

      Consider the script (attached as 'nosuch.js')

      function invokeMegamorphic() {
          var o = {};
          var s = String.fromCharCode(97);
          o[s] = 1;
          try {
      print(Debug.map(o));
      o._();
          } catch (e) {
      print(e);
          }
      }

      Object.prototype.__noSuchProperty__ = function() {
          print("no such property", Array.prototype.slice.call(arguments));
      };
      invokeMegamorphic();

      Object.prototype.__noSuchMethod__ = function() {
          print("no such method", Array.prototype.slice.call(arguments));
      };

      invokeMegamorphic();

      Running it in the default 9 configuration (with -Dnashorn.debug enabled) produces this output:

      0x3972a855 = {
      ['a'@0x62e7f11d (writable enumerable configurable) Accessor type=i slot=0]
      }
      no such property _
      TypeError: Cannot call undefined
      0x101952da = {
      ['a'@0x6babf3bf (writable enumerable configurable) Accessor type=i slot=0]
      }
      no such method _


      ... but turning off ot for the same build (running with --optimistic-types=false -Dnashorn.debug) produces

      0x424e1977 = {
      ['a'@0x10d68fcd (writable enumerable configurable) Accessor type=i slot=0]
      }
      no such property _
      TypeError: Cannot call undefined
      0x424e1977 = {
      ['a'@0x10d68fcd (writable enumerable configurable) Accessor type=i slot=0]
      }
      no such property _
      TypeError: Cannot call undefined


      The default configuration in 9 is optimistic types enabled. Not that with ot false, we get the same no such property printout twice, instead of the second one being a nosuchmethod. As far as I can tell, the latter is the correct behavior.

        Attachments

        1. nosuch.js
          0.6 kB
        2. ot_disabled.txt
          0.3 kB
        3. ot_enabled_diff_against_ot_disabled.txt
          0.5 kB
        4. ot_enabled.txt
          0.2 kB

          Issue Links

            Activity

              People

              • Assignee:
                hannesw Hannes Wallnoefer
                Reporter:
                lagergren Marcus Lagergren
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: