This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: RFC: Make gnu.classpath.Pointer work
- From: Tom Tromey <tromey at redhat dot com>
- To: Gary Benson <gbenson at redhat dot com>
- Cc: java at gcc dot gnu dot org
- Date: 17 Jan 2007 07:31:18 -0700
- Subject: Re: RFC: Make gnu.classpath.Pointer work
- References: <20070117133110.GC6617@redhat.com>
- Reply-to: tromey at redhat dot com
>>>>> "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