opaque pointers in Java Re: ANNOUNCE: JPE, the Java-Python Extension - first beta release

Frederic Giacometti frederic.giacometti at arakne.com
Mon Apr 30 18:46:07 EDT 2001


Gerhard Häring wrote:

> On Sun, 29 Apr 2001 19:45:40 -0400, Frederic Giacometti wrote:
> >April 28, 2001
> >
> >I am pleased to announce the first beta release of JPE,
> >the Java-Python Extension.
> >
> > [...]
>
> I am also very pleased to see this come along. This will be a very useful tool
> :-) erm ... Python <-> Java makes a lot more sense than Python <-> Ada 95, but
> I am digressing ...
>
> Hmm, the build process was a little frustrating for me, but in the end it built
> (with a gazillion warnings). When I try to run the TestDND.py sample, I get the

Java does not provide opaque pointer capability (something like Python's COjbect).
The concept is dearly missing to Java (a basic type matching a void* memory
address, and whose value could be accessible only from the Java/JNI C programming
interface).

So, all references (pointers) to Python objects have to be cast back and forth to
jlong (Java long) to be carried around in the Java objects.

Visual C++ keeps this silent, on some Unix compilers (Tru64), specific warnings can
be turned off, but I could not find the feature on gcc...
To keep the gcc compiler noise low when developping, I'll convert all casts using
the following definitions (2 macro/function pairs):

#ifdef JPE_NOLONGCASTWARNING
  static void* jlong2void( jlong ref) {return (void*)ref;}
  static jlong void2jlong( void* ref) {return (jlong)ref;}
# define Jlong2void( ref) jlong2void( ref)
# define Void2jlong( ref) void2jlong( ref)
#else
# define Jlong2void( ref) ((void*)(ref))
# define Void2jlong( ref) ((jlong)(ref))
#endif

That way, the gadzillon warnings will be reduced to 2 warnings, at the expense of
an additional function call...

FG






More information about the Python-list mailing list