{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/rhino/issues/271","repository_url":"https://api.github.com/repos/mozilla/rhino","labels_url":"https://api.github.com/repos/mozilla/rhino/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/rhino/issues/271/comments","events_url":"https://api.github.com/repos/mozilla/rhino/issues/271/events","html_url":"https://github.com/mozilla/rhino/issues/271","id":134345836,"number":271,"title":"potential ToBolean ecmascript spec error Rhino v1.7R3  bundled in rt.jar","user":{"login":"farzonl","id":1802579,"avatar_url":"https://avatars.githubusercontent.com/u/1802579?v=3","gravatar_id":"","url":"https://api.github.com/users/farzonl","html_url":"https://github.com/farzonl","followers_url":"https://api.github.com/users/farzonl/followers","following_url":"https://api.github.com/users/farzonl/following{/other_user}","gists_url":"https://api.github.com/users/farzonl/gists{/gist_id}","starred_url":"https://api.github.com/users/farzonl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/farzonl/subscriptions","organizations_url":"https://api.github.com/users/farzonl/orgs","repos_url":"https://api.github.com/users/farzonl/repos","events_url":"https://api.github.com/users/farzonl/events{/privacy}","received_events_url":"https://api.github.com/users/farzonl/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-17T17:25:34Z","updated_at":"2016-02-19T10:06:27Z","closed_at":"2016-02-17T20:26:34Z","body":"This does not look to be an issue in your master branch, i'm trying to track down  what is going wrong. Any help you all can provide would be amazing. The build server I am using has a JDK 7 instance I myself am using java 8. I believe this means I am using   Nashorn locally, hence the problem I am seeing on committing. It looks like the version in question is Mozilla Rhino v1.7R3 pre-release (http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html). I don't see a  1.7R3 branch on github but do see a 17R1 and a 17R2.\r\n\r\nthis is the offending code in one of the ant build files: sName is an empty string\r\n<![CDATA[\r\nif(sName)\r\n{\r\n...\r\n}\r\n]]>\r\n\r\naccording to the spec if conditions do the following\r\nif(toboolean(getvalue(\"\")))\r\nlooking as far back as ecmascript 3 the behavior of toBoolean on strings should be:\r\n\r\n\"The result is false if the argument is the empty string (its length is zero); otherwise\r\nthe result is true.\"\r\n\r\nwhich is exactly what you all do and Nashorn does, so I am really confused as to why my build machine  is evaluating this if statement as true. If you all have any insightful answers that would be awesome. as a work around I have changed this if statement to check for null and empty string explicitly, so this is not a blocking issue for me and I am not looking for a fix. I am just curious why I saw a build break in the first place."},"comment":{"url":"https://api.github.com/repos/mozilla/rhino/issues/comments/186147736","html_url":"https://github.com/mozilla/rhino/issues/271#issuecomment-186147736","issue_url":"https://api.github.com/repos/mozilla/rhino/issues/271","id":186147736,"user":{"login":"sainaen","id":2400185,"avatar_url":"https://avatars.githubusercontent.com/u/2400185?v=3","gravatar_id":"","url":"https://api.github.com/users/sainaen","html_url":"https://github.com/sainaen","followers_url":"https://api.github.com/users/sainaen/followers","following_url":"https://api.github.com/users/sainaen/following{/other_user}","gists_url":"https://api.github.com/users/sainaen/gists{/gist_id}","starred_url":"https://api.github.com/users/sainaen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sainaen/subscriptions","organizations_url":"https://api.github.com/users/sainaen/orgs","repos_url":"https://api.github.com/users/sainaen/repos","events_url":"https://api.github.com/users/sainaen/events{/privacy}","received_events_url":"https://api.github.com/users/sainaen/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T10:06:27Z","updated_at":"2016-02-19T10:06:27Z","body":"Well, `sName` *is* a String.\r\n\r\nIt's just that it is an instance of `java.lang.String` and [for Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java#Java_Strings_and_JavaScript_Strings) it's a different thing from JavaScript's `String`. Nashorn on the other hand [uses](http://hg.openjdk.java.net/jdk8/jdk8/nashorn/file/096dc407d310/src/jdk/nashorn/internal/runtime/JSType.java#l168) `java.lang.String` as JS `String` and provides expected JS behavior for them.\r\n\r\nSo this script:\r\n```js\r\nvar s = new java.lang.String(\"\");\r\nif (s) {\r\n  print(\"yep\");\r\n} else {\r\n  print(\"nope\");\r\n}\r\n```\r\nwill print \"yep\" when executed by Rhino, because `s` is a non-null reference to object, which is coerced to `true`, and \"nope\" in Nashorn, because there it's just an empty String, not object."}}