This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: JNI bug?


On Monday 29 January 2007 19:15, Andrew Haley wrote:
> Andrew Haley writes:
>  > Marco Trudel writes:

>  >  > [...]
>  >  > 	private static native void nativePrintBoolean(boolean b);
>  >  > 	private static native void nativePrintBooleanAsInt(boolean b);
>  >  > }
>  >  >
>  >  > Now this c code:
>  >  >
>  >  > #include <jni.h>
>  >  >
>  >  > JNIEXPORT void JNICALL Java_NativeBooleanTest_nativePrintBoolean
>  >  > 	(JNIEnv *env, jclass c, jboolean b)
>  >  > {
>  >  > 	printf("nativePrintBoolean: %d\n", b);
>  >  > }
>  >  >
>  >  > JNIEXPORT void JNICALL Java_NativeBooleanTest_nativePrintBooleanAsInt
>  >  > 	(JNIEnv *env, jclass c, jint b)
>  >  > {
>  >  > 	printf("nativePrintBooleanAsInt: %d\n", b);
>  >  > }
>  >  >
>  >  > [...]

> Err, *why* are you doing this weird thing, anyway?  Why not pass the
> correct type?

Quite. javah or equivalent will generate a function prototype for 
nativeBooleanPrintAsInt() with 'jboolean b', not 'jint b'. Changing the type 
of a parameter and expecting the results to remain the same is, well, 
excessively optimistic.

Chris

-- 
Chris Gray        /k/ Embedded Java Solutions      BE0503765045
Embedded & Mobile Java, OSGi    http://www.k-embedded-java.com/
chris.gray@kiffer.be                             +32 3 216 0369

See us at Embedded World 2007 in Nürnberg February 13-15, at
the DSP Valley stand 12-555


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]