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

C++ JNI jobject conversion

I have a java method setup where it will be accessed in C++ via JNI.
The process is as follows:

1) C++ function getObject(...) is called.

2) getObject(...) uses JNI to access a java class method
getJObject(...).

3) getJObject(...) will do some calculations, save them to a complex
object. This object is downcasted to the class "Object" and returned.

4) C++ function getObject(...) get's back a <jbyteArray> from the JNI
call and casts this to a jobject.

My question is...what can methods can I perfrom on this jobject. What
fields can I access? I'm trying to convert it into an already existing
C++ class, but am unsure on what i can do.
Help Please!

Tim

Jul 22 '05 #1
4 10541
Tim Wong wrote:
I have a java method setup where it will be accessed in C++ via JNI.
....which is completely off-topic here...
The process is as follows:

1) C++ function getObject(...) is called.

2) getObject(...) uses JNI to access a java class method
getJObject(...).

3) getJObject(...) will do some calculations, save them to a complex
object. This object is downcasted to the class "Object" and returned.

4) C++ function getObject(...) get's back a <jbyteArray> from the JNI
call and casts this to a jobject.
I can see everything relates to Java and the way _it_ is set to interact
with C++, but C++ knows not how to interact with Java.
My question is...what can methods can I perfrom on this jobject.
What can methods? What's a "can method"?
What
fields can I access?
Fields? You mean, members? Public members from any non-member and
non-friend functions, public and protected members from an object on
the same class hierarchy and any members from a member or a friend.
I'm trying to convert it into an already existing
C++ class, but am unsure on what i can do.


Do what you need, and if you encounter errors, post again. To the
Java newsgroup. Unless your question is about C++ only, then your
post should contain no mention of Java whatsoever.

V
Jul 22 '05 #2
You can decode your jbyteArray and create a java object from it, but there
are no methods mystically attach to it,
just by saving a stream of data... So.. you should be able to cast it to an
array of bytes in java, and access methods of a java array, but that is
about it there is not much else possible.

What you want is to have a C++ wrapper that can be created from a JByteArray
and something else, and a Java class that can be created from an array of
bytes, and from something else... What you are doing by creating a
jbytearray, is something like streaming an object. But you would need to
create your own streaming operators/functions in both java an C++, so they
would know what byte[X] of the byte stream is.

Jesper

"Tim Wong" <ti************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a java method setup where it will be accessed in C++ via JNI.
The process is as follows:

1) C++ function getObject(...) is called.

2) getObject(...) uses JNI to access a java class method
getJObject(...).

3) getJObject(...) will do some calculations, save them to a complex
object. This object is downcasted to the class "Object" and returned.

4) C++ function getObject(...) get's back a <jbyteArray> from the JNI
call and casts this to a jobject.

My question is...what can methods can I perfrom on this jobject. What
fields can I access? I'm trying to convert it into an already existing
C++ class, but am unsure on what i can do.
Help Please!

Tim

Jul 22 '05 #3
Jesper Madsen wrote:
"Tim Wong" <ti************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a java method setup where it will be accessed in C++ via JNI.
The process is as follows:

1) C++ function getObject(...) is called.

2) getObject(...) uses JNI to access a java class method
getJObject(...).

3) getJObject(...) will do some calculations, save them to a complex
object. This object is downcasted to the class "Object" and returned.

4) C++ function getObject(...) get's back a <jbyteArray> from the JNI
call and casts this to a jobject.

My question is...what can methods can I perfrom on this jobject. What
fields can I access? I'm trying to convert it into an already existing
C++ class, but am unsure on what i can do.

Don't top-post. Rearranged.
You can [...]


read the FAQ. And you should too.

http://www.parashift.com/c++-faq-lite/how-to-post.html
Jonathan
Jul 22 '05 #4
Sorry,

I figured I was in the right news group because it was a C++ coding
question.
Victor Bazarov wrote:
Tim Wong wrote:
I have a java method setup where it will be accessed in C++ via JNI.

...which is completely off-topic here...
The process is as follows:

1) C++ function getObject(...) is called.

2) getObject(...) uses JNI to access a java class method
getJObject(...).

3) getJObject(...) will do some calculations, save them to a
complex object. This object is downcasted to the class "Object" and returned.
4) C++ function getObject(...) get's back a <jbyteArray> from the JNI call and casts this to a jobject.


I can see everything relates to Java and the way _it_ is set to

interact with C++, but C++ knows not how to interact with Java.
My question is...what can methods can I perfrom on this jobject.


What can methods? What's a "can method"?
> What
fields can I access?


Fields? You mean, members? Public members from any non-member and
non-friend functions, public and protected members from an object on
the same class hierarchy and any members from a member or a friend.
> I'm trying to convert it into an already existing
C++ class, but am unsure on what i can do.


Do what you need, and if you encounter errors, post again. To the
Java newsgroup. Unless your question is about C++ only, then your
post should contain no mention of Java whatsoever.

V


Jul 22 '05 #5

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

Similar topics

0
by: Wes | last post by:
Hello, I have a C++/JNI program that creates a Java object, populates the members and returns the jobject to the calling Java program. The code compiles and runs cleanly with no exceptions being...
1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
7
by: Michael Lehn | last post by:
Hi, I have a question regarding the conversion of objects. When is the conversion done by the constructor and when by the operator. My feeling tells me that the constructor is preferred. But...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
2
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public...
3
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.