#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
-#include "vm/primitive.h"
+#include "vm/primitive.hpp"
#include "vm/stringlocal.h"
#include "vm/jit/asmpart.h"
*******************************************************************************/
-bool builtin_instanceof(java_handle_t *o, classinfo *class)
+bool builtin_instanceof(java_handle_t *o, classinfo *c)
{
- classinfo *c;
+ classinfo *oc;
if (o == NULL)
return 0;
- LLNI_class_get(o, c);
+ LLNI_class_get(o, oc);
- return class_isanysubclass(c, class);
+ return class_isanysubclass(oc, c);
}
*******************************************************************************/
-bool builtin_checkcast(java_handle_t *o, classinfo *class)
+bool builtin_checkcast(java_handle_t *o, classinfo *c)
{
- classinfo *c;
+ classinfo *oc;
if (o == NULL)
return 1;
- LLNI_class_get(o, c);
+ LLNI_class_get(o, oc);
- if (class_isanysubclass(c, class))
+ if (class_isanysubclass(oc, c))
return 1;
return 0;
return;
}
- /* we try to throw exception with the same message as SUN does */
+ // Check if offsets and length are positive.
+ if ((srcStart < 0) || (destStart < 0) || (len < 0)) {
+ exceptions_throw_arrayindexoutofboundsexception();
+ return;
+ }
- if ((len < 0) || (srcStart < 0) || (destStart < 0) ||
- (srcStart + len < 0) || (srcStart + len > LLNI_array_size(src)) ||
- (destStart + len < 0) || (destStart + len > LLNI_array_size(dest))) {
+ // Check if ranges are valid.
+ if ((((uint32_t) srcStart + (uint32_t) len) > (uint32_t) LLNI_array_size(src)) ||
+ (((uint32_t) destStart + (uint32_t) len) > (uint32_t) LLNI_array_size(dest))) {
exceptions_throw_arrayindexoutofboundsexception();
return;
}
+ // Special case.
+ if (len == 0) {
+ return;
+ }
+
if (sdesc->componentvftbl == ddesc->componentvftbl) {
/* We copy primitive values or references of exactly the same type */