Discovering a portable way of storing C/C++ pointers in Java
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kyle_Downey
Posted On:   Tuesday, May 8, 2001 02:21 PM

I am helping with a project that stores
some C/C++ data as a pointer in a Java class as an int. My role has been to
add autoconf support, and I identified
this as a possible problem autoconf
might have to cover over. On Itanium,
UltraSPARC and other 64 bit
architectures, isn't typeof(void *) ==
long rather than int? How should I handle this? I see some people use int in JNI, and some use long. Is there a
way to test using autoconf, or a
helpful type defined in JNI itself?

--kd

Re: Discovering a portable way of storing C/C++ pointers in Java

Posted By:   Alexander_Krapf  
Posted On:   Thursday, May 10, 2001 07:36 AM

Hi Kyle,


We at Codemesh have decided to always use long to store pointers in Java classes. Even if there is a way of detecting the native pointer size, I don't think you would want to take advantage of it. You would have to have two different Java implementations of the same class, one using 32bit poitners, the other using 64bit pointers. That sounds dangerously confusing and pointless, just in order to save a couple of bytes per instance.


I am not aware of a JNI provided type that assist in native pointer storage. If there were one, I would assume that they would choose to go with the largest reasonable size, just for portability reasons.


Good luck,


Alex

About | Sitemap | Contact