Skip to Main Content

Binding a C library, thin or thick (object-oriented)?

3627710Jan 28 2018 — edited Feb 1 2018

I have written a C library with *_init(void) and *_destroy(void) functions. They are to be called once during program lifetime. Yes, I know this is not object-oriented, but these function install signal handlers and thus are inherently global due Unix misdesign not allowing to easily enough chain signals, so that signals are global objects.

Now I am going to write a Java wrapper around this C library.

My question: Should I make an object, whose constructor calls *_init() and finalize() calls *_destroy()?

Or should I make just functional (non-OO) wrappers around these functions?

I think that I should call *_destroy() from finalize block. But with OO interface I can not worry that destroy will be called (anywhere with the lifetime of my application). So with OO it is a little easier.

Is it worth to use OO here?

Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Mar 1 2018
Added on Jan 28 2018