[jnigen] Generate `ResourceIdentifier`s
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 47
Description
To address https://github.com/dart-lang/native/issues/681, we should to generate `ResourceIdentifier`s on all JNIgen generated methods.
```dart
class PDDocument extends jni.JObject {
@ResourceIdentifier('jnigen')
jni.JObject getDocumentCatalog();
@ResourceIdentifier('jnigen')
static PDDocument load(
jni.JObject file,
);
}
```
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:
* What do we need from the resources.json format
* Currently the class surrounding the method is missing (workaround: `ResourceIdentifier('PDDocument')` to get the class this way)
* Instance methods are not supported. What would we need for instance methods? The identical `metadata` in the annotation on every override? Some serialization of the class hierarchy?
* Do we possibly need to change the structure of the generated JNI API?
Some assumptions:
* We cannot generate proguard rules for any dynamic invocations.
* We cannot generate proguard rules for uses of `package:jni` `invokeMethod` and friends.
@HosseinYousefi This would be very useful to know in the design of `hook/link.dart` and the `resources.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:
* https://github.com/dart-lang/native/issues/1085
* https://github.com/dart-lang/native/issues/1099
Contributor guide
Assessment
This issue has not been assessed yet.