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

Objects with more than 256 keys cause all keys to become undefined

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u45
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin my-mbp 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      Nashorn is causing keys on an object to become undefined when an object with more than 256 keys and where the keys are themselves objects.

      e.g. objects of the form:
      var foo = {
          field_1: { code: 1 },
          field_2: { code: 2 },
          ...
          field_256: { code: 256 }
      }

      Where when enumerating up to field_257 in the same form will cause all fields foo.field_<i> to become undefined. When enumerating only up to field_256, all fields contain the expected value.

      The problem only occurs when the values are also objects, so objects of the form:

      var bar = {
          field_1: 1,
          field_2: 2,
          ...
          field_256: 256
      }

      appear to be unaffected.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Running:
      jjs map_256.js

      emits: foo, # of keys= 256 first field= [object Object]

      Running:
      jjs map_257.js

      emits: foo, # of keys= 257 first field= undefined

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect map_257.js to print:
      foo, # of keys= 257 first field= [object Object]

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      map_256.js:
      var foo = {
      field_1: { code: "1" },
      field_2: { code: "2" },
      field_3: { code: "3" },
      field_4: { code: "4" },
      field_5: { code: "5" },
      field_6: { code: "6" },
      field_7: { code: "7" },
      field_8: { code: "8" },
      field_9: { code: "9" },
      field_10: { code: "10" },
      field_11: { code: "11" },
      field_12: { code: "12" },
      field_13: { code: "13" },
      field_14: { code: "14" },
      field_15: { code: "15" },
      field_16: { code: "16" },
      field_17: { code: "17" },
      field_18: { code: "18" },
      field_19: { code: "19" },
      field_20: { code: "20" },
      field_21: { code: "21" },
      field_22: { code: "22" },
      field_23: { code: "23" },
      field_24: { code: "24" },
      field_25: { code: "25" },
      field_26: { code: "26" },
      field_27: { code: "27" },
      field_28: { code: "28" },
      field_29: { code: "29" },
      field_30: { code: "30" },
      field_31: { code: "31" },
      field_32: { code: "32" },
      field_33: { code: "33" },
      field_34: { code: "34" },
      field_35: { code: "35" },
      field_36: { code: "36" },
      field_37: { code: "37" },
      field_38: { code: "38" },
      field_39: { code: "39" },
      field_40: { code: "40" },
      field_41: { code: "41" },
      field_42: { code: "42" },
      field_43: { code: "43" },
      field_44: { code: "44" },
      field_45: { code: "45" },
      field_46: { code: "46" },
      field_47: { code: "47" },
      field_48: { code: "48" },
      field_49: { code: "49" },
      field_50: { code: "50" },
      field_51: { code: "51" },
      field_52: { code: "52" },
      field_53: { code: "53" },
      field_54: { code: "54" },
      field_55: { code: "55" },
      field_56: { code: "56" },
      field_57: { code: "57" },
      field_58: { code: "58" },
      field_59: { code: "59" },
      field_60: { code: "60" },
      field_61: { code: "61" },
      field_62: { code: "62" },
      field_63: { code: "63" },
      field_64: { code: "64" },
      field_65: { code: "65" },
      field_66: { code: "66" },
      field_67: { code: "67" },
      field_68: { code: "68" },
      field_69: { code: "69" },
      field_70: { code: "70" },
      field_71: { code: "71" },
      field_72: { code: "72" },
      field_73: { code: "73" },
      field_74: { code: "74" },
      field_75: { code: "75" },
      field_76: { code: "76" },
      field_77: { code: "77" },
      field_78: { code: "78" },
      field_79: { code: "79" },
      field_80: { code: "80" },
      field_81: { code: "81" },
      field_82: { code: "82" },
      field_83: { code: "83" },
      field_84: { code: "84" },
      field_85: { code: "85" },
      field_86: { code: "86" },
      field_87: { code: "87" },
      field_88: { code: "88" },
      field_89: { code: "89" },
      field_90: { code: "90" },
      field_91: { code: "91" },
      field_92: { code: "92" },
      field_93: { code: "93" },
      field_94: { code: "94" },
      field_95: { code: "95" },
      field_96: { code: "96" },
      field_97: { code: "97" },
      field_98: { code: "98" },
      field_99: { code: "99" },
      field_100: { code: "100" },
      field_101: { code: "101" },
      field_102: { code: "102" },
      field_103: { code: "103" },
      field_104: { code: "104" },
      field_105: { code: "105" },
      field_106: { code: "106" },
      field_107: { code: "107" },
      field_108: { code: "108" },
      field_109: { code: "109" },
      field_110: { code: "110" },
      field_111: { code: "111" },
      field_112: { code: "112" },
      field_113: { code: "113" },
      field_114: { code: "114" },
      field_115: { code: "115" },
      field_116: { code: "116" },
      field_117: { code: "117" },
      field_118: { code: "118" },
      field_119: { code: "119" },
      field_120: { code: "120" },
      field_121: { code: "121" },
      field_122: { code: "122" },
      field_123: { code: "123" },
      field_124: { code: "124" },
      field_125: { code: "125" },
      field_126: { code: "126" },
      field_127: { code: "127" },
      field_128: { code: "128" },
      field_129: { code: "129" },
      field_130: { code: "130" },
      field_131: { code: "131" },
      field_132: { code: "132" },
      field_133: { code: "133" },
      field_134: { code: "134" },
      field_135: { code: "135" },
      field_136: { code: "136" },
      field_137: { code: "137" },
      field_138: { code: "138" },
      field_139: { code: "139" },
      field_140: { code: "140" },
      field_141: { code: "141" },
      field_142: { code: "142" },
      field_143: { code: "143" },
      field_144: { code: "144" },
      field_145: { code: "145" },
      field_146: { code: "146" },
      field_147: { code: "147" },
      field_148: { code: "148" },
      field_149: { code: "149" },
      field_150: { code: "150" },
      field_151: { code: "151" },
      field_152: { code: "152" },
      field_153: { code: "153" },
      field_154: { code: "154" },
      field_155: { code: "155" },
      field_156: { code: "156" },
      field_157: { code: "157" },
      field_158: { code: "158" },
      field_159: { code: "159" },
      field_160: { code: "160" },
      field_161: { code: "161" },
      field_162: { code: "162" },
      field_163: { code: "163" },
      field_164: { code: "164" },
      field_165: { code: "165" },
      field_166: { code: "166" },
      field_167: { code: "167" },
      field_168: { code: "168" },
      field_169: { code: "169" },
      field_170: { code: "170" },
      field_171: { code: "171" },
      field_172: { code: "172" },
      field_173: { code: "173" },
      field_174: { code: "174" },
      field_175: { code: "175" },
      field_176: { code: "176" },
      field_177: { code: "177" },
      field_178: { code: "178" },
      field_179: { code: "179" },
      field_180: { code: "180" },
      field_181: { code: "181" },
      field_182: { code: "182" },
      field_183: { code: "183" },
      field_184: { code: "184" },
      field_185: { code: "185" },
      field_186: { code: "186" },
      field_187: { code: "187" },
      field_188: { code: "188" },
      field_189: { code: "189" },
      field_190: { code: "190" },
      field_191: { code: "191" },
      field_192: { code: "192" },
      field_193: { code: "193" },
      field_194: { code: "194" },
      field_195: { code: "195" },
      field_196: { code: "196" },
      field_197: { code: "197" },
      field_198: { code: "198" },
      field_199: { code: "199" },
      field_200: { code: "200" },
      field_201: { code: "201" },
      field_202: { code: "202" },
      field_203: { code: "203" },
      field_204: { code: "204" },
      field_205: { code: "205" },
      field_206: { code: "206" },
      field_207: { code: "207" },
      field_208: { code: "208" },
      field_209: { code: "209" },
      field_210: { code: "210" },
      field_211: { code: "211" },
      field_212: { code: "212" },
      field_213: { code: "213" },
      field_214: { code: "214" },
      field_215: { code: "215" },
      field_216: { code: "216" },
      field_217: { code: "217" },
      field_218: { code: "218" },
      field_219: { code: "219" },
      field_220: { code: "220" },
      field_221: { code: "221" },
      field_222: { code: "222" },
      field_223: { code: "223" },
      field_224: { code: "224" },
      field_225: { code: "225" },
      field_226: { code: "226" },
      field_227: { code: "227" },
      field_228: { code: "228" },
      field_229: { code: "229" },
      field_230: { code: "230" },
      field_231: { code: "231" },
      field_232: { code: "232" },
      field_233: { code: "233" },
      field_234: { code: "234" },
      field_235: { code: "235" },
      field_236: { code: "236" },
      field_237: { code: "237" },
      field_238: { code: "238" },
      field_239: { code: "239" },
      field_240: { code: "240" },
      field_241: { code: "241" },
      field_242: { code: "242" },
      field_243: { code: "243" },
      field_244: { code: "244" },
      field_245: { code: "245" },
      field_246: { code: "246" },
      field_247: { code: "247" },
      field_248: { code: "248" },
      field_249: { code: "249" },
      field_250: { code: "250" },
      field_251: { code: "251" },
      field_252: { code: "252" },
      field_253: { code: "253" },
      field_254: { code: "254" },
      field_255: { code: "255" },
      field_256: { code: "256" }
      };

      print("foo, # of keys=", Object.keys(foo).length, "first field=", foo.field_1);

      ===================================
      map_257.js
      var foo = {
      field_1: { code: "1" },
      field_2: { code: "2" },
      field_3: { code: "3" },
      field_4: { code: "4" },
      field_5: { code: "5" },
      field_6: { code: "6" },
      field_7: { code: "7" },
      field_8: { code: "8" },
      field_9: { code: "9" },
      field_10: { code: "10" },
      field_11: { code: "11" },
      field_12: { code: "12" },
      field_13: { code: "13" },
      field_14: { code: "14" },
      field_15: { code: "15" },
      field_16: { code: "16" },
      field_17: { code: "17" },
      field_18: { code: "18" },
      field_19: { code: "19" },
      field_20: { code: "20" },
      field_21: { code: "21" },
      field_22: { code: "22" },
      field_23: { code: "23" },
      field_24: { code: "24" },
      field_25: { code: "25" },
      field_26: { code: "26" },
      field_27: { code: "27" },
      field_28: { code: "28" },
      field_29: { code: "29" },
      field_30: { code: "30" },
      field_31: { code: "31" },
      field_32: { code: "32" },
      field_33: { code: "33" },
      field_34: { code: "34" },
      field_35: { code: "35" },
      field_36: { code: "36" },
      field_37: { code: "37" },
      field_38: { code: "38" },
      field_39: { code: "39" },
      field_40: { code: "40" },
      field_41: { code: "41" },
      field_42: { code: "42" },
      field_43: { code: "43" },
      field_44: { code: "44" },
      field_45: { code: "45" },
      field_46: { code: "46" },
      field_47: { code: "47" },
      field_48: { code: "48" },
      field_49: { code: "49" },
      field_50: { code: "50" },
      field_51: { code: "51" },
      field_52: { code: "52" },
      field_53: { code: "53" },
      field_54: { code: "54" },
      field_55: { code: "55" },
      field_56: { code: "56" },
      field_57: { code: "57" },
      field_58: { code: "58" },
      field_59: { code: "59" },
      field_60: { code: "60" },
      field_61: { code: "61" },
      field_62: { code: "62" },
      field_63: { code: "63" },
      field_64: { code: "64" },
      field_65: { code: "65" },
      field_66: { code: "66" },
      field_67: { code: "67" },
      field_68: { code: "68" },
      field_69: { code: "69" },
      field_70: { code: "70" },
      field_71: { code: "71" },
      field_72: { code: "72" },
      field_73: { code: "73" },
      field_74: { code: "74" },
      field_75: { code: "75" },
      field_76: { code: "76" },
      field_77: { code: "77" },
      field_78: { code: "78" },
      field_79: { code: "79" },
      field_80: { code: "80" },
      field_81: { code: "81" },
      field_82: { code: "82" },
      field_83: { code: "83" },
      field_84: { code: "84" },
      field_85: { code: "85" },
      field_86: { code: "86" },
      field_87: { code: "87" },
      field_88: { code: "88" },
      field_89: { code: "89" },
      field_90: { code: "90" },
      field_91: { code: "91" },
      field_92: { code: "92" },
      field_93: { code: "93" },
      field_94: { code: "94" },
      field_95: { code: "95" },
      field_96: { code: "96" },
      field_97: { code: "97" },
      field_98: { code: "98" },
      field_99: { code: "99" },
      field_100: { code: "100" },
      field_101: { code: "101" },
      field_102: { code: "102" },
      field_103: { code: "103" },
      field_104: { code: "104" },
      field_105: { code: "105" },
      field_106: { code: "106" },
      field_107: { code: "107" },
      field_108: { code: "108" },
      field_109: { code: "109" },
      field_110: { code: "110" },
      field_111: { code: "111" },
      field_112: { code: "112" },
      field_113: { code: "113" },
      field_114: { code: "114" },
      field_115: { code: "115" },
      field_116: { code: "116" },
      field_117: { code: "117" },
      field_118: { code: "118" },
      field_119: { code: "119" },
      field_120: { code: "120" },
      field_121: { code: "121" },
      field_122: { code: "122" },
      field_123: { code: "123" },
      field_124: { code: "124" },
      field_125: { code: "125" },
      field_126: { code: "126" },
      field_127: { code: "127" },
      field_128: { code: "128" },
      field_129: { code: "129" },
      field_130: { code: "130" },
      field_131: { code: "131" },
      field_132: { code: "132" },
      field_133: { code: "133" },
      field_134: { code: "134" },
      field_135: { code: "135" },
      field_136: { code: "136" },
      field_137: { code: "137" },
      field_138: { code: "138" },
      field_139: { code: "139" },
      field_140: { code: "140" },
      field_141: { code: "141" },
      field_142: { code: "142" },
      field_143: { code: "143" },
      field_144: { code: "144" },
      field_145: { code: "145" },
      field_146: { code: "146" },
      field_147: { code: "147" },
      field_148: { code: "148" },
      field_149: { code: "149" },
      field_150: { code: "150" },
      field_151: { code: "151" },
      field_152: { code: "152" },
      field_153: { code: "153" },
      field_154: { code: "154" },
      field_155: { code: "155" },
      field_156: { code: "156" },
      field_157: { code: "157" },
      field_158: { code: "158" },
      field_159: { code: "159" },
      field_160: { code: "160" },
      field_161: { code: "161" },
      field_162: { code: "162" },
      field_163: { code: "163" },
      field_164: { code: "164" },
      field_165: { code: "165" },
      field_166: { code: "166" },
      field_167: { code: "167" },
      field_168: { code: "168" },
      field_169: { code: "169" },
      field_170: { code: "170" },
      field_171: { code: "171" },
      field_172: { code: "172" },
      field_173: { code: "173" },
      field_174: { code: "174" },
      field_175: { code: "175" },
      field_176: { code: "176" },
      field_177: { code: "177" },
      field_178: { code: "178" },
      field_179: { code: "179" },
      field_180: { code: "180" },
      field_181: { code: "181" },
      field_182: { code: "182" },
      field_183: { code: "183" },
      field_184: { code: "184" },
      field_185: { code: "185" },
      field_186: { code: "186" },
      field_187: { code: "187" },
      field_188: { code: "188" },
      field_189: { code: "189" },
      field_190: { code: "190" },
      field_191: { code: "191" },
      field_192: { code: "192" },
      field_193: { code: "193" },
      field_194: { code: "194" },
      field_195: { code: "195" },
      field_196: { code: "196" },
      field_197: { code: "197" },
      field_198: { code: "198" },
      field_199: { code: "199" },
      field_200: { code: "200" },
      field_201: { code: "201" },
      field_202: { code: "202" },
      field_203: { code: "203" },
      field_204: { code: "204" },
      field_205: { code: "205" },
      field_206: { code: "206" },
      field_207: { code: "207" },
      field_208: { code: "208" },
      field_209: { code: "209" },
      field_210: { code: "210" },
      field_211: { code: "211" },
      field_212: { code: "212" },
      field_213: { code: "213" },
      field_214: { code: "214" },
      field_215: { code: "215" },
      field_216: { code: "216" },
      field_217: { code: "217" },
      field_218: { code: "218" },
      field_219: { code: "219" },
      field_220: { code: "220" },
      field_221: { code: "221" },
      field_222: { code: "222" },
      field_223: { code: "223" },
      field_224: { code: "224" },
      field_225: { code: "225" },
      field_226: { code: "226" },
      field_227: { code: "227" },
      field_228: { code: "228" },
      field_229: { code: "229" },
      field_230: { code: "230" },
      field_231: { code: "231" },
      field_232: { code: "232" },
      field_233: { code: "233" },
      field_234: { code: "234" },
      field_235: { code: "235" },
      field_236: { code: "236" },
      field_237: { code: "237" },
      field_238: { code: "238" },
      field_239: { code: "239" },
      field_240: { code: "240" },
      field_241: { code: "241" },
      field_242: { code: "242" },
      field_243: { code: "243" },
      field_244: { code: "244" },
      field_245: { code: "245" },
      field_246: { code: "246" },
      field_247: { code: "247" },
      field_248: { code: "248" },
      field_249: { code: "249" },
      field_250: { code: "250" },
      field_251: { code: "251" },
      field_252: { code: "252" },
      field_253: { code: "253" },
      field_254: { code: "254" },
      field_255: { code: "255" },
      field_256: { code: "256" },
      field_257: { code: "257" }
      };

      print("foo, # of keys=", Object.keys(foo).length, "first field=", foo.field_1);

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known.

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: