{ "id": "84388", "key": "TIMOB-7006", "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": "2012-01-05T14:14:35.000+0000", "created": "2011-12-30T10:40:16.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "look1" ], "versions": [ { "id": "12570", "name": "Release 1.7.5", "archived": true, "released": true, "releaseDate": "2011-11-02" } ], "issuelinks": [ { "id": "14449", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "84498", "key": "TIDOC-14", "fields": { "summary": "APIDoc: App - rewrite plus document Properties permitted range of setInt", "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" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updated": "2017-03-21T21:09:26.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": "h2. Problem\r\n\r\nThe largest integer that can be saved without causing an exception is 2147483647, which is (2^31)-1.\r\n\r\nNote that large numbers can be successfully saved on:\r\n* iOS (according to reporter)\r\n* Android + Titanium 1.8.0.1 + v8\r\n* Android + Titanium 1.8.0.1 + rhino\r\n\r\nh2. Test case\r\n\r\n{code:lang=javascript|title=app.js}\r\nTi.App.Properties.setInt(\"lowInt\", 2147483647);\r\nTi.API.info(\"****** lowInt Saved ******\");\r\nTi.App.Properties.setInt(\"highInt\", 2147483648);\r\nTi.API.info(\"****** highInt Saved ******\");\r\nTi.App.Properties.setInt(\"veryHighInt\", 1325269931753);\r\nTi.API.info(\"****** veryHighInt Saved ******\");\r\n{code}\r\n\r\nh2. Logs\r\n\r\n{code:lang=none}\r\n 332 KrollContext D (kroll$1: app://app.js) [184,376] Running evaluated script: file:///android_asset/Resources/app.js\r\n 332 TiAPI I (kroll$1: app://app.js) [64,440] ****** lowInt Saved ******\r\n 332 TiJSError E (kroll$1: app://app.js) [217,657] ----- Titanium Javascript Runtime Error -----\r\n 332 TiJSError E (kroll$1: app://app.js) [1,658] - In file:///android_asset/Resources/app.js:110,0\r\n 332 TiJSError E (kroll$1: app://app.js) [3,661] - Message: Cannot convert 2147483648 to java.lang.Integer\r\n 332 TiJSError E (kroll$1: app://app.js) [1,662] - Source: null\r\n 332 KrollMethod E (kroll$1: app://app.js) [400,1062] Exception calling kroll method setInt, invocation: null ]\r\n 332 KrollMethod E org.mozilla.javascript.EvaluatorException: Cannot convert 2147483648 to java.lang.Integer (file:///andro\r\n id_asset/Resources/app.js#110)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.TiContext.runtimeError(TiContext.java:304)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Context.reportRuntimeError(Context.java:946)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Context.reportRuntimeError(Context.java:1001)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Context.reportRuntimeError2(Context.java:971)\r\n 332 KrollMethod E \tat org.mozilla.javascript.NativeJavaObject.reportConversionError(NativeJavaObject.java:896)\r\n 332 KrollMethod E \tat org.mozilla.javascript.NativeJavaObject.toInteger(NativeJavaObject.java:887)\r\n 332 KrollMethod E \tat org.mozilla.javascript.NativeJavaObject.coerceToNumber(NativeJavaObject.java:766)\r\n 332 KrollMethod E \tat org.mozilla.javascript.NativeJavaObject.coerceTypeImpl(NativeJavaObject.java:553)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Context.jsToJava(Context.java:1729)\r\n 332 KrollMethod E \tat org.appcelerator.kroll.KrollConverter.convertJavascript(KrollConverter.java:329)\r\n 332 KrollMethod E \tat ti.modules.titanium.app.properties.PropertiesModuleBindingGen$11.invoke(PropertiesModuleBindingGen.j\r\n ava:563)\r\n 332 KrollMethod E \tat org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)\r\n 332 KrollMethod E \tat script(file:///android_asset/Resources/app.js:110)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\r\n 332 KrollMethod E \tat org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\r\n 332 KrollMethod E \tat org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\r\n 332 KrollMethod E \tat org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177)\r\n 332 KrollMethod E \tat org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)\r\n 332 KrollMethod E \tat org.mozilla.javascript.Context.evaluateReader(Context.java:1142)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:106)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:353)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:382)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:218)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223)\r\n 332 KrollMethod E \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n 332 KrollMethod E \tat android.os.Looper.loop(Looper.java:123)\r\n 332 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)\r\n 332 KrollContext E (kroll$1: app://app.js) [15,1077] Error evaluating source: Cannot convert 2147483648 to java.lang.Intege\r\n r (file:///android_asset/Resources/app.js#110)\r\n 332 KrollContext E org.mozilla.javascript.EvaluatorException: Cannot convert 2147483648 to java.lang.Integer (file:///andro\r\n id_asset/Resources/app.js#110)\r\n 332 KrollContext E \tat org.appcelerator.titanium.TiContext.runtimeError(TiContext.java:304)\r\n 332 KrollContext E \tat org.mozilla.javascript.Context.reportRuntimeError(Context.java:946)\r\n 332 KrollContext E \tat org.mozilla.javascript.Context.reportRuntimeError(Context.java:1001)\r\n 332 KrollContext E \tat org.mozilla.javascript.Context.reportRuntimeError2(Context.java:971)\r\n 332 KrollContext E \tat org.mozilla.javascript.NativeJavaObject.reportConversionError(NativeJavaObject.java:896)\r\n 332 KrollContext E \tat org.mozilla.javascript.NativeJavaObject.toInteger(NativeJavaObject.java:887)\r\n 332 KrollContext E \tat org.mozilla.javascript.NativeJavaObject.coerceToNumber(NativeJavaObject.java:766)\r\n 332 KrollContext E \tat org.mozilla.javascript.NativeJavaObject.coerceTypeImpl(NativeJavaObject.java:553)\r\n 332 KrollContext E \tat org.mozilla.javascript.Context.jsToJava(Context.java:1729)\r\n 332 KrollContext E \tat org.appcelerator.kroll.KrollConverter.convertJavascript(KrollConverter.java:329)\r\n 332 KrollContext E \tat ti.modules.titanium.app.properties.PropertiesModuleBindingGen$11.invoke(PropertiesModuleBindingGen.j\r\n ava:563)\r\n 332 KrollContext E \tat org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)\r\n 332 KrollContext E \tat org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)\r\n 332 KrollContext E \tat script(file:///android_asset/Resources/app.js:110)\r\n 332 KrollContext E \tat org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\r\n 332 KrollContext E \tat org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\r\n 332 KrollContext E \tat org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\r\n 332 KrollContext E \tat org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177)\r\n 332 KrollContext E \tat org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)\r\n 332 KrollContext E \tat org.mozilla.javascript.Context.evaluateReader(Context.java:1142)\r\n 332 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:106)\r\n 332 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:353)\r\n 332 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:382)\r\n 332 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:218)\r\n 332 KrollContext E \tat org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223)\r\n 332 KrollContext E \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n 332 KrollContext E \tat android.os.Looper.loop(Looper.java:123)\r\n 332 KrollContext E \tat org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)\r\n 332 TiJSError E (kroll$1: app://app.js) [9,1086] ----- Titanium Javascript Runtime Error -----\r\n 332 TiJSError E (kroll$1: app://app.js) [5,1091] - In file:///android_asset/Resources/app.js:110,0\r\n 332 TiJSError E (kroll$1: app://app.js) [0,1091] - Message: Cannot convert 2147483648 to java.lang.Integer (file:///andr\r\n oid_asset/Resources/app.js#110)\r\n 332 TiJSError E (kroll$1: app://app.js) [1,1092] - Source: null\r\n 332 TiRootActivity I (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44f20810\r\n{code}\r\n\r\nh2. Workaround\r\n\r\nUse {{Ti.App.Properties.\\[g|s\\]etDouble()}}:\r\n\r\n{code:lang=javascript|title=app.js}\r\nTi.App.Properties.setDouble(\"veryHighInt\", 1325269931753);\r\nTi.API.info(\"****** veryHighInt Saved ******\");\r\nTi.App.Properties.setDouble(\"veryHighIntPlusOneThousand\", Ti.App.Properties.getDouble(\"veryHighInt\") + 1000);\r\nTi.API.info(\"****** veryHighIntPlusOneThousand Saved ******\");\r\nTi.API.info(\"----> veryHighIntPlusOneThousand = \" + Ti.App.Properties.getDouble(\"veryHighIntPlusOneThousand\"));\r\n{code}\r\n\r\n{code:lang=javascript|title=output}\r\n 576 KrollContext D (kroll$1: app://app.js) [46,701] Running evaluated script: file:///android_asset/Resources/app.js\r\n 576 TiAPI I (kroll$1: app://app.js) [38,739] ****** veryHighInt Saved ******\r\n 576 TiAPI I (kroll$1: app://app.js) [11,750] ****** veryHighIntPlusOneThousand Saved ******\r\n 576 TiAPI I (kroll$1: app://app.js) [3,753] ----> veryHighIntPlusOneThousand = 1325269932753\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: App.Properties - storing integer larger than 2147483647 causes exception", "creator": { "name": "ziggythehamster", "key": "ziggythehamster", "displayName": "Keith Gable", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "ziggythehamster", "key": "ziggythehamster", "displayName": "Keith Gable", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "* Titanium 1.7.5 (official release)\r\n* Tested on: Samsung Infuse 4G (Android 2.3.3)\r\n* Android: 2.1, 2.2, 2.3\r\n* JS Engine: Rhino\r\n* Studio 1.0.6.201110251616\r\n* OSX 10.6.8", "comment": { "comments": [ { "id": "177718", "author": { "name": "ziggythehamster", "key": "ziggythehamster", "displayName": "Keith Gable", "active": true, "timeZone": "America/Los_Angeles" }, "body": "A possible workaround is to divide getTime() by 1000 to get the number of seconds, and then use parseInt() to remove the floating point portion. Then you lose millisecond precision, though.\r\n\r\n{code}\r\nTi.App.Properties.setInt(\"my_key_here\", parseInt(instance_of_date.getTime() / 1000));\r\n{code}\r\n\r\nSo maybe this issue is that Java ints aren't big enough but Objective C ints are. Obviously this implementation difference should never be an issue in JavaScript.", "updateAuthor": { "name": "ziggythehamster", "key": "ziggythehamster", "displayName": "Keith Gable", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-30T12:22:22.000+0000", "updated": "2011-12-30T12:22:22.000+0000" }, { "id": "177721", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "For the reasons explained in TC-524, would you please edit the ticket to includes a test case that produces the included error? \r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-30T12:40:57.000+0000", "updated": "2011-12-30T12:40:57.000+0000" }, { "id": "177722", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Keith\r\n\r\nDid you seriously test this issue on all those devices listed in the environment field, or are you simply listing all the devices you have available? Please only include the devices that you have physically tested.\r\n\r\nAlso, if you have tested it in an emulator, you could include details of that.\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-30T12:47:16.000+0000", "updated": "2011-12-30T12:47:16.000+0000" }, { "id": "178128", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Keith\r\n\r\nWould you please provide the information I've requested, so I may escalate this ticket?\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2012-01-05T09:13:26.000+0000", "updated": "2012-01-05T09:13:26.000+0000" }, { "id": "178160", "author": { "name": "ziggythehamster", "key": "ziggythehamster", "displayName": "Keith Gable", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I have personally tested it on a Samsung Infuse 4G on AT&T running Gingerbread and my QA team tested it on whatever devices they tested it on (which is probably the aforementioned list but may not be the entire list, since the code failed miserably, they may not have tested it everywhere). \"org.mozilla.javascript.EvaluatorException: Cannot convert 1325269931753 to java.lang.Integer\" does not strike me as a device-specific problem however.", "updateAuthor": { "name": "ziggythehamster", "key": "ziggythehamster", "displayName": "Keith Gable", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-05T10:59:59.000+0000", "updated": "2012-01-05T10:59:59.000+0000" }, { "id": "178200", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "The use case is invalid. Blain Harmon's response below. However, am going to raise a apidoc ticket as this should be documented.\r\n\r\nI do believe that the difference is that iOS is simply letting the value overflow, so that the value stored with setInt would be some truncated, rolled over value. The reason I say that is that the data type used during setInt is indeed a 32 bit signed integer, and Apple's iOS docs say nothing of exceptions (The underlying method that causes the conversion is [NSNumber intValue]). Either way, An Int is a specific data type, of a 32 bit signed integer.\r\n\r\nHOWEVER, I think the issue here is one of documentation, to specify that int is the aforementioned specific data type. If you wish to store a larger value, setDouble exists for that very reason.\r\n", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2012-01-05T14:14:35.000+0000", "updated": "2012-01-05T14:14:35.000+0000" }, { "id": "414415", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T21:09:26.000+0000", "updated": "2017-03-21T21:09:26.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }