/* src/vm/field.cpp - field functions
- Copyright (C) 1996-2005, 2006, 2007, 2008
+ Copyright (C) 1996-2005, 2006, 2007, 2008, 2010
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include <stdint.h>
#include <stdio.h>
-#include "mm/memory.h"
+#include "mm/memory.hpp"
#include "native/llni.h"
#include "vm/types.h"
-#include "vm/annotation.h"
+#include "vm/annotation.hpp"
#include "vm/array.hpp"
#include "vm/jit/builtin.hpp"
-#include "vm/class.h"
-#include "vm/descriptor.h"
+#include "vm/class.hpp"
+#include "vm/descriptor.hpp"
#include "vm/exceptions.hpp"
#include "vm/field.hpp"
#include "vm/global.h"
+#include "vm/globals.hpp"
#include "vm/loader.hpp"
#include "vm/options.h"
#include "vm/primitive.hpp"
/* Create Java-string from compressed UTF8-string. */
- f->value->a = literalstring_new(u);
+ if (!(class_java_lang_String->flags & CLASS_LINKED))
+ linker_create_string_later(reinterpret_cast<java_object_t**>(&f->value->a), u);
+ else
+ f->value->a = literalstring_new(u);
break;
default:
#if defined(ENABLE_ANNOTATIONS)
classinfo *c; /* declaring class */
int slot; /* slot of this field */
- java_handle_bytearray_t *annotations; /* unparsed annotations */
java_handle_t *field_annotations; /* array of unparsed */
/* annotations of all fields of the declaring class */
- c = f->clazz;
- slot = f - c->fields;
- annotations = NULL;
+ c = f->clazz;
+ slot = f - c->fields;
LLNI_classinfo_field_get(c, field_annotations, field_annotations);
+ ObjectArray oa(field_annotations);
+
/* the field_annotations array might be shorter then the field
* count if the fields above a certain index have no annotations.
*/
- if (field_annotations != NULL &&
- array_length_get(field_annotations) > slot) {
- annotations = (java_handle_bytearray_t*)array_objectarray_element_get(
- (java_handle_objectarray_t*)field_annotations, slot);
+ if (field_annotations != NULL && oa.get_length() > slot) {
+ return (java_handle_bytearray_t*) oa.get_element(slot);
+ } else {
+ return NULL;
}
-
- return annotations;
#else
return NULL;
#endif