Thanks! On Thu, Sep 29, 2016 at 5:40 AM, Hannes Wallnöfer < hannes.wallnoe...@oracle.com> wrote:
> Thanks for the report, Vivin, > > I’ve filed a bug and am looking into this. > > https://bugs.openjdk.java.net/browse/JDK-8166902 > > Hannes > > > Am 27.09.2016 um 19:08 schrieb Vivin Suresh Paliath < > vivin.pali...@gmail.com>: > > > > This is on JDK 8u102. We're seeing strange behavior where certain certain > > properties on objects get set to zero. Here's the script: > > > > var config = {}; > > > > var creativeDetails = { > > fanpage_id: config.fanpage_id || "293867224112667", > > image_url: config.image_url || "http://some.url", > > title: config.title || "Ad Title", > > description: config.description || "Ad Description", > > link_description: config.link_description || "Link Description", > > call_to_action: config.call_to_action || "LEARN_MORE", > > destination_url: "http:/some.url", > > link_body: config.link_body || "Link Body" > > }; > > > > var linkData = { > > call_to_action: { > > type: creativeDetails.call_to_action, > > value:{ > > link_caption: creativeDetails.link_description, > > link: creativeDetails.destination_url > > } > > }, > > link: creativeDetails.destination_url, > > picture: creativeDetails.image_url, > > message: creativeDetails.description, > > name: creativeDetails.title > > }; > > > > print(JSON.stringify(linkData, null, 4) + "\n"); > > > > Running this with jjs without any arguments gives: > > > > { > > "call_to_action": { > > "type": "LEARN_MORE", > > "value": { > > "link_caption": "Link Description", > > "link": "https://hosted-form-service.sbsp.io/" > > } > > }, > > "link": "https://hosted-form-service.sbsp.io/", > > "picture": " > > http://res.cloudinary.com/infusionsoft/image/upload/v1474490027/1913264_ > 293881764111213_2626449405773452232_o_gxgeoe.png > > ", > > "message": "Ad Description", > > "name": "Ad Title" > > } > > > > Whereas running it with jjs --optimistic-types=true gives: > > > > { > > "call_to_action": { > > "type": "LEARN_MORE", > > "value": { > > "link_caption": "Link Description", > > "link": "https://hosted-form-service.sbsp.io/" > > } > > }, > > "link": 0, > > "picture": 0, > > "message": 0, > > "name": 0 > > } > > > > Changing the || expressions to ternaries didn't change the behavior. > > However, referencing a property of the creativeDetails object in any > manner > > (e.g., assigning it to another variable or printing it out) before > > initializing the linkData object, ends up printing out the expected > result. > > > > The strange thing is that the nested object gets the right values, but > the > > outer object does not. This behavior only shows up if you are using the > > problematic object's properties to initialize the properties of a nested > > object. For example, the following code does not cause the issue: > > > > var linkData = { > > link: creativeDetails.destination_url, > > picture: creativeDetails.image_url, > > message: creativeDetails.description, > > name: creativeDetails.title > > }; > > > > > > -- > > *[vivin.net <http://vivin.net> :: github <http://github.com/vivin> :: > > linkedin <https://www.linkedin.com/in/vivin>]* > > -- *[vivin.net <http://vivin.net> :: github <http://github.com/vivin> :: linkedin <https://www.linkedin.com/in/vivin>]*