473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JNI: Java objects to C for estimating size

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

Jul 17 '05 #1
0 1991

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Eric | last post by:
Hi, After reading the JNI specs, it looks like no JNI call is available to retrieve the reference count for a specific Java Object (LocalRef or GlobalRef). I would like to able to retrieve...
19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
2
by: ian maclure | last post by:
I'm trying to understand JNI well enough to be be able to supply a state model class in C++ to some client applications and use the same model in the JAVA app that controls the clients. The state...
32
by: Sambucus | last post by:
Hi group! I am using C++ and java with JNI to get some text in a RICHEDIT to my java program. I do so by accessing a C++ method every second. It all works fine except that it leaks memory every...
2
by: ws_dev2001 | last post by:
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, I decided to see if C could provide me some accurate data....
3
by: Sai Kit Tong | last post by:
Hi, I am developing a new application running on Windows platform that needs to interface with existing legacy code - written in basic C / C++. I am trying to evaluate Java vs C#...
3
by: Sai Kit Tong | last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't make it clear in my original mail. I got a couple of answers but none of them address my issues directly (See attached...
2
by: David Stevenson | last post by:
Programs from: Sheng Liang, The Java Native Interface, Programmer's Guide and Specification, The Java Series, (c) 1999, pp. 38-39. I thought I copied the program pretty exactly, but I don't know...
2
myusernotyours
by: myusernotyours | last post by:
Hi All, Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.