Android EXCEPTION FROM SIMULATION when returning a tuple

Hi,

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.

Any idea how I can work around this?

Cheers,

Sevan

Thanks, logged as bugs://74377

I think a temp workaround could be:

let temp = getTimePeriod(eventObject!)
let startTime: Int64 = temp.0
let endTime: int64 = temp.1

Obviously as a temporary workaround till this is fixed.

Hi Carlo,

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

Cheers,

Sevan

can you give me a more complete testcase so I can reproduce this locally? Private is fine if needed.

(Reason I ask is that:


public class MainActivity: Activity {
    private func getTimePeriod(object : sugar.json.JsonObject) -> (Int64, Int64) {
        let timePeriods = object.Item["when"] as? sugar.json.JsonArray	
        if (timePeriods == nil || timePeriods!.Count != 2) {
            return (-1, -1)
        }
        let startTime = timePeriods!.Item[0] as! sugar.json.JsonIntegerValue
        let endTime = timePeriods!.Item[1] as! sugar.json.JsonIntegerValue
        return (startTime.Value as! Int64, endTime.Value as! Int64)
    }

	public override func onCreate(savedInstanceState: Bundle!) {
		super.onCreate(savedInstanceState)
		ContentView = R.layout.main
        var eventObject = sugar.json.JsonObject();
        let (startTime, endTime) = getTimePeriod(eventObject!)
	}
}

works fine. (V8.3.90.1925)

Hi Carlo,

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.

I’ll keep investigating if I have time.

Cheers,

Sevan

FWIW, we will keep your project confidential if you send it to us via direct mail to support@ (or mh@, if you prefer).

bugs://74377 got closed with status testcaseerr.