473,395 Members | 1,941 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,395 software developers and data experts.

Riding JNI[Java Native Interface]: Java to C and back

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

Nov 14 '05 #1
2 1868
<ws********@yahoo.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hello all,
I am trying to obtain the size of a java object in C by using JNI.


I think you should be looking for a design where it's not necessary to
determine the size of a Java object.
Nov 14 '05 #2
On 27 Feb 2005 10:50:21 -0800, ws********@yahoo.com wrote in
comp.lang.c:
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.


Nope, we can't. As far as the C standard, and therefore this group is
concerned, C is the only language in existence. There is no such
thing as Java, C++, BASIC, FORTRAN, etc.

Even "using JNI" is done by a non-standard extension provided by your
operating system/compiler combination.

You need to ask in a Java group, or maybe one for your particular
compiler/OS combination.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #3

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

Similar topics

0
by: Psycho0190 | last post by:
Hello World ! I got some questions about the JNI and its usage with Microsoft Visual Studio. First question: I made an Win32 Application that starts a VM when clicking on a button. The first...
0
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....
2
by: cppaddict | last post by:
Hi, I'm writing a windows application in C++. However, much of the application's logic is already written in Java. I'd like to be able to make use of that code from within my C++ code. How...
4
by: Saurabh Sharma | last post by:
Hi I have a Project in C# which makes 4 dlls and takes 2 C# class of the dlls and a string array as as an input and returns a string array. I want to use these dlls in java. The dll also makes a...
1
by: chriskr7 | last post by:
Hi, I changed C source to C++ source and compiled with g++. The output file is .so module which java source calls JNI native function in the source. However, when aix server restart and try...
0
by: bpr | last post by:
i want to know list of softwares that are installed in my pc using jni interface its great , if any one provide me with dll's of a cpgm which does the work....
4
by: the.new.delboy | last post by:
Hi, I'm working on an application which requires some native calls to be made from Java. The calls work fine in one version of my code. I need to change the location of my native calls to a...
10
by: christery | last post by:
Got at java consumer to a producer that I want to connect to a pref. C# or some other .net app, on the producer side we went with java->jni- (thanks javah)>C->fortran program connecting to our...
3
etiainen
by: etiainen | last post by:
Hi everyone! I'm in a bit of a problem here: I have to make a maven project for native (jni & C) code. I am using this plugin:...
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.