I’ve been testing out a small JSON parsing app written in Silver and Sugar on some iOS devices and it runs perfectly, but today I tried to get the same code running on an Android device and during compilation I see an EXCEPTION FROM SIMULATION error.
I’m running an alpha version of Fire (v8.3.92.1911) and Sugar compiled from the beta branch (commit ID 8f62c6a) to fix the TimeSpan problems that I was seeing a couple of weeks ago, so this might not be an issue that other people are seeing.
The error that I’m shown is:
/Applications/Fire-alpha.app/Contents/Resources/XbuildTargets/RemObjects Software/Oxygene/RemObjects.Oxygene.Cooper.Android.targets: error : EXCEPTION FROM SIMULATION:
expected type long but found int
…at bytecode offset 000000ba
locals[0000]: Lorg/me/jsonandroid/JsonParser;
locals[0001]: I
locals[0002]: I
locals[0003]: Lsugar/json/JsonObject;
locals[0004]: Lsugar/json/JsonStringValue;
locals[0005]: Lcom/remobjects/elements/system/Tuple2;
locals[0006]: Ljava/lang/Long;
locals[0007]: Ljava/lang/Long;
locals[0008]:
locals[0009]:
…while working on block 00b9
…while working on method setEvent:()V
…while processing setEvent ()V
…while processing org/me/jsonandroid/JsonParser.class
1 error; aborting
The line of code causing the problem is: let (startTime, endTime) = getTimePeriod(eventObject!)
The code that this executes is: private func getTimePeriod(object : JsonObject) -> (Int64, Int64) { let timePeriods = object.Item["when"] as? JsonArray if (timePeriods == nil || timePeriods!.Count != 2) { return (-1, -1) } let startTime = timePeriods!.Item[0] as! JsonIntegerValue let endTime = timePeriods!.Item[1] as! JsonIntegerValue return (startTime.Value as! Int64, endTime.Value as! Int64) }
It’s not great code, but it does the job for the test I’m working through.
Actually I see the same error when using the code that you suggested: let timePeriod = getTimePeriod(eventObject!) let startTime = timePeriod.0 let endTime = timePeriod.1
/Applications/Fire-alpha.app/Contents/Resources/XbuildTargets/RemObjects Software/Oxygene/RemObjects.Oxygene.Cooper.Android.targets: error : EXCEPTION FROM SIMULATION: expected type long but found int ...at bytecode offset 000000ba locals[0000]: Lorg/me/jsonandroid/JsonParser; locals[0001]: I locals[0002]: I locals[0003]: Lsugar/json/JsonObject; locals[0004]: Lsugar/json/JsonStringValue; locals[0005]: Lcom/remobjects/elements/system/Tuple2; locals[0006]: Ljava/lang/Long; locals[0007]: Ljava/lang/Long; locals[0008]: <invalid> locals[0009]: <invalid> ...while working on block 00b9 ...while working on method setEvent:()V ...while processing setEvent ()V ...while processing org/me/jsonandroid/JsonParser.class 1 error; aborting
I can’t send you the code that I’m working on, so I tried to create a small test app with only a couple of methods to show the problem that I have with my real app. The test app, which has the code that I pasted in earlier in the thread, builds correctly though so I’m not sure why the problem’s occurring.