Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19023
| From | Steven Simpson <ss@domain.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JNI return jobjectArray |
| Date | 2012-10-01 23:46 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <14jpj9-va7.ln1@s.simpson148.btinternet.com> (permalink) |
| References | <k4a9gd$usp$1@online.de> |
On 30/09/12 21:23, Philipp Kraus wrote:
> class myclass {
>
> void native mymethod( Double[] x )
> }
I realise this snippet could be just for illustration, but 'native' must
come before the return type in real code. Missing semicolon too.
> so the parameter x should be a call-by-reference, I would set x in the
> native JNI function:
>
> void mymethod( JNIEnv *jenv, jclass jcls, jobjectArray& jarg )
When I tried the class (after the fixes) with javah, I got this:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class myclass */
#ifndef _Included_myclass
#define _Included_myclass
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: myclass
* Method: mymethod
* Signature: ([Ljava/lang/Double;)V
*/
JNIEXPORT void JNICALL Java_myclass_mymethod
(JNIEnv *, jobject, jobjectArray);
#ifdef __cplusplus
}
#endif
#endif
The jobjectArray parameter has no '&'. If it had one, it would not be
possible to link it with a C implementation. If an '&' is inserted
manually, and the function is implemented in C++, the machine code would
likely be identical to an equivalent function using a pointer, but the
JVM would not pass a jobjectArray* to it, and you'd get undefined behaviour.
--
ss at comp dot lancs dot ac dot uk
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
JNI return jobjectArray Philipp Kraus <philipp.kraus@flashpixx.de> - 2012-09-30 22:23 +0200
Re: JNI return jobjectArray markspace <-@.> - 2012-09-30 14:56 -0700
Re: JNI return jobjectArray Philipp Kraus <philipp.kraus@flashpixx.de> - 2012-10-01 00:23 +0200
Re: JNI return jobjectArray markspace <-@.> - 2012-09-30 19:21 -0700
Re: JNI return jobjectArray Lew <lewbloch@gmail.com> - 2012-09-30 21:14 -0700
Re: JNI return jobjectArray markspace <-@.> - 2012-10-01 08:32 -0700
Re: JNI return jobjectArray "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-10-01 09:39 +0100
Re: JNI return jobjectArray Roedy Green <see_website@mindprod.com.invalid> - 2012-10-01 10:21 -0700
Re: JNI return jobjectArray Steven Simpson <ss@domain.invalid> - 2012-10-01 23:46 +0100
csiph-web