static int string_obj_comparator(const void *key1, const void *key2) { struct vm_object *array1, *array2; jint offset1, offset2; jint count1, count2; count1 = field_get_int(key1, vm_java_lang_String_count); count2 = field_get_int(key2, vm_java_lang_String_count); if (count1 != count2) return -1; offset1 = field_get_int(key1, vm_java_lang_String_offset); offset2 = field_get_int(key2, vm_java_lang_String_offset); array1 = field_get_object(key1, vm_java_lang_String_value); array2 = field_get_object(key2, vm_java_lang_String_value); int fsize = get_vmtype_size(J_CHAR); return memcmp(array1->fields + offset1 * fsize, array2->fields + offset2 * fsize, count1 * fsize); }
/* * Compare key1 string and key2 weak reference to string. */ static bool string_obj_equals(const void *key1, const void *key2) { struct vm_object *array1, *array2; jint offset1, offset2; jint count1, count2; count1 = field_get_int(key1, vm_java_lang_String_count); count2 = field_get_int(key2, vm_java_lang_String_count); if (count1 != count2) return false; offset1 = field_get_int(key1, vm_java_lang_String_offset); offset2 = field_get_int(key2, vm_java_lang_String_offset); array1 = field_get_object(key1, vm_java_lang_String_value); array2 = field_get_object(key2, vm_java_lang_String_value); int fsize = vmtype_get_size(J_CHAR); return memcmp(vm_array_elems(array1) + offset1 * fsize, vm_array_elems(array2) + offset2 * fsize, count1 * fsize) == 0; }
struct vm_field *vm_object_to_vm_field(struct vm_object *field) { struct vm_object *class; struct vm_class *vmc; int slot; if (!field) return throw_npe(); if (vm_java_lang_reflect_VMField != NULL) { /* Classpath 0.98 */ if (vm_object_is_instance_of(field, vm_java_lang_reflect_Field)) field = field_get_object(field, vm_java_lang_reflect_Field_f); class = field_get_object(field, vm_java_lang_reflect_VMField_clazz); slot = field_get_int(field, vm_java_lang_reflect_VMField_slot); } else {
static unsigned long string_obj_hash(const void *key) { struct vm_object *array; unsigned long hash; jint offset; jint count; offset = field_get_int(key, vm_java_lang_String_offset); count = field_get_int(key, vm_java_lang_String_count); array = field_get_object(key, vm_java_lang_String_value); hash = 0; for (jint i = 0; i < count; i++) hash += 31 * hash + array_get_field_char(array, i + offset); return hash; }