This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Check CNI array types
Tom Tromey writes:
> >>>>> "Andrew" == Andrew Haley <aph@redhat.com> writes:
>
> Andrew> +_Jv_JNI_check_types (JArray<T> *array, jclass K)
> Andrew> +{
> Andrew> + jclass klass = array->getClass()->getComponentType();
> Andrew> + if (__builtin_expect (klass != K, false))
> Andrew> + throw new java::lang::IllegalAccessError ();
>
> Andrew> (JNICALL _Jv_JNI_GetPrimitiveArrayElements) (JNIEnv *, JArray<T> *array,
> Andrew> jboolean *isCopy)
> Andrew> {
> Andrew> array = unwrap (array);
> Andrew> + _Jv_JNI_check_types (array, K);
>
> A function in the JNI table can't simply throw. It must convert the
> exception into a JNI exception. See _Jv_JNI_NewPrimitiveArray for an
> example.
It worked for me. But okay, I'll do that.
> If you've got a few minutes, could you add a new JNI test case for
> this patch? Adding a JNI test case is really easy.
OK.
Andrew.