JNI: Java objects to C for estimating size

W

ws_dev2001

Hello all,
I am trying to obtain the size of a java object in C by using JNI. As
we do not have a proper implementation of this in java[other than obj
serialization and reflection etc...], I decided to see if C could
provide me some accurate data.
As in java, C does provide accurate sizeof for primtives and can even
handle String objects received from java. In java reflection, we cannot

find/estimate the length of the string with as much ease as it is in C
via JNI.
Sizeof impl in C seem to be centred around primitives and structs
etc...
So, how do I find the sizeof a java object being sent via native method

call to a C program? Do I need to allocate memory for this object
[estimation based]?
I tried loading the jobject into a struct but sizeof always gives me 4
whether it is via sizeof(jobject) or sizeof(struct myjostruct)!!!
I understand that this is the size allocated for the address in memory.

Can anyone please help ?
TIA
 
G

Gordon Beaton

I am trying to obtain the size of a java object in C by using JNI. As
we do not have a proper implementation of this in java[other than obj
serialization and reflection etc...], I decided to see if C could
provide me some accurate data.

Do you not read the newsgroup after posting a question? You have
already received a number of replies to your earlier, identical
question.

If you don't like or don't understand an answer you've been given,
reply to *that* post and say why. Don't just start a new thread to
repeat the original question.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top