JNI bug?

Chris Gray chris.gray@kiffer.be
Mon Jan 29 18:30:00 GMT 2007


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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /