RFC: Make gnu.classpath.Pointer work
Tom Tromey
tromey@redhat.com
Wed Jan 17 16:40:00 GMT 2007
>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
Gary> Is this patch all that's needed to make gnu.classpath.Pointer an
Gary> analogue of gnu.gcj.RawData?
I don't think Pointer works like RawData, and without extra work on
the JNI code, this patch will result in bugs. Furthermore I think it
would probably be more trouble than benefit to actually do this work
on the JNI code, since it would mean keeping a divergence around
forever.
Pointer is a base class with 2 concrete subclasses: Pointer32 and
Pointer64. The Classpath JNI code creates an instance of one of these
subclasses depending on the system it is running on. Each of the
subclasses is just a plain old Java class, and each wraps a value
(either int or long) which is a cast C pointer. When a real C pointer
is needed, the value is extracted and cast back. See jni/classpath/jcl.c.
RawData on the other hand is basically like a 'void*'. A RawData
field does not point to a Java object at all.
If this patch goes in I think we will see bugs where a Pointer is
collected but then later dereferenced by the JNI code.
Tom
More information about the Java
mailing list