A JNI problem where GCJ isn't doing the same as a Sun JDK:

public class NativeBooleanTest
{
    public static void main(String[] args)
    {
        System.loadLibrary("nativeBoolean");
        nativePrintBoolean(false);
        nativePrintBoolean(true);
        nativePrintBooleanAsInt(false);
        nativePrintBooleanAsInt(true);
    }

    private static native void nativePrintBoolean(boolean b);
    private static native void nativePrintBooleanAsInt(boolean b);
}

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);
}


On a sun JVM, the output will be:
nativePrintBoolean: 0
nativePrintBoolean: 1
nativePrintBooleanAsInt: 0
nativePrintBooleanAsInt: 1

GCJ will print something like:
nativePrintBoolean: 0
nativePrintBoolean: 1
nativePrintBooleanAsInt: 10084864 
nativePrintBooleanAsInt: 10084865


-- 
           Summary: [jni] Different behaviour than a Sun JRE
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mtrudel at gmx dot ch


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30673

Reply via email to