/* src/vm/properties.c - handling commandline properties
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Christian Thalinger
-
- $Id: properties.c 6015 2006-11-18 22:16:32Z twisti $
+ $Id: properties.c 7783 2007-04-20 13:28:27Z twisti $
*/
#include "mm/memory.h"
-#include "vm/global.h"
+#include "native/jni.h"
+
+#include "vm/global.h" /* required by java_lang_String.h */
#include "native/include/java_lang_String.h"
-#include "native/include/java_util_Properties.h"
+
#include "toolbox/list.h"
#include "toolbox/util.h"
-#include "vm/method.h"
-#include "vm/options.h"
+
#include "vm/properties.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
+
#include "vm/jit/asmpart.h"
+#include "vmcore/method.h"
+#include "vmcore/options.h"
+
/* internal property structure ************************************************/
typedef struct list_properties_entry list_properties_entry;
struct list_properties_entry {
- char *key;
- char *value;
- listnode linkage;
+ char *key;
+ char *value;
+ listnode_t linkage;
};
/* global variables ***********************************************************/
-static list *list_properties = NULL;
+static list_t *list_properties = NULL;
/* properties_init *************************************************************
properties_add("java.vm.version", VERSION);
properties_add("java.vm.vendor", "CACAO Team");
properties_add("java.vm.name", "CACAO");
- properties_add("java.specification.version", "1.4");
+ properties_add("java.specification.version", "1.5");
properties_add("java.specification.vendor", "Sun Microsystems Inc.");
properties_add("java.specification.name", "Java Platform API Specification");
properties_add("java.class.version", CLASS_VERSION);
}
#elif defined(ENABLE_JAVAME_CLDC1_1)
properties_add("microedition.configuration", "CLDC-1.1");
- properties_add("microedition.platform", "PowerPC");
- properties_add("microedition.encoding", "ISO-8859-1");
+ properties_add("microedition.platform", "generic");
+ properties_add("microedition.encoding", "ISO8859_1");
properties_add("microedition.profiles", "");
#else
#error unknown Java configuration
{
list_properties_entry *pe;
- /* We search backwards, so we get the newest entry for a key, as
- the list may contain more than one entry for a specific key. */
-
- for (pe = list_last_unsynced(list_properties); pe != NULL;
- pe = list_prev_unsynced(list_properties, pe)) {
+ for (pe = list_first_unsynced(list_properties); pe != NULL;
+ pe = list_next_unsynced(list_properties, pe)) {
if (strcmp(pe->key, key) == 0)
return pe->value;
}
}
+/* properties_system_add *******************************************************
+
+ Adds a given property to the Java system properties.
+
+*******************************************************************************/
+
+void properties_system_add(java_objectheader *p, char *key, char *value)
+{
+ methodinfo *m;
+ java_objectheader *k;
+ java_objectheader *v;
+
+ /* search for method to add properties */
+
+ m = class_resolveclassmethod(p->vftbl->class,
+ utf_put,
+ utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
+ NULL,
+ true);
+
+ if (m == NULL)
+ return;
+
+ /* add to the Java system properties */
+
+ k = javastring_new_from_utf_string(key);
+ v = javastring_new_from_utf_string(value);
+
+ (void) vm_call_method(m, p, k, v);
+}
+
+
/* properties_system_add_all ***************************************************
Adds all properties from the properties list to the Java system
properties.
+ ARGUMENTS:
+ p.... is actually a java_util_Properties structure
+
*******************************************************************************/
#if defined(ENABLE_JAVASE)
-void properties_system_add_all(java_util_Properties *p)
+void properties_system_add_all(java_objectheader *p)
{
list_properties_entry *pe;
methodinfo *m;
- java_lang_String *key;
- java_lang_String *value;
+ java_objectheader *key;
+ java_objectheader *value;
/* search for method to add properties */
- m = class_resolveclassmethod(p->header.vftbl->class,
- utf_new_char("put"),
+ m = class_resolveclassmethod(p->vftbl->class,
+ utf_put,
utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"),
NULL,
true);