Skip to content

MethodNotFoundException in GetExtern(), possibly during JIT #415

Description

@aarononeal

I ran into this issue today and wanted to document it.

void Start() {
    ObjectiveCRuntime.Initialize();
    var x = NSApplication.NSApplicationLaunchRemoteNotificationKey;
}

Running that I get MethodNotFoundException.

What seems to happen is Start() is JIT compiled, NSApplicationLaunchRemoteNotificationKey is resolved, which resolves ObjectiveCRuntime.GetExtern() which internally uses GetInstanceInternal. The latter is an internal method which hasn't been registered yet because the bridge hasn't been bootstrapped because ObjectiveCRuntime.Initialize() hasn't actually executed yet. More specifically, the static constructor for ObjectiveCRuntime hasn't executed yet because Start() is still being compiled.

Moving the constant extern to a separate method works around it.

void Start() {
    ObjectiveCRuntime.Initialize();
    CheckConstant();
}
void CheckConstant() {
    var x = NSApplication.NSApplicationLaunchRemoteNotificationKey;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions