void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
{
- arraydescriptor *ad;
- classinfo *cc;
- int32_t size;
+ int32_t size;
if (a == NULL) {
exceptions_throw_nullpointerexception();
return;
}
- /* TODO Write inline functions for that and use LLNI. */
+ /* Sanity check. */
- LLNI_CRITICAL_START;
+ assert(a->header.objheader.vftbl->arraydesc->arraytype == ARRAYTYPE_OBJECT);
- ad = a->header.objheader.vftbl->arraydesc;
- cc = ad->componentvftbl->class;
-
- LLNI_CRITICAL_END;
-
- if (ad->arraytype == ARRAYTYPE_OBJECT) {
- if (value != NULL) {
- if (builtin_instanceof(value, cc) == false) {
- exceptions_throw_illegalargumentexception();
- return;
- }
+ if (value != NULL) {
+ if (builtin_canstore(a, value) == false) {
+ exceptions_throw_illegalargumentexception();
+ return;
}
}
a ... Java array
RETURN VALUE:
- 0 ... exception thrown
- >0 ... length of the Java array
+ -1 ... exception thrown
+ >= 0 ... length of the Java array
*******************************************************************************/
if (a == NULL) {
exceptions_throw_nullpointerexception();
- return 0;
+ return -1;
}
LLNI_class_get(a, c);
if (!class_is_array(c)) {
/* exceptions_throw_illegalargumentexception("Argument is not an array"); */
exceptions_throw_illegalargumentexception();
- return 0;
+ return -1;
}
size = LLNI_array_size(a);
- if ((size <= 0) || (size > /* MAX_DIM */ 255)) {
- exceptions_throw_illegalargumentexception();
- return 0;
- }
-
return size;
}