

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
15 messages in net.java.dev.jna.usersRe: [jna-users] Override Pointer.fina...| From | Sent On | Attachments |
|---|---|---|
| bb...@cox.net | Jun 26, 2007 9:11 am | |
| Timothy Wall | Jun 26, 2007 12:52 pm | |
| Wayne Meissner | Jun 26, 2007 7:43 pm | |
| Ben Chase | Jun 26, 2007 8:39 pm | |
| Wayne Meissner | Jun 26, 2007 10:33 pm | |
| Timothy Wall | Jun 27, 2007 5:08 am | |
| Timothy Wall | Jun 27, 2007 5:20 am | |
| Rick Goldstein | Jun 27, 2007 8:50 am | |
| Timothy Wall | Jun 27, 2007 9:59 am | |
| Ben Chase | Jun 27, 2007 7:26 pm | |
| Timothy Wall | Jun 28, 2007 3:56 am | |
| bb...@cox.net | Jun 28, 2007 4:43 am | |
| bb...@cox.net | Jun 28, 2007 5:37 am | |
| bb...@cox.net | Jun 28, 2007 6:18 am | |
| Wayne Meissner | Jun 28, 2007 7:41 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Override Pointer.finalize to reclaim Native resources? | Actions... |
|---|---|---|
| From: | bb...@cox.net (bb...@cox.net) | |
| Date: | Jun 28, 2007 5:37:11 am | |
| List: | net.java.dev.jna.users | |
---- Timothy Wall <twal...@dev.java.net> wrote:
I don't mean to imply no one else is using it. I just mean that no one else has (yet) participated in a discussion of how best to represent usage XYZ, or provided much feedback after getting suggestions on how to approach a particular mapping.
Okay...,
I now have lots of code that looks like public class Image { private Pointer jnaPointer; public Pointer getPointer() { return jnaPointer; } protected void finalize() throws Throwable { Media.INSTANCE.destroyImageHandle(getPointer()); } ... // Methods actually relevant to an Image }
So, maybe JNA should provide this base class: public class WrappedPointer { private Pointer jnaPointer; public Pointer getPointer() { return jnaPointer; } public void setPointer(Pointer p) { jnaPointer = p; } }
and then I would have instead written public class Image extends WrapperPointer { protected void finalize() throws Throwable { Media.INSTANCE.destroyImageHandle(this); } ... // Methods actually relevant to an Image }
? (I haven't thought too hard about the public/private/protected decls on the
above.) If JNA provides methods which expect WrapperPointers (in addition to
the ones
that expect Pointers, I guess), does that help, or does it just make JNA more
baroque? Thinking about it some (the initial version of this email got tossed
by the spaminator), I think this works. Everywhere JNA would take a Pointer, it
also takes a WrappedPointer. Most users will just extend WrappedPointer (rather
than perhaps wondering how to subclass Pointer, as I did). They don't have to
extend WrapperPointer; they could roll their own version of it (just as I was
obligated to do). The only difference when using this proposed WrappedPointer
is that the getPointer() call would happen inside JNA instead of in the user's
code, and the user gets type safety because he can claim that methods in the
Interface each expect certain subclasses of WrappedPointer.
So, it looks like a win. Well, to me.







