{ "id": "84154", "key": "TIMOB-6819", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-06-05T23:31:44.000+0000", "created": "2011-12-21T11:22:10.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "tbs-1.8.2" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-06-05T23:31:44.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h1. Problem\r\nWith V8, any constant that isn't a String or primitive doesn't seem to be accessible from JavaScript -- they come across as undefined.\r\n\r\nh2. Is Rhino Broken [in this way] Too?\r\nNope.\r\n\r\nh2. Reproduction\r\nCreate a module (where \"titanium\" is an alias to the titanium.py in your 1.8.0.1 folder):\r\n{quote}titanium create --type=module --name=booltest --id=ti.booltest --platform=android{quote}\r\n\r\nMy original test requires the following two file changes in the module. It tests for access to Boolean constants. See my comments down below for a more comprehensive, albiet less humorous, test.\r\n\r\nUpdate the module's source file to the following:\r\n{code:title=src/ti/booltest/BooltestModule.java}\r\npackage ti.booltest;\r\n\r\nimport org.appcelerator.kroll.KrollModule;\r\nimport org.appcelerator.kroll.annotations.Kroll;\r\n\r\nimport org.appcelerator.titanium.TiApplication;\r\n\r\n@Kroll.module(name=\"Booltest\", id=\"ti.booltest\")\r\npublic class BooltestModule extends KrollModule\r\n{\r\n @Kroll.constant public static final Boolean THE_SKY_IS_BLUE = true;\r\n\r\n public BooltestModule()\r\n {\r\n super();\r\n }\r\n}\r\n{code}\r\n\r\nUpdate the app.js to the following:\r\n{code:title=example/app.js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\nwin.add(Ti.UI.createLabel({\r\n text: 'Papa! Papa! Is the sky blue?\\n\\n'\r\n + (require('ti.booltest').THE_SKY_IS_BLUE ? 'Yes! Just like your eyes, son.' : 'No! And while we\\'re at it, Santa...')\r\n}));\r\nwin.open();\r\n{code}\r\n\r\nRun the code on your device. You should see confirmation that the sky is, indeed, blue (in the form of a gripping father-son narrative). If you see slander against Santa, than we still have a problem that needs to be fixed.", "attachment": [], "flagged": false, "summary": "Android: V8 Only Supports String and Primitive Constants", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": "version=1.8.0.1\r\nmodule_apiversion=2\r\ntimestamp=12/18/11 00:16\r\ngithash=22868a1\r\n\r\nTested on an Android EPIC 4G 2.2", "comment": { "comments": [ { "id": "176884", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "While we're at it, let's test all the available constants.\r\n\r\nh2. Expanded Results\r\nAll the following work on Rhino. But ONLY STRINGS work on V8.\r\n\r\n{code:title=src/ti/booltest/BooltestModule.java}\r\npackage ti.booltest;\r\n\r\nimport org.appcelerator.kroll.KrollModule;\r\nimport org.appcelerator.kroll.annotations.Kroll;\r\n\r\nimport org.appcelerator.titanium.TiApplication;\r\n\r\n@Kroll.module(name=\"Booltest\", id=\"ti.booltest\")\r\npublic class BooltestModule extends KrollModule\r\n{\r\n\t/*\r\n\t * This test marches through the various available types in Java\r\n\t * to see if they can be used as constants in a Titanium Mobile app.\r\n\t * \r\n\t * They follow the naming convention \"d\" + either \"w\" for the wrapped\r\n\t * form or \"p\" for the primitive form + the variable type.\r\n\t */\r\n\r\n\t@Kroll.constant public static final Boolean dbool = true;\r\n\t@Kroll.constant public static final Integer dint = 2;\r\n\t@Kroll.constant public static final Short dshort = 3;\r\n\t@Kroll.constant public static final Byte dbyte = 0x4;\r\n\t@Kroll.constant public static final Float dfloat = 5.5f;\r\n\t@Kroll.constant public static final Double ddouble = 6.6d;\r\n\t@Kroll.constant public static final Long dlong = 7l;\r\n\t@Kroll.constant public static final String dstr = \"So how 'bout them Bears?\";\r\n\t\r\n\tpublic BooltestModule()\r\n\t{\r\n\t\tsuper();\r\n\t}\r\n}\r\n{code}\r\n\r\n{code:title=example/app.js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff',\r\n layout: 'vertical'\r\n});\r\nvar constants = [\r\n 'dbool', 'dint', 'dshort', 'dbyte', 'dfloat', 'ddouble', 'dlong', 'dstr'\r\n];\r\nvar BoolTest = require('ti.booltest');\r\nfor (var c in constants) {\r\n win.add(Ti.UI.createLabel({\r\n text: BoolTest[constants[c]] || (constants[c] + ' FAILED!'),\r\n height: '12dp', top: '1dp'\r\n }));\r\n}\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-12-21T11:58:43.000+0000", "updated": "2011-12-21T11:58:58.000+0000" }, { "id": "176886", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Sorry for the misleading title. After further investigation, Rhino supports any sort of constants I throw at it.\r\n\r\nBut V8 does not support any wrapped type variable (like Boolean, Integer, Float) EXCEPT for String. The primitive forms work great (int, bool, short, etc).", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-12-21T12:04:49.000+0000", "updated": "2011-12-21T12:04:49.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }