Setting a Java.Object with UXL macros

Hi,

I tried to do this:

static Java.Object myCallbackManager;

and then in my method:

@{myCallbackManager:Set(callbackManager)};

But got this error:

../../../../usr/local/share/uno/Packages/UnoCore/0.26.9/Source/Uno/Compiler/ExportTargetInterop/Foreign/Android/$.uno(23.1): E6118: 'Facebook.myCallbackManager:Set(uCast<@{Java.Object}>(uno_setVal, @{Java.Object:TypeOf}))': Object reference not set to an instance of an object

(This is the generated java code:

ExternedBlockHost.callUno_Facebook_myCallbackManagerSet55(callbackManager,UnoHelper.GetUnoObjectRef(callbackManager));

)

Is it possible, or do I need to have a function that returns the callbackmanager?

Hi!

This is odd as what you are writing looks perfectly reasonable.

I will test this again on our end to make sure there havent been any regressions and then get back to you.

Thanks as ever for the detailed report.

Regards

Hi Chris,

I managed to make this working. Probably with Olle’s help on Slack. So don’t wear yourself out trying to fix this. :slight_smile:

Hey, I’ve had a little dig into this and havent been able to reproduce it, maybe we have this fixed on the more recent versions.

Here is what I have

    public NativeTest()
    {
        DoFieldStuff();
        StaticFieldStuff();
    }

    static Java.Object myCallbackManager;

    [Foreign(Language.Java)]
    static public extern(android) void StaticFieldStuff()
    @{
        Object callbackManager = "no Really I am a callbackManager";
        @{myCallbackManager:Set(callbackManager)};    @}


    [Foreign(Language.Java)]
    public extern(android) void DoFieldStuff()
    @{
        Object callbackManager = "no Really I am a callbackManager";
        @{myCallbackManager:Set(callbackManager)};
    @}

And it compiles and runs just fine. I’m tentatively mark this as resolved but if you still see the issue in the next release please yell at me and we will open it up again.

Cheers as ever for the good leads on bugs :slight_smile:

Back again, HAve been poking at this code with some big sticks and managed to find a few more bugs. One of them was related to null checks and so could absolutely account for the issues you were seeing.

Those fixes missed the code freeze for 0.12 but will be in the following release.

I’m going to mark this as resolved though feel free to bump if needed.

Thanks for the heads-up on the issues.