fix Call[Static]<type>MethodA float argument marshalling

This commit is contained in:
Joel Dice 2012-10-05 10:56:07 -06:00
parent f8d3494b1c
commit 45073db421
3 changed files with 36 additions and 1 deletions

View File

@ -2823,7 +2823,7 @@ pushArguments(Thread* t, object this_, const char* spec,
break; break;
case 'F': { case 'F': {
pushFloat(t, arguments[index++].d); pushFloat(t, arguments[index++].f);
} break; } break;
default: default:

View File

@ -7,6 +7,18 @@ public class JNI {
if (! v) throw new RuntimeException(); 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 private static native double addDoubles
(double a1, double a2, double a3, double a4, double a5, double a6, (double a1, double a2, double a3, double a4, double a5, double a6,
double a7, double a8, double a9, double a10, double a11, double a12, 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, (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) 12.0f, 13.0f, 14.0f, 15.0f, 16.0d, 17.0f, 18.0f, 19.0f, 20.0f)
== 210.0d); == 210.0d);
expect(doEcho(42.0f) == 42.0f);
expect(doEcho(42.0d) == 42.0d);
} }
} }

View File

@ -37,6 +37,26 @@ Java_JNI_addMix
+ a14 + a15 + a16 + a17 + a18 + a19 + a20; + 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 extern "C" JNIEXPORT jobject JNICALL
Java_Buffers_allocateNative(JNIEnv* e, jclass, jint capacity) Java_Buffers_allocateNative(JNIEnv* e, jclass, jint capacity)
{ {