Merge: Java FFI: use class NitObject for references to Nit objects from Java
authorJean Privat <jean@pryen.org>
Fri, 1 Mar 2019 00:08:44 +0000 (19:08 -0500)
committerJean Privat <jean@pryen.org>
Fri, 1 Mar 2019 00:08:44 +0000 (19:08 -0500)
commitb1970c9463a9154435d41a3c78301a35fb05a5df
treea59dbdec4851e572956388acf5b610335be8e871
parent8989d627b35f762f8332a1ede1dde090213d200a
parent18c3d60356b2f4c768a022a0281fec113b8a5839
Merge: Java FFI: use class NitObject for references to Nit objects from Java

This PR improves the type safety of the Java FFI and fixes a bug with pointers to Nit objects at the same time.

* The main change is the introduction of the Java class `NitObject` used as a general type for Nit objects referenced from Java code. It replaces the use of a simple `int` holding the pointer value, which was the source of the Java FFI bug.

* Change internal pointers to Nit object to use the Java primitive types `long` instead of `int`, addressing to the same pointer bug. Only low-level services should still use `long` this way, in this case it is the support for Android that relies mostly on the FFI with C.

* Change the annotation `extra_java_files` to accept the full name of Java classes (package + class) instead of the path to the Java source file. The compile still looks for the file in the same directory as the Nit module.

* Clear up the documentation of the class `ExternFile` for `filename` to be relative to the compilation folder. This required updating previous usages.

Pull-Request: #2740
Reviewed-by: Jean Privat <jean@pryen.org>