Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

C++ -> Java -- Multiple Return Values

843829Oct 31 2006 — edited Nov 2 2006
I am in need to multiple values from a method.
A status code (int) and a return value (double).

From what I have read -- it is customary to use an object array to handle this, since java does not support out parameters.

When I return the Object[] through JNI as a jobjectArray how do I obtain(cast) the values as int and double???

This is how I am getting the values from the array via JNI. However the cast to jint does not work as expected.
jsize numOfObjects = m_env->GetArrayLength(attrReturnArray);

if ( numOfObjects >= 2 )
{
   jint status = (jint)m_env->GetObjectArrayElement(attrReturnArray, 0);
   jint retValue = (jint)m_env->GetObjectArrayElement(attrReturnArray, 1);
}
Any sugestions?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 30 2006
Added on Oct 31 2006
5 comments
859 views