diff --git a/src/interpret.cpp b/src/interpret.cpp index da3e6c7853..543363a7d3 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -2823,7 +2823,7 @@ pushArguments(Thread* t, object this_, const char* spec, break; case 'F': { - pushFloat(t, arguments[index++].d); + pushFloat(t, arguments[index++].f); } break; default: diff --git a/test/JNI.java b/test/JNI.java index dc24da9b8f..b4e93c0f75 100644 --- a/test/JNI.java +++ b/test/JNI.java @@ -7,6 +7,18 @@ public class JNI { if (! v) throw new RuntimeException(); } + private static float echo(float f) { + return f; + } + + private static native float doEcho(float f); + + private static double echo(double f) { + return f; + } + + private static native double doEcho(double f); + private static native double addDoubles (double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, @@ -40,5 +52,8 @@ public class JNI { (1.0f, 2.0d, 3.0f, 4.0d, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0d, 17.0f, 18.0f, 19.0f, 20.0f) == 210.0d); + + expect(doEcho(42.0f) == 42.0f); + expect(doEcho(42.0d) == 42.0d); } } diff --git a/test/jni.cpp b/test/jni.cpp index 8c1ea91f05..fe174edec9 100644 --- a/test/jni.cpp +++ b/test/jni.cpp @@ -37,6 +37,26 @@ Java_JNI_addMix + a14 + a15 + a16 + a17 + a18 + a19 + a20; } +extern "C" JNIEXPORT jfloat JNICALL +Java_JNI_doEcho__F(JNIEnv* e, jclass c, jfloat f) +{ + jvalue value; + value.f = f; + jvalue array[] = { value }; + return e->CallStaticFloatMethodA + (c, e->GetStaticMethodID(c, "echo", "(F)F"), array); +} + +extern "C" JNIEXPORT jdouble JNICALL +Java_JNI_doEcho__D(JNIEnv* e, jclass c, jdouble f) +{ + jvalue value; + value.d = f; + jvalue array[] = { value }; + return e->CallStaticDoubleMethodA + (c, e->GetStaticMethodID(c, "echo", "(D)D"), array); +} + extern "C" JNIEXPORT jobject JNICALL Java_Buffers_allocateNative(JNIEnv* e, jclass, jint capacity) {