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?


Chris Gray wrote:
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.

Yes, the code definitely looks wrong. But I don't know if there should be an automatic cast.
Anyway, it works with a Sun JRE, so we're stuck with the old discussion: Do we want to add support for erroneous code just to be consistent with a RE? There are good reasons for and good reasons against it...



Marco



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