From 22c8a9aa841114765daf3d1e61b7341a0e0b356c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=BCtz?= Date: Sun, 22 Sep 2024 01:02:19 +0200 Subject: [PATCH] Increase test coverage to 93% --- README.md | 25 +- java_testcode/FieldTests.class | Bin 2223 -> 2226 bytes java_testcode/MethodCalls$NvChild.class | Bin 5762 -> 5762 bytes java_testcode/MethodCalls.class | Bin 9292 -> 9292 bytes java_testcode/RegisterTest.class | Bin 0 -> 377 bytes java_testcode/RegisterTest.java | 15 + src/lib.rs | 677 ++++++++++++++++++++---- tests/locals.rs | 25 + tests/register_natives.rs | 108 ++++ 9 files changed, 726 insertions(+), 124 deletions(-) create mode 100644 java_testcode/RegisterTest.class create mode 100644 java_testcode/RegisterTest.java create mode 100644 tests/locals.rs create mode 100644 tests/register_natives.rs diff --git a/README.md b/README.md index bb41dc9..3ca6510 100644 --- a/README.md +++ b/README.md @@ -158,22 +158,31 @@ This feature enables assertions in the code. This is useful for debugging and te These checks will cause a big performance hit and should not be used in production builds. I would not even recommend using this feature for normal debugging builds -unless you are specifically debugging issues that occur in relation to the JNI interface. -There is no need to enable this feature when you are just debugging a problem that occurs in pure rust. +unless you are specifically debugging issues that occur in relation to UB with the JNI interface. +There is no need to enable this feature when you are just debugging a problem that occurs in pure rust code. + +Enabling this feature for automated unit/integration tests that perform complicated JNI calls can be a good idea if you +can tolerate the performance penalty of enabling this feature. +Enabling this feature for benchmarks is not recommended as it falsifies the results of the benchmark. This feature should NOT be used with the jvm launch option `-Xcheck:jni` -as the assertions contain calls to `env.ExceptionCheck()` which will fool the JVM into thinking -that your user code checks for exceptions, which it may not do. +as the assertions contain calls to `env.ExceptionCheck()` before nearly every normal call to the jvm, +which will fool the JVM into thinking that your user code checks for exceptions, which it may not do. +It will also generate many false negatives as some 'assertion' code does not call `env.ExceptionCheck()` +as the only realistic scenario for some calls that are made to fail is for the JVM to run out of memory. I recommend using this feature before or after you have tested your code with `-Xcheck:jni` depending on what problem your troubleshooting. The assertions are generally much better at detecting things like null pointers or invalid parameters than the JVM checks, while the JVM checks are able to catch missing exception checks or JVM Local Stack overflows better. -Since asserts are implemented using unwinding panics the panics can be caught. -It is not recommended to continue or try to "recover" from this as the -assertions do NOT perform cleanup actions when a panic occurs so you will leak JVM memory. -I recommend aborting the processes on such a panic as such a panic only occurs if the rust code had triggered UB in the JVM. +The asserts are implemented using rust panics. +If you compile your project with unwinding panics the panics can be caught. +It is not recommended to continue or try to "recover" from these panics as the +assertions do NOT perform cleanup actions when a panic occurs, so you will leak JVM locals or leave the JVM in an +otherwise unrecoverable state. I recommend aborting the processes on such a panic as such a panic only occurs, +if the rust code had triggered UB in the JVM in the absence of the assertions. This can either be done by calling abort when "catching" the panic or compiling your rust code with panic=abort +if you do not need to catch panics anywhere in your rust code. ### Further Info ### Variadic up-calls diff --git a/java_testcode/FieldTests.class b/java_testcode/FieldTests.class index c3807b2cdeea81afb031bc1b960113c365c24ccb..fa69e67aa4c1d29469538c802be0cb630435c0ea 100644 GIT binary patch literal 2226 zcmah~T~`}b6x~CHWF`y=1p=XjuUa*vwpi?k2(1(_Efr`rwA$KgCdmkaki>jcvHk+z ztS>Ho*Jl%;YuUAYP@numzN!1%VG_FN(k$kjd(S;{XP9B6Z5{9l$dofcf{N^@c}*z;9d|GRt?-2|B__%g!7gr0xv^OdA@57{#VlX6R+4$AkXv`EwJO&Gx!s~$iyEmS48{)8 zOVEYw=Sbm|kPB4u4iTChdeCI-Ve-%Ai}~7B4Zir~T@CtTDMt+9m3+}ztM6o-%DSz} z(R1~kGPCSlPD6L9W@ooo?Xp@V`x-hcPSs(J#$2{=xMMI?s#mg3GB0$5+eMud7A#!D zf`vEnvV|GEYT+$RTA0Nd3v)PY;R>cKT*Y|{Z{rOM^SBs5*}`XFg9h6)rfQXZabuyL zFXSAq9QHufe8oZ)H4CrHCRNleJi_Mzd|_c1U$O?5cb609PRnPic+B2=tTB2Cm)ZOl zcZ{4C#IFeAxFAjl;@1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9h0OSIDnY!_W&{c<>x=cU;=Wl^RC3abp{k z+ep7OG;4j{fW#eTs+Vva^SnpPIAO(64HH$D z%^cvj8XkRzSoB9kBXvBg;YoDyt2&<4kc}>WQ%AN2H@f(B9c~TF(ZxEJYgo0NI#vlu zXX_ZPVJ?xYW3Gk;{x=Z|!;$#V*T$eMLD)UW&@4vS?c@e5OW5s+F0wvhuh({1sIb?k zv#eOy>rdoZIsx7Usal%V0zVGzR7p4bshLw4WS!1aEm!$A!Me`yOYoR=D`E)Gc;A1C zVSI~o_<^%FF@j(D)qKh*U5MJ_>QCH>!TOth?!h;nT6`9gh~KFY`Q?Q=K2P{$`M7+R z3TOm6jbIj4(ugi;M42>uwK+#60+*?@D?FK3d4jI- z^rWcHQ7Uqbg}+YZH^{*_u}%=vBxg;rH_hAoCg#Y~eZD=yE#%0Dh0k{ot(ub#3=_fs xB6mu$yrP;&g5(+*UIEHlWSvg2_Di70%^h*{{V;O$k6}* diff --git a/java_testcode/MethodCalls$NvChild.class b/java_testcode/MethodCalls$NvChild.class index cbf7c581f4efd08a1a468c1c7f3353b0ad66677e..cc3b1420fac212162e8fa5875a3ec16de976751a 100644 GIT binary patch literal 5762 zcma);X?R>!8OQ&(NjfLf+hm%gDYOB)Nhc|7nxshE074Q!RS>jn%Blh?dzWZhT0j96C_5;t3iv!OAKX5;eh~eiImgU7cX=K@WNz^I}@ZBVuWXAUdzAtc(z`X+Z3EVI6fWU(S4+-oN*e$R} zV6VWqzz+m|C@>+gPhh{m!vY5c4hlRX@TkCJ0zVS?vB2X3PY66I@DqWb3j9pqDS@X2 zo=Ma}m2TbWpt`p(=sBogoAbSOqr(GU@yzT%o{_r29sb5bZt!%k zw6!p}EEwpZG@X$IJF(M2b2_tjTXrnlp3nM2?du1&d0R@|;mj@vv!XKlWNM15E9K<+ zP3hJ!Hk`@AX0osklFC{aMOE;D#4JA@CGLw<&tN}2g+kuT`jZXu1)Sp`^h7%w^(fZd zsN{HmnJr&h&yJF37Sj_9>q-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8^m>5Vu9=A QIjy+zUg6~PTY)tFAFvQPS^xk5 diff --git a/java_testcode/RegisterTest.class b/java_testcode/RegisterTest.class new file mode 100644 index 0000000000000000000000000000000000000000..7a027177810ede70613b3501b6362df1f4215672 GIT binary patch literal 377 zcmZ8cyG{c!5S+bd&Nwe1B}E!^P>_Z$hz3LzfkYyD-(j5`9T(~1@LyC!6np?5g;+Zh zK{PYo*_qw-*Z0RKfJ=-7VhjW#3>_S%I7)F$NUls{>@^|G&z=a;&FWbb`ZLq$`^`(C z+l4A>RwAp{mN3d^OZBQIwQ8!#+_t8vraqV7I_i|Ft{2`Z=BrIx>O14o!$)12wdHBt zyKoaE5~LCW2M#1b{ {} +pub trait JType: private::Sealed+Into+Clone+Copy { + + /// + /// Returns a single character that equals the type's JNI signature. + /// + /// Boolean -> Z + /// Byte -> B + /// Short -> S + /// Char -> C + /// Int -> I + /// Long -> J + /// Float -> F + /// Double -> D + /// any java.lang.Object -> L + /// + /// + fn jtype_id() -> char; +} impl private::Sealed for jobject {} -impl Jtype for jobject {} +impl JType for jobject { + #[inline(always)] + fn jtype_id() -> char { + 'L' + } +} impl private::Sealed for jboolean {} -impl Jtype for jboolean {} +impl JType for jboolean { + + #[inline(always)] + fn jtype_id() -> char { + 'Z' + } +} impl private::Sealed for jbyte {} -impl Jtype for jbyte {} +impl JType for jbyte { + #[inline(always)] + fn jtype_id() -> char { + 'B' + } +} impl private::Sealed for jshort {} -impl Jtype for jshort {} +impl JType for jshort { + #[inline(always)] + fn jtype_id() -> char { + 'S' + } +} impl private::Sealed for jchar {} -impl Jtype for jchar {} +impl JType for jchar { + #[inline(always)] + fn jtype_id() -> char { + 'C' + } +} impl private::Sealed for jint {} -impl Jtype for jint {} +impl JType for jint { + #[inline(always)] + fn jtype_id() -> char { + 'I' + } +} impl private::Sealed for jlong {} -impl Jtype for jlong {} +impl JType for jlong { + #[inline(always)] + fn jtype_id() -> char { + 'J' + } +} impl private::Sealed for jfloat {} -impl Jtype for jfloat {} +impl JType for jfloat { + #[inline(always)] + fn jtype_id() -> char { + 'F' + } +} impl private::Sealed for jdouble {} -impl Jtype for jdouble {} +impl JType for jdouble { + #[inline(always)] + fn jtype_id() -> char { + 'D' + } +} #[repr(C)] pub union jtype { @@ -607,35 +670,41 @@ impl JNIEnv { self.jni:: jobject>(28)(self.vtable, clazz, constructor) } - pub unsafe fn NewObject1(&self, clazz: jclass, constructor: jmethodID, arg1: A) -> jobject { + pub unsafe fn NewObject1(&self, clazz: jclass, constructor: jmethodID, arg1: A) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("NewObject"); self.check_no_exception("NewObject"); assert!(!constructor.is_null(), "NewObject constructor is null"); self.check_is_class("NewObject", clazz); + self.check_parameter_types_constructor("NewObject", clazz, constructor, arg1, 0, 1); } self.jni:: jobject>(28)(self.vtable, clazz, constructor, arg1) } - pub unsafe fn NewObject2(&self, clazz: jclass, constructor: jmethodID, arg1: A, arg2: B) -> jobject { + pub unsafe fn NewObject2(&self, clazz: jclass, constructor: jmethodID, arg1: A, arg2: B) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("NewObject"); self.check_no_exception("NewObject"); assert!(!constructor.is_null(), "NewObject constructor is null"); self.check_is_class("NewObject", clazz); + self.check_parameter_types_constructor("NewObject", clazz, constructor, arg1, 0, 2); + self.check_parameter_types_constructor("NewObject", clazz, constructor, arg2, 1, 2); } self.jni:: jobject>(28)(self.vtable, clazz, constructor, arg1, arg2) } - pub unsafe fn NewObject3(&self, clazz: jclass, constructor: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { + pub unsafe fn NewObject3(&self, clazz: jclass, constructor: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("NewObject"); self.check_no_exception("NewObject"); assert!(!constructor.is_null(), "NewObject constructor is null"); self.check_is_class("NewObject", clazz); + self.check_parameter_types_constructor("NewObject", clazz, constructor, arg1, 0, 3); + self.check_parameter_types_constructor("NewObject", clazz, constructor, arg2, 1, 3); + self.check_parameter_types_constructor("NewObject", clazz, constructor, arg3, 2, 3); } self.jni:: jobject>(28)(self.vtable, clazz, constructor, arg1, arg2, arg3) } @@ -920,34 +989,40 @@ impl JNIEnv { } - pub unsafe fn CallVoidMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) { + pub unsafe fn CallVoidMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) { #[cfg(feature = "asserts")] { self.check_not_critical("CallVoidMethod"); self.check_no_exception("CallVoidMethod"); self.check_return_type_object("CallVoidMethod", obj, methodID, "void"); + self.check_parameter_types_object("CallVoidMethod", obj, methodID, arg1, 0, 1); } self.jni::(61)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallVoidMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) { + pub unsafe fn CallVoidMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) { #[cfg(feature = "asserts")] { self.check_not_critical("CallVoidMethod"); self.check_no_exception("CallVoidMethod"); self.check_return_type_object("CallVoidMethod", obj, methodID, "void"); + self.check_parameter_types_object("CallVoidMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallVoidMethod", obj, methodID, arg2, 1, 2); } self.jni::(61)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallVoidMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) { + pub unsafe fn CallVoidMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) { #[cfg(feature = "asserts")] { self.check_not_critical("CallVoidMethod"); self.check_no_exception("CallVoidMethod"); self.check_return_type_object("CallVoidMethod", obj, methodID, "void"); + self.check_parameter_types_object("CallVoidMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallVoidMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallVoidMethod", obj, methodID, arg3, 2, 3); } self.jni::(61)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -973,34 +1048,40 @@ impl JNIEnv { } - pub unsafe fn CallObjectMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jobject { + pub unsafe fn CallObjectMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallObjectMethod"); self.check_no_exception("CallObjectMethod"); self.check_return_type_object("CallObjectMethod", obj, methodID, "object"); + self.check_parameter_types_object("CallObjectMethod", obj, methodID, arg1, 0, 1); } self.jni:: jobject>(34)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallObjectMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jobject { + pub unsafe fn CallObjectMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallObjectMethod"); self.check_no_exception("CallObjectMethod"); self.check_return_type_object("CallObjectMethod", obj, methodID, "object"); + self.check_parameter_types_object("CallObjectMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallObjectMethod", obj, methodID, arg2, 1, 2); } self.jni:: jobject>(34)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallObjectMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { + pub unsafe fn CallObjectMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallObjectMethod"); self.check_no_exception("CallObjectMethod"); self.check_return_type_object("CallObjectMethod", obj, methodID, "object"); + self.check_parameter_types_object("CallObjectMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallObjectMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallObjectMethod", obj, methodID, arg3, 2, 3); } self.jni:: jobject>(34)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1026,34 +1107,40 @@ impl JNIEnv { } - pub unsafe fn CallBooleanMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jboolean { + pub unsafe fn CallBooleanMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallBooleanMethod"); self.check_no_exception("CallBooleanMethod"); self.check_return_type_object("CallBooleanMethod", obj, methodID, "boolean"); + self.check_parameter_types_object("CallBooleanMethod", obj, methodID, arg1, 0, 1); } self.jni:: jboolean>(37)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallBooleanMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jboolean { + pub unsafe fn CallBooleanMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallBooleanMethod"); self.check_no_exception("CallBooleanMethod"); self.check_return_type_object("CallBooleanMethod", obj, methodID, "boolean"); + self.check_parameter_types_object("CallBooleanMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallBooleanMethod", obj, methodID, arg2, 1, 2); } self.jni:: jboolean>(37)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallBooleanMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jboolean { + pub unsafe fn CallBooleanMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallBooleanMethod"); self.check_no_exception("CallBooleanMethod"); self.check_return_type_object("CallBooleanMethod", obj, methodID, "boolean"); + self.check_parameter_types_object("CallBooleanMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallBooleanMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallBooleanMethod", obj, methodID, arg3, 2, 3); } self.jni:: jboolean>(37)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1079,34 +1166,40 @@ impl JNIEnv { } - pub unsafe fn CallByteMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jbyte { + pub unsafe fn CallByteMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallByteMethod1"); self.check_no_exception("CallByteMethod1"); self.check_return_type_object("CallByteMethod1", obj, methodID, "byte"); + self.check_parameter_types_object("CallByteMethod1", obj, methodID, arg1, 0, 1); } self.jni:: jbyte>(40)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallByteMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jbyte { + pub unsafe fn CallByteMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallByteMethod2"); self.check_no_exception("CallByteMethod2"); self.check_return_type_object("CallByteMethod2", obj, methodID, "byte"); + self.check_parameter_types_object("CallByteMethod2", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallByteMethod2", obj, methodID, arg2, 1, 2); } self.jni:: jbyte>(40)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallByteMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jbyte { + pub unsafe fn CallByteMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallByteMethod3"); self.check_no_exception("CallByteMethod3"); self.check_return_type_object("CallByteMethod3", obj, methodID, "byte"); + self.check_parameter_types_object("CallByteMethod3", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallByteMethod3", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallByteMethod3", obj, methodID, arg3, 2, 3); } self.jni:: jbyte>(40)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1132,34 +1225,40 @@ impl JNIEnv { } - pub unsafe fn CallCharMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jchar { + pub unsafe fn CallCharMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallCharMethod"); self.check_no_exception("CallCharMethod"); self.check_return_type_object("CallCharMethod", obj, methodID, "char"); + self.check_parameter_types_object("CallCharMethod", obj, methodID, arg1, 0, 1); } self.jni:: jchar>(43)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallCharMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jchar { + pub unsafe fn CallCharMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallCharMethod"); self.check_no_exception("CallCharMethod"); self.check_return_type_object("CallCharMethod", obj, methodID, "char"); + self.check_parameter_types_object("CallCharMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallCharMethod", obj, methodID, arg2, 1, 2); } self.jni:: jchar>(43)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallCharMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jchar { + pub unsafe fn CallCharMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallCharMethod"); self.check_no_exception("CallCharMethod"); self.check_return_type_object("CallCharMethod", obj, methodID, "char"); + self.check_parameter_types_object("CallCharMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallCharMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallCharMethod", obj, methodID, arg3, 2, 3); } self.jni:: jchar>(43)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1185,34 +1284,40 @@ impl JNIEnv { } - pub unsafe fn CallShortMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jshort { + pub unsafe fn CallShortMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallShortMethod"); self.check_no_exception("CallShortMethod"); self.check_return_type_object("CallShortMethod", obj, methodID, "short"); + self.check_parameter_types_object("CallShortMethod", obj, methodID, arg1, 0, 1); } self.jni:: jshort>(46)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallShortMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jshort { + pub unsafe fn CallShortMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallShortMethod"); self.check_no_exception("CallShortMethod"); self.check_return_type_object("CallShortMethod", obj, methodID, "short"); + self.check_parameter_types_object("CallShortMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallShortMethod", obj, methodID, arg2, 1, 2); } self.jni:: jshort>(46)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallShortMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jshort { + pub unsafe fn CallShortMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallShortMethod"); self.check_no_exception("CallShortMethod"); self.check_return_type_object("CallShortMethod", obj, methodID, "short"); + self.check_parameter_types_object("CallShortMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallShortMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallShortMethod", obj, methodID, arg3, 2, 3); } self.jni:: jshort>(46)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1238,34 +1343,40 @@ impl JNIEnv { } - pub unsafe fn CallIntMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jint { + pub unsafe fn CallIntMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallIntMethod"); self.check_no_exception("CallIntMethod"); self.check_return_type_object("CallIntMethod", obj, methodID, "int"); + self.check_parameter_types_object("CallIntMethod", obj, methodID, arg1, 0, 1); } self.jni:: jint>(49)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallIntMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jint { + pub unsafe fn CallIntMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallIntMethod"); self.check_no_exception("CallIntMethod"); self.check_return_type_object("CallIntMethod", obj, methodID, "int"); + self.check_parameter_types_object("CallIntMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallIntMethod", obj, methodID, arg2, 1, 2); } self.jni:: jint>(49)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallIntMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jint { + pub unsafe fn CallIntMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallIntMethod"); self.check_no_exception("CallIntMethod"); self.check_return_type_object("CallIntMethod", obj, methodID, "int"); + self.check_parameter_types_object("CallIntMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallIntMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallIntMethod", obj, methodID, arg3, 2, 3); } self.jni:: jint>(49)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1291,34 +1402,40 @@ impl JNIEnv { } - pub unsafe fn CallLongMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jlong { + pub unsafe fn CallLongMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallLongMethod"); self.check_no_exception("CallLongMethod"); self.check_return_type_object("CallLongMethod", obj, methodID, "long"); + self.check_parameter_types_object("CallLongMethod", obj, methodID, arg1, 0, 1); } self.jni:: jlong>(52)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallLongMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jlong { + pub unsafe fn CallLongMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallLongMethod"); self.check_no_exception("CallLongMethod"); self.check_return_type_object("CallLongMethod", obj, methodID, "long"); + self.check_parameter_types_object("CallLongMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallLongMethod", obj, methodID, arg2, 1, 2); } self.jni:: jlong>(52)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallLongMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jlong { + pub unsafe fn CallLongMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallLongMethod"); self.check_no_exception("CallLongMethod"); self.check_return_type_object("CallLongMethod", obj, methodID, "long"); + self.check_parameter_types_object("CallLongMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallLongMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallLongMethod", obj, methodID, arg3, 2, 3); } self.jni:: jlong>(52)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1344,34 +1461,40 @@ impl JNIEnv { } - pub unsafe fn CallFloatMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jfloat { + pub unsafe fn CallFloatMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallFloatMethod"); self.check_no_exception("CallFloatMethod"); self.check_return_type_object("CallFloatMethod", obj, methodID, "float"); + self.check_parameter_types_object("CallFloatMethod", obj, methodID, arg1, 0, 1); } self.jni:: jfloat>(55)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallFloatMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jfloat { + pub unsafe fn CallFloatMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallFloatMethod"); self.check_no_exception("CallFloatMethod"); self.check_return_type_object("CallFloatMethod", obj, methodID, "float"); + self.check_parameter_types_object("CallFloatMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallFloatMethod", obj, methodID, arg2, 1, 2); } self.jni:: jfloat>(55)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallFloatMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jfloat { + pub unsafe fn CallFloatMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallFloatMethod"); self.check_no_exception("CallFloatMethod"); self.check_return_type_object("CallFloatMethod", obj, methodID, "float"); + self.check_parameter_types_object("CallFloatMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallFloatMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallFloatMethod", obj, methodID, arg3, 2, 3); } self.jni:: jfloat>(55)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1397,34 +1520,40 @@ impl JNIEnv { } - pub unsafe fn CallDoubleMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jdouble { + pub unsafe fn CallDoubleMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallDoubleMethod"); self.check_no_exception("CallDoubleMethod"); self.check_return_type_object("CallDoubleMethod", obj, methodID, "double"); + self.check_parameter_types_object("CallDoubleMethod", obj, methodID, arg1, 0, 1); } self.jni:: jdouble>(58)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallDoubleMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jdouble { + pub unsafe fn CallDoubleMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallDoubleMethod"); self.check_no_exception("CallDoubleMethod"); self.check_return_type_object("CallDoubleMethod", obj, methodID, "double"); + self.check_parameter_types_object("CallDoubleMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallDoubleMethod", obj, methodID, arg2, 1, 2); } self.jni:: jdouble>(58)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallDoubleMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jdouble { + pub unsafe fn CallDoubleMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallDoubleMethod"); self.check_no_exception("CallDoubleMethod"); self.check_return_type_object("CallDoubleMethod", obj, methodID, "double"); + self.check_parameter_types_object("CallDoubleMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallDoubleMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallDoubleMethod", obj, methodID, arg3, 2, 3); } self.jni:: jdouble>(58)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -1453,37 +1582,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualVoidMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) { + pub unsafe fn CallNonvirtualVoidMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualVoidMethod"); self.check_no_exception("CallNonvirtualVoidMethod"); self.check_return_type_object("CallNonvirtualVoidMethod", obj, methodID, "void"); self.check_is_class("CallNonvirtualVoidMethod", class); + self.check_parameter_types_object("CallNonvirtualVoidMethod", obj, methodID, arg1, 0, 1); } self.jni::(91)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualVoidMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) { + pub unsafe fn CallNonvirtualVoidMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualVoidMethod"); self.check_no_exception("CallNonvirtualVoidMethod"); self.check_return_type_object("CallNonvirtualVoidMethod", obj, methodID, "void"); self.check_is_class("CallNonvirtualVoidMethod", class); + self.check_parameter_types_object("CallNonvirtualVoidMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualVoidMethod", obj, methodID, arg2, 1, 2); } self.jni::(91)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualVoidMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) { + pub unsafe fn CallNonvirtualVoidMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualVoidMethod"); self.check_no_exception("CallNonvirtualVoidMethod"); self.check_return_type_object("CallNonvirtualVoidMethod", obj, methodID, "void"); self.check_is_class("CallNonvirtualVoidMethod", class); + self.check_parameter_types_object("CallNonvirtualVoidMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualVoidMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualVoidMethod", obj, methodID, arg3, 2, 3); } self.jni::(91)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1511,37 +1646,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualObjectMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jobject { + pub unsafe fn CallNonvirtualObjectMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualObjectMethod"); self.check_no_exception("CallNonvirtualObjectMethod"); self.check_return_type_object("CallNonvirtualObjectMethod", obj, methodID, "object"); self.check_is_class("CallNonvirtualObjectMethod", class); + self.check_parameter_types_object("CallNonvirtualObjectMethod", obj, methodID, arg1, 0, 1); } self.jni:: jobject>(64)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualObjectMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jobject { + pub unsafe fn CallNonvirtualObjectMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualObjectMethod"); self.check_no_exception("CallNonvirtualObjectMethod"); self.check_return_type_object("CallNonvirtualObjectMethod", obj, methodID, "object"); self.check_is_class("CallNonvirtualObjectMethod", class); + self.check_parameter_types_object("CallNonvirtualObjectMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualObjectMethod", obj, methodID, arg2, 1, 2); } self.jni:: jobject>(64)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualObjectMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { + pub unsafe fn CallNonvirtualObjectMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualObjectMethod"); self.check_no_exception("CallNonvirtualObjectMethod"); self.check_return_type_object("CallNonvirtualObjectMethod", obj, methodID, "object"); self.check_is_class("CallNonvirtualObjectMethod", class); + self.check_parameter_types_object("CallNonvirtualObjectMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualObjectMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualObjectMethod", obj, methodID, arg3, 2, 3); } self.jni:: jobject>(64)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1569,37 +1710,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualBooleanMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jboolean { + pub unsafe fn CallNonvirtualBooleanMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualBooleanMethod"); self.check_no_exception("CallNonvirtualBooleanMethod"); self.check_return_type_object("CallNonvirtualBooleanMethod", obj, methodID, "boolean"); self.check_is_class("CallNonvirtualBooleanMethod", class); + self.check_parameter_types_object("CallNonvirtualBooleanMethod", obj, methodID, arg1, 0, 1); } self.jni:: jboolean>(67)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualBooleanMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jboolean { + pub unsafe fn CallNonvirtualBooleanMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualBooleanMethod"); self.check_no_exception("CallNonvirtualBooleanMethod"); self.check_return_type_object("CallNonvirtualBooleanMethod", obj, methodID, "boolean"); self.check_is_class("CallNonvirtualBooleanMethod", class); + self.check_parameter_types_object("CallNonvirtualBooleanMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualBooleanMethod", obj, methodID, arg2, 1, 2); } self.jni:: jboolean>(67)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualBooleanMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jboolean { + pub unsafe fn CallNonvirtualBooleanMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualBooleanMethod"); self.check_no_exception("CallNonvirtualBooleanMethod"); self.check_return_type_object("CallNonvirtualBooleanMethod", obj, methodID, "boolean"); self.check_is_class("CallNonvirtualBooleanMethod", class); + self.check_parameter_types_object("CallNonvirtualBooleanMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualBooleanMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualBooleanMethod", obj, methodID, arg3, 2, 3); } self.jni:: jboolean>(67)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1627,37 +1774,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualByteMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jbyte { + pub unsafe fn CallNonvirtualByteMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualByteMethod"); self.check_no_exception("CallNonvirtualByteMethod"); self.check_return_type_object("CallNonvirtualByteMethod", obj, methodID, "byte"); self.check_is_class("CallNonvirtualByteMethod", class); + self.check_parameter_types_object("CallNonvirtualByteMethod", obj, methodID, arg1, 0, 1); } self.jni:: jbyte>(70)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualByteMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jbyte { + pub unsafe fn CallNonvirtualByteMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualByteMethod"); self.check_no_exception("CallNonvirtualByteMethod"); self.check_return_type_object("CallNonvirtualByteMethod", obj, methodID, "byte"); self.check_is_class("CallNonvirtualByteMethod", class); + self.check_parameter_types_object("CallNonvirtualByteMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualByteMethod", obj, methodID, arg2, 1, 2); } self.jni:: jbyte>(70)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualByteMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jbyte { + pub unsafe fn CallNonvirtualByteMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualByteMethod"); self.check_no_exception("CallNonvirtualByteMethod"); self.check_return_type_object("CallNonvirtualByteMethod", obj, methodID, "byte"); self.check_is_class("CallNonvirtualByteMethod", class); + self.check_parameter_types_object("CallNonvirtualByteMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualByteMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualByteMethod", obj, methodID, arg3, 2, 3); } self.jni:: jbyte>(70)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1685,37 +1838,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualCharMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jchar { + pub unsafe fn CallNonvirtualCharMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualCharMethod"); self.check_no_exception("CallNonvirtualCharMethod"); self.check_return_type_object("CallNonvirtualCharMethod", obj, methodID, "char"); self.check_is_class("CallNonvirtualCharMethod", class); + self.check_parameter_types_object("CallNonvirtualCharMethod", obj, methodID, arg1, 0, 1); } self.jni:: jchar>(73)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualCharMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jchar { + pub unsafe fn CallNonvirtualCharMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualCharMethod"); self.check_no_exception("CallNonvirtualCharMethod"); self.check_return_type_object("CallNonvirtualCharMethod", obj, methodID, "char"); self.check_is_class("CallNonvirtualCharMethod", class); + self.check_parameter_types_object("CallNonvirtualCharMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualCharMethod", obj, methodID, arg2, 1, 2); } self.jni:: jchar>(73)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualCharMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jchar { + pub unsafe fn CallNonvirtualCharMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualCharMethod"); self.check_no_exception("CallNonvirtualCharMethod"); self.check_return_type_object("CallNonvirtualCharMethod", obj, methodID, "char"); self.check_is_class("CallNonvirtualCharMethod", class); + self.check_parameter_types_object("CallNonvirtualCharMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualCharMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualCharMethod", obj, methodID, arg3, 2, 3); } self.jni:: jchar>(73)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1745,37 +1904,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualShortMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jshort { + pub unsafe fn CallNonvirtualShortMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualShortMethod"); self.check_no_exception("CallNonvirtualShortMethod"); self.check_return_type_object("CallNonvirtualShortMethod", obj, methodID, "short"); self.check_is_class("CallNonvirtualShortMethod", class); + self.check_parameter_types_object("CallNonvirtualShortMethod", obj, methodID, arg1, 0, 1); } self.jni:: jshort>(76)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualShortMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jshort { + pub unsafe fn CallNonvirtualShortMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualShortMethod"); self.check_no_exception("CallNonvirtualShortMethod"); self.check_return_type_object("CallNonvirtualShortMethod", obj, methodID, "short"); self.check_is_class("CallNonvirtualShortMethod", class); + self.check_parameter_types_object("CallNonvirtualShortMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualShortMethod", obj, methodID, arg2, 1, 2); } self.jni:: jshort>(76)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualShortMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jshort { + pub unsafe fn CallNonvirtualShortMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualShortMethod"); self.check_no_exception("CallNonvirtualShortMethod"); self.check_return_type_object("CallNonvirtualShortMethod", obj, methodID, "short"); self.check_is_class("CallNonvirtualShortMethod", class); + self.check_parameter_types_object("CallNonvirtualShortMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualShortMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualShortMethod", obj, methodID, arg3, 2, 3); } self.jni:: jshort>(76)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1803,37 +1968,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualIntMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jint { + pub unsafe fn CallNonvirtualIntMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualIntMethod"); self.check_no_exception("CallNonvirtualIntMethod"); self.check_return_type_object("CallNonvirtualIntMethod", obj, methodID, "int"); self.check_is_class("CallNonvirtualIntMethod", class); + self.check_parameter_types_object("CallNonvirtualIntMethod", obj, methodID, arg1, 0, 1); } self.jni:: jint>(79)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualIntMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jint { + pub unsafe fn CallNonvirtualIntMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualIntMethod"); self.check_no_exception("CallNonvirtualIntMethod"); self.check_return_type_object("CallNonvirtualIntMethod", obj, methodID, "int"); self.check_is_class("CallNonvirtualIntMethod", class); + self.check_parameter_types_object("CallNonvirtualIntMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualIntMethod", obj, methodID, arg2, 1, 2); } self.jni:: jint>(79)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualIntMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jint { + pub unsafe fn CallNonvirtualIntMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualIntMethod"); self.check_no_exception("CallNonvirtualIntMethod"); self.check_return_type_object("CallNonvirtualIntMethod", obj, methodID, "int"); self.check_is_class("CallNonvirtualIntMethod", class); + self.check_parameter_types_object("CallNonvirtualIntMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualIntMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualIntMethod", obj, methodID, arg3, 2, 3); } self.jni:: jint>(79)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1861,37 +2032,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualLongMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jlong { + pub unsafe fn CallNonvirtualLongMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualLongMethod"); self.check_no_exception("CallNonvirtualLongMethod"); self.check_return_type_object("CallNonvirtualLongMethod", obj, methodID, "long"); self.check_is_class("CallNonvirtualLongMethod", class); + self.check_parameter_types_object("CallNonvirtualLongMethod", obj, methodID, arg1, 0, 1); } self.jni:: jlong>(82)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualLongMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jlong { + pub unsafe fn CallNonvirtualLongMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualLongMethod"); self.check_no_exception("CallNonvirtualLongMethod"); self.check_return_type_object("CallNonvirtualLongMethod", obj, methodID, "long"); self.check_is_class("CallNonvirtualLongMethod", class); + self.check_parameter_types_object("CallNonvirtualLongMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualLongMethod", obj, methodID, arg2, 1, 2); } self.jni:: jlong>(82)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualLongMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jlong { + pub unsafe fn CallNonvirtualLongMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualLongMethod"); self.check_no_exception("CallNonvirtualLongMethod"); self.check_return_type_object("CallNonvirtualLongMethod", obj, methodID, "long"); self.check_is_class("CallNonvirtualLongMethod", class); + self.check_parameter_types_object("CallNonvirtualLongMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualLongMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualLongMethod", obj, methodID, arg3, 2, 3); } self.jni:: jlong>(82)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1919,37 +2096,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualFloatMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jfloat { + pub unsafe fn CallNonvirtualFloatMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualFloatMethod"); self.check_no_exception("CallNonvirtualFloatMethod"); self.check_return_type_object("CallNonvirtualFloatMethod", obj, methodID, "float"); self.check_is_class("CallNonvirtualFloatMethod", class); + self.check_parameter_types_object("CallNonvirtualFloatMethod", obj, methodID, arg1, 0, 1); } self.jni:: jfloat>(85)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualFloatMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jfloat { + pub unsafe fn CallNonvirtualFloatMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualFloatMethod"); self.check_no_exception("CallNonvirtualFloatMethod"); self.check_return_type_object("CallNonvirtualFloatMethod", obj, methodID, "float"); self.check_is_class("CallNonvirtualFloatMethod", class); + self.check_parameter_types_object("CallNonvirtualFloatMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualFloatMethod", obj, methodID, arg2, 1, 2); } self.jni:: jfloat>(85)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualFloatMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jfloat { + pub unsafe fn CallNonvirtualFloatMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualFloatMethod"); self.check_no_exception("CallNonvirtualFloatMethod"); self.check_return_type_object("CallNonvirtualFloatMethod", obj, methodID, "float"); self.check_is_class("CallNonvirtualFloatMethod", class); + self.check_parameter_types_object("CallNonvirtualFloatMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualFloatMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualFloatMethod", obj, methodID, arg3, 2, 3); } self.jni:: jfloat>(85)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -1977,37 +2160,43 @@ impl JNIEnv { } - pub unsafe fn CallNonvirtualDoubleMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jdouble { + pub unsafe fn CallNonvirtualDoubleMethod1(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualDoubleMethod"); self.check_no_exception("CallNonvirtualDoubleMethod"); self.check_return_type_object("CallNonvirtualDoubleMethod", obj, methodID, "double"); self.check_is_class("CallNonvirtualDoubleMethod", class); + self.check_parameter_types_object("CallNonvirtualDoubleMethod", obj, methodID, arg1, 0, 1); } self.jni:: jdouble>(88)(self.vtable, obj, class, methodID, arg1) } - pub unsafe fn CallNonvirtualDoubleMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jdouble { + pub unsafe fn CallNonvirtualDoubleMethod2(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualDoubleMethod"); self.check_no_exception("CallNonvirtualDoubleMethod"); self.check_return_type_object("CallNonvirtualDoubleMethod", obj, methodID, "double"); self.check_is_class("CallNonvirtualDoubleMethod", class); + self.check_parameter_types_object("CallNonvirtualDoubleMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_object("CallNonvirtualDoubleMethod", obj, methodID, arg2, 1, 2); } self.jni:: jdouble>(88)(self.vtable, obj, class, methodID, arg1, arg2) } - pub unsafe fn CallNonvirtualDoubleMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jdouble { + pub unsafe fn CallNonvirtualDoubleMethod3(&self, obj: jobject, class: jclass, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallNonvirtualDoubleMethod"); self.check_no_exception("CallNonvirtualDoubleMethod"); self.check_return_type_object("CallNonvirtualDoubleMethod", obj, methodID, "double"); self.check_is_class("CallNonvirtualDoubleMethod", class); + self.check_parameter_types_object("CallNonvirtualDoubleMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_object("CallNonvirtualDoubleMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_object("CallNonvirtualDoubleMethod", obj, methodID, arg3, 2, 3); } self.jni:: jdouble>(88)(self.vtable, obj, class, methodID, arg1, arg2, arg3) } @@ -2249,42 +2438,48 @@ impl JNIEnv { pub unsafe fn CallStaticVoidMethod0(&self, obj: jobject, methodID: jmethodID) { #[cfg(feature = "asserts")] { - self.check_not_critical("CallStaticObjectMethod"); - self.check_no_exception("CallStaticObjectMethod"); - self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "void"); + self.check_not_critical("CallStaticVoidMethod"); + self.check_no_exception("CallStaticVoidMethod"); + self.check_return_type_object("CallStaticVoidMethod", obj, methodID, "void"); } self.jni::(141)(self.vtable, obj, methodID) } - pub unsafe fn CallStaticVoidMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) { + pub unsafe fn CallStaticVoidMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) { #[cfg(feature = "asserts")] { - self.check_not_critical("CallStaticObjectMethod"); - self.check_no_exception("CallStaticObjectMethod"); - self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "void"); + self.check_not_critical("CallStaticVoidMethod"); + self.check_no_exception("CallStaticVoidMethod"); + self.check_return_type_object("CallStaticVoidMethod", obj, methodID, "void"); + self.check_parameter_types_static("CallStaticVoidMethod", obj, methodID, arg1, 0, 1); } self.jni::(141)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticVoidMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) { + pub unsafe fn CallStaticVoidMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) { #[cfg(feature = "asserts")] { - self.check_not_critical("CallStaticObjectMethod"); - self.check_no_exception("CallStaticObjectMethod"); - self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "void"); + self.check_not_critical("CallStaticVoidMethod"); + self.check_no_exception("CallStaticVoidMethod"); + self.check_return_type_object("CallStaticVoidMethod", obj, methodID, "void"); + self.check_parameter_types_static("CallStaticVoidMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticVoidMethod", obj, methodID, arg2, 1, 2); } self.jni::(141)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticVoidMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) { + pub unsafe fn CallStaticVoidMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) { #[cfg(feature = "asserts")] { - self.check_not_critical("CallStaticObjectMethod"); - self.check_no_exception("CallStaticObjectMethod"); - self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "void"); + self.check_not_critical("CallStaticVoidMethod"); + self.check_no_exception("CallStaticVoidMethod"); + self.check_return_type_object("CallStaticVoidMethod", obj, methodID, "void"); + self.check_parameter_types_static("CallStaticVoidMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticVoidMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticVoidMethod", obj, methodID, arg3, 2, 3); } self.jni::(141)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2310,34 +2505,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticObjectMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jobject { + pub unsafe fn CallStaticObjectMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticObjectMethod"); self.check_no_exception("CallStaticObjectMethod"); self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "object"); + self.check_parameter_types_static("CallStaticObjectMethod", obj, methodID, arg1, 0, 1); } self.jni:: jobject>(114)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticObjectMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jobject { + pub unsafe fn CallStaticObjectMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticObjectMethod"); self.check_no_exception("CallStaticObjectMethod"); self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "object"); + self.check_parameter_types_static("CallStaticObjectMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticObjectMethod", obj, methodID, arg2, 1, 2); } self.jni:: jobject>(114)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticObjectMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { + pub unsafe fn CallStaticObjectMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jobject { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticObjectMethod"); self.check_no_exception("CallStaticObjectMethod"); self.check_return_type_object("CallStaticObjectMethod", obj, methodID, "object"); + self.check_parameter_types_static("CallStaticObjectMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticObjectMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticObjectMethod", obj, methodID, arg3, 2, 3); } self.jni:: jobject>(114)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2363,34 +2564,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticBooleanMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jboolean { + pub unsafe fn CallStaticBooleanMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticBooleanMethod"); self.check_no_exception("CallStaticBooleanMethod"); self.check_return_type_object("CallStaticBooleanMethod", obj, methodID, "boolean"); + self.check_parameter_types_static("CallStaticBooleanMethod", obj, methodID, arg1, 0, 1); } self.jni:: jboolean>(117)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticBooleanMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jboolean { + pub unsafe fn CallStaticBooleanMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticBooleanMethod"); self.check_no_exception("CallStaticBooleanMethod"); self.check_return_type_object("CallStaticBooleanMethod", obj, methodID, "boolean"); + self.check_parameter_types_static("CallStaticBooleanMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticBooleanMethod", obj, methodID, arg2, 1, 2); } self.jni:: jboolean>(117)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticBooleanMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jboolean { + pub unsafe fn CallStaticBooleanMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jboolean { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticBooleanMethod"); self.check_no_exception("CallStaticBooleanMethod"); self.check_return_type_object("CallStaticBooleanMethod", obj, methodID, "boolean"); + self.check_parameter_types_static("CallStaticBooleanMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticBooleanMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticBooleanMethod", obj, methodID, arg3, 2, 3); } self.jni:: jboolean>(117)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2415,32 +2622,38 @@ impl JNIEnv { self.jni:: jbyte>(120)(self.vtable, obj, methodID) } - pub unsafe fn CallStaticByteMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jbyte { + pub unsafe fn CallStaticByteMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticByteMethod"); self.check_no_exception("CallStaticByteMethod"); self.check_return_type_object("CallStaticByteMethod", obj, methodID, "byte"); + self.check_parameter_types_static("CallStaticByteMethod", obj, methodID, arg1, 0, 1); } self.jni:: jbyte>(120)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticByteMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jbyte { + pub unsafe fn CallStaticByteMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticByteMethod"); self.check_no_exception("CallStaticByteMethod"); self.check_return_type_object("CallStaticByteMethod", obj, methodID, "byte"); + self.check_parameter_types_static("CallStaticByteMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticByteMethod", obj, methodID, arg2, 1, 2); } self.jni:: jbyte>(120)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticByteMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jbyte { + pub unsafe fn CallStaticByteMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jbyte { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticByteMethod"); self.check_no_exception("CallStaticByteMethod"); self.check_return_type_object("CallStaticByteMethod", obj, methodID, "byte"); + self.check_parameter_types_static("CallStaticByteMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticByteMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticByteMethod", obj, methodID, arg3, 2, 3); } self.jni:: jbyte>(120)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2466,34 +2679,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticCharMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jchar { + pub unsafe fn CallStaticCharMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticCharMethod"); self.check_no_exception("CallStaticCharMethod"); self.check_return_type_object("CallStaticCharMethod", obj, methodID, "char"); + self.check_parameter_types_static("CallStaticCharMethod", obj, methodID, arg1, 0, 1); } self.jni:: jchar>(123)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticCharMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jchar { + pub unsafe fn CallStaticCharMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticCharMethod"); self.check_no_exception("CallStaticCharMethod"); self.check_return_type_object("CallStaticCharMethod", obj, methodID, "char"); + self.check_parameter_types_static("CallStaticCharMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticCharMethod", obj, methodID, arg2, 1, 2); } self.jni:: jchar>(123)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticCharMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jchar { + pub unsafe fn CallStaticCharMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jchar { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticCharMethod"); self.check_no_exception("CallStaticCharMethod"); self.check_return_type_object("CallStaticCharMethod", obj, methodID, "char"); + self.check_parameter_types_static("CallStaticCharMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticCharMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticCharMethod", obj, methodID, arg3, 2, 3); } self.jni:: jchar>(123)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2519,34 +2738,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticShortMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jshort { + pub unsafe fn CallStaticShortMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticShortMethod"); self.check_no_exception("CallStaticShortMethod"); self.check_return_type_object("CallStaticShortMethod", obj, methodID, "short"); + self.check_parameter_types_static("CallStaticShortMethod", obj, methodID, arg1, 0, 1); } self.jni:: jshort>(126)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticShortMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jshort { + pub unsafe fn CallStaticShortMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticShortMethod"); self.check_no_exception("CallStaticShortMethod"); self.check_return_type_object("CallStaticShortMethod", obj, methodID, "short"); + self.check_parameter_types_static("CallStaticShortMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticShortMethod", obj, methodID, arg2, 1, 2); } self.jni:: jshort>(126)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticShortMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jshort { + pub unsafe fn CallStaticShortMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jshort { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticShortMethod"); self.check_no_exception("CallStaticShortMethod"); self.check_return_type_object("CallStaticShortMethod", obj, methodID, "short"); + self.check_parameter_types_static("CallStaticShortMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticShortMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticShortMethod", obj, methodID, arg3, 2, 3); } self.jni:: jshort>(126)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2572,34 +2797,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticIntMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jint { + pub unsafe fn CallStaticIntMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticIntMethod"); self.check_no_exception("CallStaticIntMethod"); self.check_return_type_object("CallStaticIntMethod", obj, methodID, "int"); + self.check_parameter_types_static("CallStaticIntMethod", obj, methodID, arg1, 0, 1); } self.jni:: jint>(129)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticIntMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jint { + pub unsafe fn CallStaticIntMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticIntMethod"); self.check_no_exception("CallStaticIntMethod"); self.check_return_type_object("CallStaticIntMethod", obj, methodID, "int"); + self.check_parameter_types_static("CallStaticIntMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticIntMethod", obj, methodID, arg2, 1, 2); } self.jni:: jint>(129)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticIntMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jint { + pub unsafe fn CallStaticIntMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jint { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticIntMethod"); self.check_no_exception("CallStaticIntMethod"); self.check_return_type_object("CallStaticIntMethod", obj, methodID, "int"); + self.check_parameter_types_static("CallStaticIntMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticIntMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticIntMethod", obj, methodID, arg3, 2, 3); } self.jni:: jint>(129)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2625,34 +2856,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticLongMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jlong { + pub unsafe fn CallStaticLongMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticLongMethod"); self.check_no_exception("CallStaticLongMethod"); self.check_return_type_object("CallStaticLongMethod", obj, methodID, "long"); + self.check_parameter_types_static("CallStaticLongMethod", obj, methodID, arg1, 0, 1); } self.jni:: jlong>(132)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticLongMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jlong { + pub unsafe fn CallStaticLongMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticLongMethod"); self.check_no_exception("CallStaticLongMethod"); self.check_return_type_object("CallStaticLongMethod", obj, methodID, "long"); + self.check_parameter_types_static("CallStaticLongMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticLongMethod", obj, methodID, arg2, 1, 2); } self.jni:: jlong>(132)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticLongMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jlong { + pub unsafe fn CallStaticLongMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jlong { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticLongMethod"); self.check_no_exception("CallStaticLongMethod"); self.check_return_type_object("CallStaticLongMethod", obj, methodID, "long"); + self.check_parameter_types_static("CallStaticLongMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticLongMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticLongMethod", obj, methodID, arg3, 2, 3); } self.jni:: jlong>(132)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2678,34 +2915,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticFloatMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jfloat { + pub unsafe fn CallStaticFloatMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticFloatMethod"); self.check_no_exception("CallStaticFloatMethod"); self.check_return_type_object("CallStaticFloatMethod", obj, methodID, "float"); + self.check_parameter_types_static("CallStaticFloatMethod", obj, methodID, arg1, 0, 1); } self.jni:: jfloat>(135)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticFloatMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jfloat { + pub unsafe fn CallStaticFloatMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticFloatMethod"); self.check_no_exception("CallStaticFloatMethod"); self.check_return_type_object("CallStaticFloatMethod", obj, methodID, "float"); + self.check_parameter_types_static("CallStaticFloatMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticFloatMethod", obj, methodID, arg2, 1, 2); } self.jni:: jfloat>(135)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticFloatMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jfloat { + pub unsafe fn CallStaticFloatMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jfloat { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticFloatMethod"); self.check_no_exception("CallStaticFloatMethod"); self.check_return_type_object("CallStaticFloatMethod", obj, methodID, "float"); + self.check_parameter_types_static("CallStaticFloatMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticFloatMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticFloatMethod", obj, methodID, arg3, 2, 3); } self.jni:: jfloat>(135)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -2731,34 +2974,40 @@ impl JNIEnv { } - pub unsafe fn CallStaticDoubleMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jdouble { + pub unsafe fn CallStaticDoubleMethod1(&self, obj: jobject, methodID: jmethodID, arg1: A) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticDoubleMethod"); self.check_no_exception("CallStaticDoubleMethod"); self.check_return_type_object("CallStaticDoubleMethod", obj, methodID, "double"); + self.check_parameter_types_static("CallStaticDoubleMethod", obj, methodID, arg1, 0, 1); } self.jni:: jdouble>(138)(self.vtable, obj, methodID, arg1) } - pub unsafe fn CallStaticDoubleMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jdouble { + pub unsafe fn CallStaticDoubleMethod2(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticDoubleMethod"); self.check_no_exception("CallStaticDoubleMethod"); self.check_return_type_object("CallStaticDoubleMethod", obj, methodID, "double"); + self.check_parameter_types_static("CallStaticDoubleMethod", obj, methodID, arg1, 0, 2); + self.check_parameter_types_static("CallStaticDoubleMethod", obj, methodID, arg2, 1, 2); } self.jni:: jdouble>(138)(self.vtable, obj, methodID, arg1, arg2) } - pub unsafe fn CallStaticDoubleMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jdouble { + pub unsafe fn CallStaticDoubleMethod3(&self, obj: jobject, methodID: jmethodID, arg1: A, arg2: B, arg3: C) -> jdouble { #[cfg(feature = "asserts")] { self.check_not_critical("CallStaticDoubleMethod"); self.check_no_exception("CallStaticDoubleMethod"); self.check_return_type_object("CallStaticDoubleMethod", obj, methodID, "double"); + self.check_parameter_types_static("CallStaticDoubleMethod", obj, methodID, arg1, 0, 3); + self.check_parameter_types_static("CallStaticDoubleMethod", obj, methodID, arg2, 1, 3); + self.check_parameter_types_static("CallStaticDoubleMethod", obj, methodID, arg3, 2, 3); } self.jni:: jdouble>(138)(self.vtable, obj, methodID, arg1, arg2, arg3) } @@ -3625,6 +3874,10 @@ impl JNIEnv { self.jni::(223)(self.vtable, array, carray, mode); } + pub unsafe fn RegisterNatives_slice(&self, clazz: jclass, methods : &[JNINativeMethod]) -> jint { + self.RegisterNatives(clazz, methods.as_ptr(), methods.len() as jint) + } + pub unsafe fn RegisterNatives(&self, clazz: jclass, methods : *const JNINativeMethod, size: jint) -> jint { #[cfg(feature = "asserts")] { @@ -3995,6 +4248,197 @@ impl JNIEnv { panic!("{} return type of method is {} but expected {}", context, the_name, ty); } + #[cfg(feature = "asserts")] + unsafe fn check_parameter_types_static(&self, context: &str, clazz: jclass, methodID: jmethodID, param1: T, idx: jsize, count: jsize) { + self.check_is_class(context, clazz); + assert!(!methodID.is_null(), "{} methodID is null", context); + let java_method = self.ToReflectedMethod(clazz, methodID, true); + assert!(!java_method.is_null(), "{} -> ToReflectedMethod returned null", context); + let meth_cl = self.FindClass_str("java/lang/reflect/Method"); + assert!(!java_method.is_null(), "{} java/lang/reflect/Method not found???", context); + let meth_params = self.GetMethodID_str(meth_cl, "getParameterTypes", "()[Ljava/lang/Class;"); + assert!(!meth_params.is_null(), "{} java/lang/reflect/Method#getParameterTypes not found???", context); + + //CallObjectMethodA + let parameter_array = self.jni:: jobject>(36)(self.vtable, java_method, meth_params, null()); + self.DeleteLocalRef(meth_cl); + self.DeleteLocalRef(java_method); + assert!(!parameter_array.is_null(), "{} java/lang/reflect/Method#getParameterTypes return null???", context); + let parameter_count = self.GetArrayLength(parameter_array); + assert_eq!(parameter_count, count, "{} wrong number of method parameters", context); + let param1_class = self.GetObjectArrayElement(parameter_array, idx); + assert!(!param1_class.is_null(), "{} java/lang/reflect/Method#getParameterTypes[{}] is null???", context, idx); + self.DeleteLocalRef(parameter_array); + + let class_cl = self.FindClass_str("java/lang/Class"); + assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context); + let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;"); + assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context); + let class_is_primitive = self.GetMethodID_str(class_cl, "isPrimitive", "()Z"); + assert!(!class_is_primitive.is_null(), "{} java/lang/Class#isPrimitive not found???", context); + + //CallObjectMethodA + let name_str = self.jni:: jobject>(36)(self.vtable, param1_class, class_name, null()); + assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context); + //CallBooleanMethodA + let param1_is_primitive = self.jni:: jboolean>(39)(self.vtable, param1_class, class_is_primitive, null()); + + let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str()); + self.DeleteLocalRef(class_cl); + self.DeleteLocalRef(name_str); + + match T::jtype_id() { + 'Z' => assert_eq!("boolean", the_name, "{} param{} wrong type. Method has {} but passed boolean", context, idx, the_name), + 'B' => assert_eq!("byte", the_name, "{} param{} wrong type. Method has {} but passed byte", context, idx, the_name), + 'S' => assert_eq!("short", the_name, "{} param{} wrong type. Method has {} but passed short", context, idx, the_name), + 'C' => assert_eq!("char", the_name, "{} param{} wrong type. Method has {} but passed char", context, idx, the_name), + 'I' => assert_eq!("int", the_name, "{} param{} wrong type. Method has {} but passed int", context, idx, the_name), + 'J' => assert_eq!("long", the_name, "{} param{} wrong type. Method has {} but passed long", context, idx, the_name), + 'F' => assert_eq!("float", the_name, "{} param{} wrong type. Method has {} but passed float", context, idx, the_name), + 'D' => assert_eq!("double", the_name, "{} param{} wrong type. Method has {} but passed double", context, idx, the_name), + 'L' => { + assert!(!param1_is_primitive, "{} param{} wrong type. Method has {} but passed an object or null", context, idx, the_name); + let jt : jtype = param1.into(); + let obj = jt.object; + if !obj.is_null() { + assert!(self.IsInstanceOf(obj, param1_class), "{} param{} wrong type. Method has {} but passed an object that is not null and not instanceof", context, idx, the_name); + } + } + _=> unreachable!("{}", T::jtype_id()) + } + + self.DeleteLocalRef(param1_class); + } + + #[cfg(feature = "asserts")] + unsafe fn check_parameter_types_constructor(&self, context: &str, clazz: jclass, methodID: jmethodID, param1: T, idx: jsize, count: jsize) { + self.check_ref_obj(context, clazz); + assert!(!clazz.is_null(), "{} obj.class is null??", context); + assert!(!methodID.is_null(), "{} methodID is null", context); + let java_method = self.ToReflectedMethod(clazz, methodID, false); + assert!(!java_method.is_null(), "{} -> ToReflectedMethod returned null", context); + let meth_cl = self.FindClass_str("java/lang/reflect/Method"); + assert!(!java_method.is_null(), "{} java/lang/reflect/Method not found???", context); + let meth_params = self.GetMethodID_str(meth_cl, "getParameterTypes", "()[Ljava/lang/Class;"); + assert!(!meth_params.is_null(), "{} java/lang/reflect/Method#getParameterTypes not found???", context); + + //CallObjectMethodA + let parameter_array = self.jni:: jobject>(36)(self.vtable, java_method, meth_params, null()); + self.DeleteLocalRef(meth_cl); + self.DeleteLocalRef(java_method); + assert!(!parameter_array.is_null(), "{} java/lang/reflect/Method#getParameterTypes return null???", context); + let parameter_count = self.GetArrayLength(parameter_array); + assert_eq!(parameter_count, count, "{} wrong number of method parameters", context); + let param1_class = self.GetObjectArrayElement(parameter_array, idx); + assert!(!param1_class.is_null(), "{} java/lang/reflect/Method#getParameterTypes[{}] is null???", context, idx); + self.DeleteLocalRef(parameter_array); + + let class_cl = self.FindClass_str("java/lang/Class"); + assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context); + let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;"); + assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context); + let class_is_primitive = self.GetMethodID_str(class_cl, "isPrimitive", "()Z"); + assert!(!class_is_primitive.is_null(), "{} java/lang/Class#isPrimitive not found???", context); + + //CallObjectMethodA + let name_str = self.jni:: jobject>(36)(self.vtable, param1_class, class_name, null()); + assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context); + //CallBooleanMethodA + let param1_is_primitive = self.jni:: jboolean>(39)(self.vtable, param1_class, class_is_primitive, null()); + + let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str()); + self.DeleteLocalRef(class_cl); + self.DeleteLocalRef(name_str); + + match T::jtype_id() { + 'Z' => assert_eq!("boolean", the_name, "{} param{} wrong type. Method has {} but passed boolean", context, idx, the_name), + 'B' => assert_eq!("byte", the_name, "{} param{} wrong type. Method has {} but passed byte", context, idx, the_name), + 'S' => assert_eq!("short", the_name, "{} param{} wrong type. Method has {} but passed short", context, idx, the_name), + 'C' => assert_eq!("char", the_name, "{} param{} wrong type. Method has {} but passed char", context, idx, the_name), + 'I' => assert_eq!("int", the_name, "{} param{} wrong type. Method has {} but passed int", context, idx, the_name), + 'J' => assert_eq!("long", the_name, "{} param{} wrong type. Method has {} but passed long", context, idx, the_name), + 'F' => assert_eq!("float", the_name, "{} param{} wrong type. Method has {} but passed float", context, idx, the_name), + 'D' => assert_eq!("double", the_name, "{} param{} wrong type. Method has {} but passed double", context, idx, the_name), + 'L' => { + assert!(!param1_is_primitive, "{} param{} wrong type. Method has {} but passed an object or null", context, idx, the_name); + let jt : jtype = param1.into(); + let obj = jt.object; + if !obj.is_null() { + assert!(self.IsInstanceOf(obj, param1_class), "{} param{} wrong type. Method has {} but passed an object that is not null and not instanceof", context, idx, the_name); + } + } + _=> unreachable!("{}", T::jtype_id()) + } + + self.DeleteLocalRef(param1_class); + } + + #[cfg(feature = "asserts")] + unsafe fn check_parameter_types_object(&self, context: &str, obj: jobject, methodID: jmethodID, param1: T, idx: jsize, count: jsize) { + assert!(!obj.is_null(), "{} obj is null", context); + self.check_ref_obj(context, obj); + let clazz = self.GetObjectClass(obj); + assert!(!clazz.is_null(), "{} obj.class is null??", context); + assert!(!methodID.is_null(), "{} methodID is null", context); + let java_method = self.ToReflectedMethod(clazz, methodID, false); + assert!(!java_method.is_null(), "{} -> ToReflectedMethod returned null", context); + self.DeleteLocalRef(clazz); + let meth_cl = self.FindClass_str("java/lang/reflect/Method"); + assert!(!java_method.is_null(), "{} java/lang/reflect/Method not found???", context); + let meth_params = self.GetMethodID_str(meth_cl, "getParameterTypes", "()[Ljava/lang/Class;"); + assert!(!meth_params.is_null(), "{} java/lang/reflect/Method#getParameterTypes not found???", context); + + //CallObjectMethodA + let parameter_array = self.jni:: jobject>(36)(self.vtable, java_method, meth_params, null()); + self.DeleteLocalRef(meth_cl); + self.DeleteLocalRef(java_method); + assert!(!parameter_array.is_null(), "{} java/lang/reflect/Method#getParameterTypes return null???", context); + let parameter_count = self.GetArrayLength(parameter_array); + assert_eq!(parameter_count, count, "{} wrong number of method parameters", context); + let param1_class = self.GetObjectArrayElement(parameter_array, idx); + assert!(!param1_class.is_null(), "{} java/lang/reflect/Method#getParameterTypes[{}] is null???", context, idx); + self.DeleteLocalRef(parameter_array); + + let class_cl = self.FindClass_str("java/lang/Class"); + assert!(!class_cl.is_null(), "{} java/lang/Class not found???", context); + let class_name = self.GetMethodID_str(class_cl, "getName", "()Ljava/lang/String;"); + assert!(!class_name.is_null(), "{} java/lang/Class#getName not found???", context); + let class_is_primitive = self.GetMethodID_str(class_cl, "isPrimitive", "()Z"); + assert!(!class_is_primitive.is_null(), "{} java/lang/Class#isPrimitive not found???", context); + + //CallObjectMethodA + let name_str = self.jni:: jobject>(36)(self.vtable, param1_class, class_name, null()); + assert!(!name_str.is_null(), "{} java/lang/Class#getName returned null??? Class has no name???", context); + //CallBooleanMethodA + let param1_is_primitive = self.jni:: jboolean>(39)(self.vtable, param1_class, class_is_primitive, null()); + + let the_name = self.GetStringUTFChars_as_string(name_str).expect(format!("{} failed to get/parse classname???", context).as_str()); + self.DeleteLocalRef(class_cl); + self.DeleteLocalRef(name_str); + + match T::jtype_id() { + 'Z' => assert_eq!("boolean", the_name, "{} param{} wrong type. Method has {} but passed boolean", context, idx, the_name), + 'B' => assert_eq!("byte", the_name, "{} param{} wrong type. Method has {} but passed byte", context, idx, the_name), + 'S' => assert_eq!("short", the_name, "{} param{} wrong type. Method has {} but passed short", context, idx, the_name), + 'C' => assert_eq!("char", the_name, "{} param{} wrong type. Method has {} but passed char", context, idx, the_name), + 'I' => assert_eq!("int", the_name, "{} param{} wrong type. Method has {} but passed int", context, idx, the_name), + 'J' => assert_eq!("long", the_name, "{} param{} wrong type. Method has {} but passed long", context, idx, the_name), + 'F' => assert_eq!("float", the_name, "{} param{} wrong type. Method has {} but passed float", context, idx, the_name), + 'D' => assert_eq!("double", the_name, "{} param{} wrong type. Method has {} but passed double", context, idx, the_name), + 'L' => { + assert!(!param1_is_primitive, "{} param{} wrong type. Method has {} but passed an object or null", context, idx, the_name); + let jt : jtype = param1.into(); + let obj = jt.object; + if !obj.is_null() { + assert!(self.IsInstanceOf(obj, param1_class), "{} param{} wrong type. Method has {} but passed an object that is not null and not instanceof", context, idx, the_name); + } + } + _=> unreachable!("{}", T::jtype_id()) + } + + self.DeleteLocalRef(param1_class); + } + #[cfg(feature = "asserts")] unsafe fn check_return_type_object(&self, context: &str, obj: jobject, methodID: jmethodID, ty: &str) { assert!(!obj.is_null(), "{} obj is null", context); @@ -4003,6 +4447,7 @@ impl JNIEnv { assert!(!clazz.is_null(), "{} obj.class is null??", context); assert!(!methodID.is_null(), "{} methodID is null", context); let m = self.ToReflectedMethod(clazz, methodID, false); + self.DeleteLocalRef(clazz); assert!(!m.is_null(), "{} -> ToReflectedMethod returned null", context); let meth_cl = self.FindClass_str("java/lang/reflect/Method"); assert!(!m.is_null(), "{} java/lang/reflect/Method not found???", context); diff --git a/tests/locals.rs b/tests/locals.rs new file mode 100644 index 0000000..dad82b9 --- /dev/null +++ b/tests/locals.rs @@ -0,0 +1,25 @@ +#[cfg(feature = "loadjvm")] +pub mod test { + use jni_simple::*; + + #[test] + fn test() { + unsafe { + load_jvm_from_java_home().expect("failed to load jvm"); + + let args: Vec = vec![]; + + let (vm, env) = JNI_CreateJavaVM_with_string_args(JNI_VERSION_1_8, &args) + .expect("failed to create jvm"); + + let clazz = env.FindClass_str("java/lang/Object"); + assert_eq!(JNI_OK, env.EnsureLocalCapacity(128)); + assert_eq!(JNI_OK, env.PushLocalFrame(128)); + let obj = env.AllocObject(clazz); + let n = env.NewGlobalRef(obj); + let r = env.PopLocalFrame(obj); + assert!(env.IsSameObject(r, n)); + vm.DestroyJavaVM(); + } + } +} \ No newline at end of file diff --git a/tests/register_natives.rs b/tests/register_natives.rs new file mode 100644 index 0000000..aae9675 --- /dev/null +++ b/tests/register_natives.rs @@ -0,0 +1,108 @@ +#[cfg(feature = "loadjvm")] +pub mod test { + use jni_simple::*; + use std::ffi::{c_void, CString}; + use std::ptr::null_mut; + + unsafe extern "system" fn t1(env: JNIEnv, _: jclass, param: jobject) { + assert!(!param.is_null()); + let data = env.GetStringUTFChars_as_string(param).unwrap(); + assert_eq!(data.as_str(), "test_string"); + } + + unsafe extern "system" fn t2(_env: JNIEnv, _: jclass, param: jdouble) { + assert_eq!(param, 754.156f64); + } + + #[test] + fn test() { + unsafe { + load_jvm_from_java_home().expect("failed to load jvm"); + let args: Vec = vec![]; + let (vm, env) = JNI_CreateJavaVM_with_string_args(JNI_VERSION_1_8, &args).expect("failed to create java VM"); + + let class_blob = include_bytes!("../java_testcode/RegisterTest.class"); + + let registered_class = env.DefineClass_str("RegisterTest", null_mut(), class_blob.as_slice()); + let t1m = env.GetStaticMethodID_str(registered_class, "callTest", "(Ljava/lang/String;)V"); + let t2m = env.GetStaticMethodID_str(registered_class, "callTest", "(D)V"); + let test_string = env.NewStringUTF_str("test_string"); + + env.CallStaticVoidMethod1(registered_class, t1m, test_string); + assert!(env.ExceptionCheck()); + let exc = env.ExceptionOccurred(); + assert!(!exc.is_null()); + env.ExceptionClear(); + let exc_class = env.GetObjectClass(exc); + env.DeleteLocalRef(exc); + let class_class = env.GetObjectClass(exc_class); + let get_name_method = env.GetMethodID_str(class_class, "getName", "()Ljava/lang/String;"); + env.DeleteLocalRef(class_class); + let exc_class_name = env.CallObjectMethod0(exc_class, get_name_method); + env.DeleteLocalRef(exc_class); + let exc_class_name_str = env.GetStringUTFChars_as_string(exc_class_name).unwrap(); + env.DeleteLocalRef(exc_class_name); + assert_eq!(exc_class_name_str.as_str(), "java.lang.UnsatisfiedLinkError"); + + env.CallStaticVoidMethod1(registered_class, t2m, 754.156f64); + assert!(env.ExceptionCheck()); + let exc = env.ExceptionOccurred(); + assert!(!exc.is_null()); + env.ExceptionClear(); + let exc_class = env.GetObjectClass(exc); + env.DeleteLocalRef(exc); + let exc_class_name = env.CallObjectMethod0(exc_class, get_name_method); + env.DeleteLocalRef(exc_class); + let exc_class_name_str = env.GetStringUTFChars_as_string(exc_class_name).unwrap(); + assert_eq!(exc_class_name_str.as_str(), "java.lang.UnsatisfiedLinkError"); + env.DeleteLocalRef(exc_class_name); + + + + let name = CString::new("test").unwrap(); + let sig1 = CString::new("(Ljava/lang/String;)V").unwrap(); + let sig2 = CString::new("(D)V").unwrap(); + + let method1 = JNINativeMethod::new(name.as_ptr(), sig1.as_ptr(), t1 as *const c_void); + let method2 = JNINativeMethod::new(name.as_ptr(), sig2.as_ptr(), t2 as *const c_void); + + assert_eq!(JNI_OK, env.RegisterNatives_slice(registered_class, &[method1, method2])); + + env.CallStaticVoidMethod1(registered_class, t2m, 754.156f64); + assert!(!env.ExceptionCheck()); + + env.CallStaticVoidMethod1(registered_class, t1m, test_string); + assert!(!env.ExceptionCheck()); + + env.UnregisterNatives(registered_class); + + env.CallStaticVoidMethod1(registered_class, t2m, 754.156f64); + assert!(env.ExceptionCheck()); + let exc = env.ExceptionOccurred(); + assert!(!exc.is_null()); + env.ExceptionClear(); + let exc_class = env.GetObjectClass(exc); + env.DeleteLocalRef(exc); + let exc_class_name = env.CallObjectMethod0(exc_class, get_name_method); + env.DeleteLocalRef(exc_class); + let exc_class_name_str = env.GetStringUTFChars_as_string(exc_class_name).unwrap(); + assert_eq!(exc_class_name_str.as_str(), "java.lang.UnsatisfiedLinkError"); + env.DeleteLocalRef(exc_class_name); + + env.CallStaticVoidMethod1(registered_class, t1m, test_string); + assert!(env.ExceptionCheck()); + let exc = env.ExceptionOccurred(); + assert!(!exc.is_null()); + env.ExceptionClear(); + let exc_class = env.GetObjectClass(exc); + env.DeleteLocalRef(exc); + let exc_class_name = env.CallObjectMethod0(exc_class, get_name_method); + env.DeleteLocalRef(exc_class); + let exc_class_name_str = env.GetStringUTFChars_as_string(exc_class_name).unwrap(); + assert_eq!(exc_class_name_str.as_str(), "java.lang.UnsatisfiedLinkError"); + env.DeleteLocalRef(exc_class_name); + + vm.DestroyJavaVM(); + } + } +} \ No newline at end of file