shannah / Java-Objective-C-Bridge

A thin bridge that allows for two-way communication from Java to Objective-C.
123 stars 25 forks source link

ClassNotFoundException: ca.weblite.objc.RuntimeMappings$Runtime #44

Closed rednoah closed 2 years ago

rednoah commented 2 years ago

I have an objc mapping that looks like this:

public static Object NSURL_URLByResolvingBookmarkData_startAccessingSecurityScopedResource(String text) {
        return Client.getInstance().sendProxy("NSURL", "URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:", NSData_initWithBase64Encoding(text), 1024, null, false, null).send("startAccessingSecurityScopedResource");
}

But with the latest version of objc I get this issue, and indeed RuntimeMappings does not contain a Runtime (without number) class, but I'm not quite sure what's going on, since the code compiles but doesn't work at runtime:

java.lang.ClassNotFoundException: ca.weblite.objc.RuntimeMappings$Runtime
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at ca.weblite.objc.RuntimeUtils.objc_msgSend(RuntimeUtils.java:315)
    at ca.weblite.objc.RuntimeUtils.msg(RuntimeUtils.java:351)
    at ca.weblite.objc.RuntimeUtils.msg(RuntimeUtils.java:790)
    at ca.weblite.objc.Client.send(Client.java:161)
    at ca.weblite.objc.Client.sendProxy(Client.java:354)
    at ca.weblite.objc.Client.sendProxy(Client.java:381)
    at net.filebot.platform.mac.MacAppUtilities.NSURL_URLByResolvingBookmarkData_startAccessingSecurityScopedResource(MacAppUtilities.java:69)
...
rednoah commented 2 years ago

Looks like objc_msgSend only works for up to 4 arguments, but for NSURL.URLByResolvingBookmarkData I'd need support for up to 5 arguments.

shannah commented 2 years ago

I've increased it to 7 args now. Please try these latest changes.

rednoah commented 2 years ago

Cheers. It works now. :)