You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 1, we also have to specify which Java classes we really want to subclass. Generating native & java code for all classes will blow up the size of the app. These wrapper java classes can't be tree shaken by proguard, and C files also are bundled. This can be fine with small java - dart interlinking, but not general purpose libraries.
In 2, all primitive arguments are boxed, which is also significant usability disadvantage unless we also generate some code around this.
I think a bytecode generation strategy, while far-fetched, is optimal here.
Java:
@FunctionalInterface
class Runnable {
void Run();
}
Dart:
class Runnable extends JniObject {
void Run() => jni.methodCall(..)
static JObject fromDartSubclassInstance(Runnable x) {
// on first invocation, create bytecode for a class with appropriate native methods
// and a long integer storing handle to dart object
// this is a generated method, so can pass dart handles of all methods.
}
}
I don't know how feasible this is. also, the methods have to be per-isolate. Dart GC may have to pin the reference to current obect etc.. etc..
Uh oh!
There was an error while loading. Please reload this page.
Implementation strategy 1: native methods
JNI features a way of declaring native methods.
https://docs.oracle.com/en/java/javase/17/docs/specs/jni/design.html
We should consider if it makes sense to add some kind of way to generate a Java class that delegates all of its methods to Dart.
This would generate:
The developer would then implement the Dart interface.
Implementation strategy 2: proxies
https://docs.oracle.com/javase/8/docs/technotes/guides/reflection/proxy.html
Pro:
Con:
Related issues
The more general version of:
The text was updated successfully, but these errors were encountered: