X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Ffield.cpp;h=4f85068ed1b083847e4aa8522b50f96047006f0a;hb=e60e2e7532c2ce0657b23f0ba1338ea433529d2c;hp=987217cffd4aeea8a3cecba34a73b97f76a19cc5;hpb=cf3b4b938bfdbd119c007424ba40c40fedcdaac2;p=cacao.git diff --git a/src/vm/field.cpp b/src/vm/field.cpp index 987217cff..4f85068ed 100644 --- a/src/vm/field.cpp +++ b/src/vm/field.cpp @@ -1,6 +1,6 @@ /* 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. @@ -29,20 +29,21 @@ #include #include -#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.hpp" -#include "vm/descriptor.h" +#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" @@ -296,7 +297,10 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) /* 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(&f->value->a), u); + else + f->value->a = literalstring_new(u); break; default: @@ -405,26 +409,24 @@ java_handle_bytearray_t *field_get_annotations(fieldinfo *f) #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