Dear Mentors
Greetings of the day.
I am Prayas, a student at Birla Institute of Technology and Sciences, Pilani. I am interested in the GSoC project - JNI interop for Dart. I know there is a discussion forum. I even put some queries there before. I have made my heart and mind to work this summer with Dart 🤞🏻. Hopefully, also in the fall. The project really excites me. The last few days, reading and researching the task, related projects, building the sample project and preparing possible workflows for the project have been such a fun and delightful experience. I can not wait for summer to begin and get on with it.
I am writing this mail to discuss ideas that may be within or beyond the project's scope but are strongly related to the project. And to take your opinions on it.
- DartVM, JVM and Garbage collection:
- When to collect garbage? How to coordinate it between the two VMs? What will happen if both VMs work asynchronously on the same data in a heap?
- How do you detect cycles between the VMs?
- How I imagine it is as DartVM will exist throughout the running of an app. JVM will be booted when DartVM calls JVM and then shuts down.
- Memory debugging tools: In continuation with the previous point, should the package I write will also provide memory debugging tools? If so, what technical depths will that be expected?
- C is a procedural lang, and Dart and Java are object-oriented langs.
- dart:ffigen generates dart bindings for C libraries. It converts Dart primitive data types int, double, etc to C primitive data types like int32, int64, char, bool, etc for native functions in C. But Java libraries can also have functions with objects as parameters. Developers of Dart will like features where Java Classes will map/bind to Dart Classes with as little code as possible. eg: DartParentClass binds to JavaParentClass, DartChildClassA binds to JavaChildClassA, and so on with as little code as possible. (Refer to the image below)
- Implementing polymorphism is the trickiest and most mind-boggling (refer to image) task I can think of. Say Dart Class Files are generated using Java Class Files and binded to Java Class Files. Next, MAIN.dart has an object called objVar of type DartParentClass, storing an object of DartChildClassA later DartChildClassB. The commands at line2 and line4 are to call the java functions using JNI from the dart code. The function call at line2 should pick f1, not f2. Similarly, line4 should call f2, not f1. I cannot process this out, but I am sure I can reach an algorithmic conclusion.

As of now, points 1 and 2 are optional deliverables, i.e. if I get the extended timeline.
Point 3, in my opinion, is very much needed. Without this, the project will be incomplete.
I require your thoughts and opinions on all 3.
Also, currently, I am still working on my proposal, refining workflow, mapping the timeline, etc. Most of all waiting for your input. Then I will submit a draft for you to review.
Sincerely
Prayas Kumar Singh