-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jnigen] Generate ResourceIdentifier
s
#1098
Comments
@liamappelbe mentioned that we'd need to deal with renames and super classes, so probably we should generate something along the lines of: @ResourceIdentifier({
'jnigen': true,
'java_class' : 'SomeClass',
'java_method' : 'someMethod',
'java_method_static' : true,
'java_super_class' : 'SomeOtherClass',
}) |
We have
I don't think so, I will try it!
Of course, this seems to be fine. If you want any level of dynamicism, you'll have to deal with keeping the classes and methods yourself.
We could consider supporting this use case iff all the names and signatures are known at compile time. And maybe issue a helpful warning when the names and signatures are not const. final jclass = JClass.forName('Ljava/nio/ByteBuffer;'); // using a string literal, so we could keep it
const name = 'allocate';
final allocate = jclass.staticMethodId(name, '(I)Ljava/nio/ByteBuffer;'); // ditto Will we be able to "link" the method name with the class name though? Or does the I can construct another use case, imagine we have a bunch of icon fonts in a Flutter application and we want to access a certain one: final font = Font('assets/fonts/1.ttf');
final icon = font.icon(5);
// We would ideally like to keep the icon number 5 from 1.ttf and tree-shake everything else that's unused.
We only need the class' binary name, member name, its signature, and its modifiers to keep the class or member in proguard: https://www.guardsquare.com/manual/configuration/usage |
For example using cc/ @mosuem |
To address #681, we should to generate
ResourceIdentifier
s on all JNIgen generated methods.The consuming of the annotations can be tested with
pkg/vm/tool/gen_kernel
.pkg/vm/tool/gen_kernel --help
shows the API.--resources-file=... --aot --tfa
are the arguments to use.Some questions to answer:
ResourceIdentifier('PDDocument')
to get the class this way)metadata
in the annotation on every override? Some serialization of the class hierarchy?Some assumptions:
package:jni
invokeMethod
and friends.@HosseinYousefi This would be very useful to know in the design of
hook/link.dart
and theresources.json
format. Can you give the existing implementation a spin and try to answer the above questions? (And maybe ask some more good questions! 😄)Related issues:
@Native
s and@ResourceIdentifier
#1085ResourceIdentifier
s for Objective-C #1099The text was updated successfully, but these errors were encountered: