Need Feedback: Centralize (j)int <-> HANDLE conversions under Win32?
Fri Nov 7 04:04:00 GMT 2003
For my next little project, I was thinking of
centralizing the conversion of GCJ file handles
(which are (j)ints) and Win32 handles, which are
of type HANDLE or SOCKET. At present, we
indiscriminately do old-style C typecasts
between HANDLE, SOCKET and jint in the Win32 code.
(HANDLE is a typedef for a pointer type under Win32.
SOCKET is an unsigned int.)
What I'd like to do is put something in win32.h
which looks something like this (I'm just typing
this on-the-fly so be indulgent - and also keep
in mind that I'm bad at names):
typedef jint LibJavaFD;
...and make all conversions go through these
This is somewhat tangential to this:
...but not necessarily mutually exclusive. I'm
not sure whether the above discussion was continued in
the CLASSPATH list or not.
Not only does this centralized conversion under Win32
seem to make sense to me, but it would be a bit of
insurance for the day that Win64 comes along and the
jint <-> HANDLE typecasts break. If this issue isn't
resolved in a more elegant way, then in the Win64, we
could have the conversion functions use integers which
are indices into a lookup table of HANDLEs. Of course,
access to this table would have to be synchronized,
but it would be better than nothing.
More information about the Java