are only executed if the Nim constructor (proc new) is called to create/construct a Jnim object. But when the object is created from Java code (the Java-exported constructor of the class is called), the setNimDataToJObject procedure is never executed, and thus this.data is nil in such an object.
To fix this, I think the code initializing the .data field could be moved to the Java constructor (e.g. as a native private helper function to be called from the constructor, similar to the _0 and _1 method & field).
I will try to workaround this temporarily in my current code; I hope to get back to fixing this properly later in the future. For now I'm opening the issue for the record.
The following lines generated by
implementConstructor
:https://github.com/yglukhov/jnim/blob/de5f19900c88200ce3eef94abbb4332ea7bd13ce/jnim/private/jni_export.nim#L288-L290
are only executed if the Nim constructor (
proc new
) is called to create/construct a Jnim object. But when the object is created from Java code (the Java-exported constructor of the class is called), thesetNimDataToJObject
procedure is never executed, and thusthis.data
is nil in such an object.To fix this, I think the code initializing the
.data
field could be moved to the Java constructor (e.g. as a native private helper function to be called from the constructor, similar to the_0
and_1
method & field).I will try to workaround this temporarily in my current code; I hope to get back to fixing this properly later in the future. For now I'm opening the issue for the record.