Closed zcaudate closed 4 years ago
I looked into it and figured out how that error happened.
Struct.time_t
is an inner class of the Struct
class, and an inner class in general has an associated enclosing instance. When javac
compiles an inner class C
, it implicitly passes the enclosing instance to C
's constructors as their first argument and maintains internally the relationships between the enclosing instance and each instance of C
. JiSE does not support inner classes (or any other nested classes) at all right now, nor has such an internal mechanism.
To work around the issue, you'll need to feed the enclosing instance (i.e. this
) on your own to the constructors of inner classes, as follows:
^:public
(defm Timeval [^jnr.ffi.Runtime rt]
(super rt)
(set! (.tv_sec this) (Struct$time_t. this))
(set! (.tv_usec this) (Struct$SignedLong. this))))
Ah that makes sense. The example is working now.
Thanks!
@athos: I'm looking to get jnr-ffi working with jise and am porting the Gettimeofday example here:
https://github.com/jnr/jnr-ffi-examples/blob/master/gettimeofday/src/main/java/gettimeofday/Gettimeofday.java
I'm having problems compiling the
defclass
form. Would you please take a look and let me know what I'm doing wrong.https://gist.github.com/zcaudate/f05001f6cc38a8a02f9b0892bab02a82
I'm getting this error here, which I'm not sure is
defclass
orjnr
related.