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!

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
915 views