* src/native/vm/sun/jvm.c (vm/package.h): Added.
(JVM_GetSystemPackage): Implemented.
* src/vm/Makefile.am (libvm_la_SOURCES): Added package.[ch].
* src/vm/package.c: New file.
* src/vm/package.h: Likewise.
* src/vm/vm.c (vm/package.h): Added.
(vm_create): Call package_init.
* src/vmcore/loader.c (vm/package.h): Added.
(load_class_bootstrap): Call package_add.
* src/vmcore/options.c (opt_DebugPackage): Added.
(options_xx): Likewise.
* src/vmcore/options.h (opt_DebugPackage): Added.
}
+/* package ********************************************************************/
+
+/* void package_add(java_handle_t *packagename) */
+void package_add(utf *packagename)
+{
+ /* Do nothing. */
+}
+
+
/* primitive ******************************************************************/
classinfo *primitive_arrayclass_get_by_type(int type)
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
+#include "vm/package.h"
#include "vm/primitive.h"
#include "vm/properties.h"
#include "vm/resolve.h"
jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
{
- log_println("JVM_GetSystemPackage(env=%p, name=%p)");
- javastring_print((java_handle_t *) name);
- printf("\n");
+ java_handle_t *s;
+ utf *u;
+ utf *result;
- return NULL;
+ TRACEJVMCALLS("JVM_GetSystemPackage(env=%p, name=%p)", env, name);
+
+/* s = package_find(name); */
+ u = javastring_toutf(name, false);
+ result = package_find(u);
+ if (result != NULL)
+ s = javastring_new(result);
+ else
+ s = NULL;
+
+ return (jstring) s;
}
initialize.c \
initialize.h \
jit_interface.h \
+ package.c \
+ package.h \
primitive.c \
primitive.h \
properties.c \
--- /dev/null
+/* src/vm/package.c - Java boot-package functions
+
+ Copyright (C) 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
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "toolbox/list.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+
+#include "native/include/java_lang_String.h"
+
+#include "vm/package.h"
+#include "vm/stringlocal.h"
+
+#include "vmcore/options.h"
+#include "vmcore/utf8.h"
+
+
+/* internal property structure ************************************************/
+
+typedef struct list_package_entry_t list_package_entry_t;
+
+struct list_package_entry_t {
+/* java_string_t *packagename; */
+ utf *packagename;
+ listnode_t linkage;
+};
+
+
+/* global variables ***********************************************************/
+
+static list_t *list_package = NULL;
+
+
+/* package_init ****************************************************************
+
+ Initialize the package list.
+
+*******************************************************************************/
+
+void package_init(void)
+{
+ /* create the properties list */
+
+ list_package = list_create(OFFSET(list_package_entry_t, linkage));
+}
+
+
+/* package_add *****************************************************************
+
+ Add a package to the boot-package list.
+
+ IN:
+ packagename....package name as Java string
+
+*******************************************************************************/
+
+/* void package_add(java_handle_t *packagename) */
+void package_add(utf *packagename)
+{
+/* java_string_t *s; */
+ list_package_entry_t *lpe;
+
+ /* Intern the Java string to get a unique address. */
+
+/* s = javastring_intern(packagename); */
+
+ /* Check if the package is already stored. */
+
+ if (package_find(packagename) != NULL)
+ return;
+
+ /* Add the package. */
+
+#if !defined(NDEBUG)
+ if (opt_DebugPackage) {
+ log_start();
+ log_print("[package_add: packagename=");
+ utf_display_printable_ascii(packagename);
+ log_print("]");
+ log_finish();
+ }
+#endif
+
+ lpe = NEW(list_package_entry_t);
+
+ lpe->packagename = packagename;
+
+ list_add_last(list_package, lpe);
+}
+
+
+/* package_find ****************************************************************
+
+ Find a package in the list.
+
+ IN:
+ packagename....package name as Java string
+
+ OUT:
+ package name as Java string
+
+*******************************************************************************/
+
+/* java_handle_t *package_find(java_handle_t *packagename) */
+utf *package_find(utf *packagename)
+{
+/* java_string_t *s; */
+ list_t *l;
+ list_package_entry_t *lpe;
+
+ /* Intern the Java string to get a unique address. */
+
+/* s = javastring_intern(packagename); */
+
+ /* For convenience. */
+
+ l = list_package;
+
+ for (lpe = list_first(l); lpe != NULL; lpe = list_next(l, lpe)) {
+/* if (lpe->packagename == s) */
+ if (lpe->packagename == packagename)
+ return lpe->packagename;
+ }
+
+ return NULL;
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
--- /dev/null
+/* src/vm/package.c - Java boot-package functions
+
+ Copyright (C) 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
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_PACKAGE_H
+#define _VM_PACKAGE_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+
+#include "vm/global.h"
+
+
+/* function prototypes ********************************************************/
+
+void package_init(void);
+
+/* void package_add(java_handle_t *packagename); */
+void package_add(utf *packagename);
+/* java_handle_t *package_find(java_handle_t *packagename); */
+utf *package_find(utf *packagename);
+
+#endif /* _VM_PACKAGE_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
#include "vm/finalizer.h"
#include "vm/global.h"
#include "vm/initialize.h"
+#include "vm/package.h"
#include "vm/primitive.h"
#include "vm/properties.h"
#include "vm/signallocal.h"
#define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */
#define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
-#define STACK_SIZE 64 * 1024 /* default 64kB */
+#define STACK_SIZE 128 * 1024 /* default 64kB */
/* define command line options ************************************************/
intrp_md_init();
#endif
+ /* BEFORE: loader_preinit */
+
+ package_init();
+
/* AFTER: utf8_init, classcache_init */
loader_preinit();
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
+#include "vm/package.h"
#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/stringlocal.h"
RT_TIMING_GET_TIME(time_load);
- if (!r) {
+ if (r == NULL) {
/* the class could not be loaded, free the classinfo struct */
class_free(c);
-
- } else {
+ }
+ else {
/* Store this class in the loaded class cache this step also
- checks the loading constraints. If the class has been loaded
- before, the earlier loaded class is returned. */
+ checks the loading constraints. If the class has been
+ loaded before, the earlier loaded class is returned. */
classinfo *res = classcache_store(NULL, c, true);
- if (!res) {
+ if (res == NULL) {
/* exception */
class_free(c);
}
+ else {
+ /* Add the package name to the boot packages. */
+
+ package_add(c->packagename);
+ }
r = res;
}
int opt_DebugExceptions = 0;
int opt_DebugLocks = 0;
+int opt_DebugPackage = 0;
int opt_DebugPatcher = 0;
int opt_DebugProperties = 0;
int32_t opt_DebugStackFrameInfo = 0;
enum {
OPT_DebugExceptions,
OPT_DebugLocks,
+ OPT_DebugPackage,
OPT_DebugPatcher,
OPT_DebugProperties,
OPT_DebugStackFrameInfo,
option_t options_XX[] = {
{ "DebugExceptions", OPT_DebugExceptions, OPT_TYPE_BOOLEAN, "debug exceptions" },
{ "DebugLocks", OPT_DebugLocks, OPT_TYPE_BOOLEAN, "print debug information for locks" },
+ { "DebugPackage", OPT_DebugPackage, OPT_TYPE_BOOLEAN, "debug Java boot-packages" },
{ "DebugPatcher", OPT_DebugPatcher, OPT_TYPE_BOOLEAN, "debug JIT code patching" },
{ "DebugProperties", OPT_DebugProperties, OPT_TYPE_BOOLEAN, "print debug information for properties" },
{ "DebugStackFrameInfo", OPT_DebugStackFrameInfo, OPT_TYPE_BOOLEAN, "TODO" },
opt_DebugLocks = enable;
break;
+ case OPT_DebugPackage:
+ opt_DebugPackage = enable;
+ break;
+
case OPT_DebugPatcher:
opt_DebugPatcher = enable;
break;
extern int opt_DebugExceptions;
extern int opt_DebugLocks;
extern int opt_DebugPatcher;
+extern int opt_DebugPackage;
extern int opt_DebugProperties;
extern int32_t opt_DebugStackFrameInfo;
extern int32_t opt_DebugStackTrace;