classes for Java object access.
AC_SUBST(CACAO_VM_ZIP)
-AC_CHECK_WITH_CACAOH
AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY
dnl Now we check for jre-layout so we can skip some checks that are
[man/Makefile]
[src/Makefile]
[src/cacao/Makefile]
- [src/cacaoh/Makefile]
[src/classes/Makefile]
[src/fdlibm/Makefile]
[src/mm/Makefile]
Doxyfile
doxygen:
- doxygen
+ doxygen $(srcdir)/Doxyfile
clean-local:
-rm -rf html latex
+++ /dev/null
-dnl m4/cacaoh.m4
-dnl
-dnl Copyright (C) 2007, 2008
-dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-dnl
-dnl This file is part of CACAO.
-dnl
-dnl This program is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU General Public License as
-dnl published by the Free Software Foundation; either version 2, or (at
-dnl your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-dnl 02110-1301, USA.
-
-
-dnl check which cacaoh to use
-
-AC_DEFUN([AC_CHECK_WITH_CACAOH],[
-AC_MSG_CHECKING(which cacaoh to use (for crosscompilation))
-AC_ARG_WITH([cacaoh],
- [AS_HELP_STRING(--with-cacaoh,which cacaoh to use [[default=$(top_builddir)/src/cacaoh/cacaoh]])],
- [CACAOH="${withval}"],
- [CACAOH=["\$(top_builddir)/src/cacaoh/cacaoh"]])
-AC_MSG_RESULT(${CACAOH})
-AC_SUBST(CACAOH)
-])
DIST_SUBDIRS = \
cacao \
- cacaoh \
classes \
fdlibm \
mm \
# DON'T CHANGE THIS ORDER!!!
SUBDIRS = \
- toolbox \
- vmcore \
- cacaoh \
classes \
- native \
fdlibm \
+ toolbox \
mm \
- threads \
+ vmcore \
vm \
+ threads \
+ native \
cacao \
scripts
+++ /dev/null
-## src/cacaoh/Makefile.am
-##
-## Copyright (C) 1996-2005, 2006, 2007, 2008
-## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-##
-## 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.
-
-
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
-
-if ENABLE_RT_TIMING
-cacaoh_LDFLAGS = -lrt
-endif
-
-noinst_LTLIBRARIES = \
- libcacaoh.la
-
-libcacaoh_la_SOURCES = \
- dummy.cpp \
- headers.c \
- headers.h
-
-libcacaoh_la_LIBADD = \
- $(top_builddir)/src/toolbox/libtoolbox.la \
- $(top_builddir)/src/vmcore/libvmcore.la
-
-noinst_PROGRAMS = \
- cacaoh
-
-cacaoh_SOURCES = \
- cacaoh.c
-
-# Dummy C++ source to cause C++ linking.
-# http://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries
-nodist_EXTRA_cacaoh_SOURCES = \
- foo.cxx
-
-cacaoh_LDADD = \
- libcacaoh.la
-
-cacaoh_DEPENDENCIES = \
- $(cacaoh_LDADD)
-
-
-## Local variables:
-## mode: Makefile
-## indent-tabs-mode: t
-## c-basic-offset: 4
-## tab-width: 8
-## compile-command: "automake --add-missing"
-## End:
+++ /dev/null
-/* src/cacaoh/cacaoh.c - main for header generation (cacaoh)
-
- Copyright (C) 1996-2005, 2006, 2007, 2008
- CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
- 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "cacaoh/headers.h"
-
-#include "mm/gc.hpp"
-#include "mm/memory.h"
-
-#include "toolbox/hashtable.h"
-#include "toolbox/logging.h"
-
-#include "vm/global.h"
-#include "vm/string.hpp"
-#include "vm/vm.hpp"
-
-#include "vmcore/classcache.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-#include "vmcore/suck.h"
-
-
-/* define cacaoh options ******************************************************/
-
-enum {
- OPT_HELP,
- OPT_VERSION,
- OPT_VERBOSE,
- OPT_DIRECTORY,
- OPT_CLASSPATH,
- OPT_BOOTCLASSPATH,
-
- DUMMY
-};
-
-
-opt_struct opts[] = {
- { "help", false, OPT_HELP },
- { "version", false, OPT_VERSION },
- { "verbose", false, OPT_VERBOSE },
- { "d", true, OPT_DIRECTORY },
- { "classpath", true, OPT_CLASSPATH },
- { "bootclasspath", true, OPT_BOOTCLASSPATH },
- { NULL, false, 0 }
-};
-
-
-/* usage ***********************************************************************
-
- Obviously prints usage information of cacaoh.
-
-*******************************************************************************/
-
-void usage(void)
-{
- printf("Usage: cacaoh [options] <classes>\n"
- "\n"
- "Options:\n"
- " -help Print this message\n"
- " -classpath <path> \n"
- " -bootclasspath <path> \n"
- " -d <dir> Output directory\n"
- " -version Print version information\n"
- " -verbose Enable verbose output\n");
-
- /* exit with error code */
-
- exit(1);
-}
-
-
-/* version *********************************************************************
-
- Prints cacaoh version information.
-
-*******************************************************************************/
-
-static void version(void)
-{
- printf("cacaoh version "VERSION"\n");
- printf("Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,\n");
- printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
- printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
- printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
-
- printf("This program is free software; you can redistribute it and/or\n");
- printf("modify it under the terms of the GNU General Public License as\n");
- printf("published by the Free Software Foundation; either version 2, or (at\n");
- printf("your option) any later version.\n\n");
-
- printf("This program is distributed in the hope that it will be useful, but\n");
- printf("WITHOUT ANY WARRANTY; without even the implied warranty of\n");
- printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
- printf("General Public License for more details.\n");
-
- exit(0);
-}
-
-
-/* forward declarations *******************************************************/
-
-static JavaVMInitArgs *cacaoh_options_prepare(int argc, char **argv);
-
-
-/* main ************************************************************************
-
- Main program.
-
-*******************************************************************************/
-
-int main(int argc, char **argv)
-{
- JavaVMInitArgs *vm_args;
- s4 i, j;
- s4 opt;
- classinfo *c;
- char *opt_directory;
-
- /********** internal (only used by main) *****************************/
-
- char *bootclasspath;
- char *classpath;
- char *cp;
- s4 cplen;
-
- if (argc < 2)
- usage();
-
- /* set the bootclasspath */
-
- cp = getenv("BOOTCLASSPATH");
-
- if (cp) {
- bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
- strcpy(bootclasspath, cp);
- }
- else {
- cplen =
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- strlen(CACAO_VM_ZIP) +
- strlen(":") +
-#endif
- strlen(JAVA_RUNTIME_LIBRARY_CLASSES) +
- strlen("0");
-
- bootclasspath = MNEW(char, cplen);
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- strcat(bootclasspath, CACAO_VM_ZIP);
- strcat(bootclasspath, ":");
-#endif
- strcat(bootclasspath, JAVA_RUNTIME_LIBRARY_CLASSES);
- }
-
-
- /* set the classpath */
-
- cp = getenv("CLASSPATH");
-
- if (cp != NULL) {
- classpath = MNEW(char, strlen(cp) + strlen("0"));
- strcat(classpath, cp);
- }
- else {
- classpath = MNEW(char, strlen(".") + strlen("0"));
- strcpy(classpath, ".");
- }
-
-
- /* initialize options with default values */
-
- opt_verbose = false;
- opt_directory = NULL;
-
-
- /* parse the options ******************************************************/
-
- vm_args = cacaoh_options_prepare(argc, argv);
-
- while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
- switch (opt) {
- case OPT_IGNORE:
- break;
-
- case OPT_HELP:
- usage();
- break;
-
- case OPT_CLASSPATH:
- /* forget old classpath and set the argument as new classpath */
- MFREE(classpath, char, strlen(classpath));
-
- classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(classpath, opt_arg);
- break;
-
- case OPT_BOOTCLASSPATH:
- /* Forget default bootclasspath and set the argument as
- new boot classpath. */
- MFREE(bootclasspath, char, strlen(bootclasspath));
-
- bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(bootclasspath, opt_arg);
- break;
-
- case OPT_DIRECTORY:
- opt_directory = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(opt_directory, opt_arg);
- break;
-
- case OPT_VERSION:
- version();
- break;
-
- case OPT_VERBOSE:
- opt_verbose = true;
- loadverbose = true;
- break;
-
- default:
- usage();
- }
- }
-
- /**************************** Program start **************************/
-
- if (opt_verbose) {
- log_init(NULL);
- log_println("Java - header-generator started");
- }
-
- utf8_init();
-
- /* initialize the classcache hashtable stuff: lock, hashtable
- (must be done _after_ threads_preinit) */
-
- if (!classcache_init())
- vm_abort("classcache_init failed\n");
-
- /* initialize the loader with bootclasspath (must be done _after_
- thread_preinit) */
-
- if (!suck_init())
- vm_abort("suck_init failed\n");
-
- suck_add(bootclasspath);
-
- /* Also add the normal classpath, so the bootstrap class loader
- can find the files. */
-
- suck_add(classpath);
-
- /* AFTER: classcache_init */
-
- loader_preinit();
- loader_init();
-
-
- /* load Java classes ******************************************************/
-
- for (i = opt_index; i < vm_args->nOptions; i++) {
- cp = vm_args->options[i].optionString;
-
- /* convert classname */
-
- for (j = strlen(cp) - 1; j >= 0; j--) {
- switch (cp[j]) {
- case '.':
- cp[j] = '/';
- break;
- case '_':
- cp[j] = '$';
- break;
- }
- }
-
- /* exceptions are catched with new_exception call */
-
- if (!(c = load_class_bootstrap(utf_new_char(cp))))
- vm_abort("java.lang.NoClassDefFoundError: %s\n", cp);
-
- if (!link_class(c))
- vm_abort("java.lang.LinkageError: %s\n", cp);
-
- headerfile_generate(c, opt_directory);
- }
-
- /************************ Release all resources **********************/
-
- loader_close();
-
- if (opt_verbose) {
- log_println("Java - header-generator stopped");
-#if defined(ENABLE_STATISTICS)
- statistics_print_memory_usage();
-#endif
- }
-
- return 0;
-}
-
-
-/* cacaoh_options_prepare ******************************************************
-
- Prepare the JavaVMInitArgs.
-
-*******************************************************************************/
-
-static JavaVMInitArgs *cacaoh_options_prepare(int argc, char **argv)
-{
- JavaVMInitArgs *vm_args;
- s4 i;
-
- vm_args = NEW(JavaVMInitArgs);
-
- vm_args->nOptions = argc - 1;
- vm_args->options = MNEW(JavaVMOption, argc);
-
- for (i = 1; i < argc; i++)
- vm_args->options[i - 1].optionString = argv[i];
-
- return vm_args;
-}
-
-
-/*
- * 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:
- */
+++ /dev/null
-/* src/cacaoh/dummy.cpp - dummy functions for cacaoh
-
- Copyright (C) 2007, 2008
- CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
- 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 <assert.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "mm/gc.hpp"
-#include "mm/memory.h"
-
-#include "native/llni.h"
-
-#include "toolbox/logging.h"
-
-#include "vm/exceptions.hpp"
-#include "vm/global.h"
-#include "vm/primitive.hpp"
-#include "vm/vm.hpp"
-
-#include "vm/jit/code.h"
-
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/field.h"
-#include "vmcore/loader.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
-#include "vmcore/os.hpp"
-
-
-// Below this line are C exports.
-extern "C" {
-
-/* global variables ***********************************************************/
-
-bool vm_initializing = true;
-char *_Jv_bootclasspath;
-
-
-java_handle_t *javastring_new_slash_to_dot(utf *u)
-{
- vm_abort("javastring_new_slash_to_dot");
-
- return NULL;
-}
-
-
-/* access *********************************************************************/
-
-bool access_is_accessible_class(classinfo *referer, classinfo *cls)
-{
- return true;
-}
-
-bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
- int32_t memberflags)
-{
- vm_abort("access_is_accessible_member");
-
- return true;
-}
-
-
-/* array **********************************************************************/
-
-java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index)
-{
- java_handle_t *value;
- int32_t size;
-
- if (a == NULL) {
- log_println("array_objectarray_element_get(a=%p, index=%d): NullPointerException", a, index);
- return NULL;
- }
-
- size = LLNI_array_size(a);
-
- if ((index < 0) || (index > size)) {
- log_println("array_objectarray_element_get(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
- return NULL;
- }
-
- value = LLNI_WRAP(LLNI_array_direct(a, index));
-
- return value;
-}
-
-void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
-{
- int32_t size;
-
- if (a == NULL) {
- log_println("array_objectarray_element_set(a=%p, index=%d): NullPointerException", a, index);
- return;
- }
-
- size = LLNI_array_size(a);
-
- if ((index < 0) || (index > size)) {
- log_println("array_objectarray_element_set(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
- return;
- }
-
- LLNI_array_direct(a, index) = LLNI_UNWRAP(value);
-}
-
-int32_t array_length_get(java_handle_t *a)
-{
- if (a == NULL) {
- log_println("array_length_get(a=%p): NullPointerException", a);
- return 0;
- }
-
- return LLNI_array_size(a);
-}
-
-
-/* asm ************************************************************************/
-
-void asm_abstractmethoderror(void)
-{
- abort();
-}
-
-void intrp_asm_abstractmethoderror(void)
-{
- abort();
-}
-
-
-/* builtin ********************************************************************/
-
-java_handle_t *builtin_clone(void *env, java_handle_t *o)
-{
- vm_abort("builtin_clone: Not implemented.");
- return NULL;
-}
-
-bool builtin_isanysubclass(classinfo *sub, classinfo *super)
-{
- vm_abort("builtin_isanysubclass: Not implemented.");
- return 0;
-}
-
-bool builtin_instanceof(java_handle_t *o, classinfo *c)
-{
- vm_abort("builtin_instanceof: Not implemented.");
- return 0;
-}
-
-java_handle_t *builtin_new(classinfo *c)
-{
- vm_abort("builtin_new: Not implemented.");
- return NULL;
-}
-
-java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
-{
- java_objectarray_t *oa = (java_objectarray_t*) mem_alloc(
- sizeof(java_array_t) + size * sizeof(java_object_t*));
- java_handle_objectarray_t *h = (java_handle_objectarray_t*) LLNI_WRAP(
- (java_object_t*) oa);
-
- if (h != NULL) {
- LLNI_array_size(h) = size;
- }
-
- return h;
-}
-
-java_handle_bytearray_t *builtin_newarray_byte(int32_t size)
-{
- java_bytearray_t *ba = (java_bytearray_t*) mem_alloc(
- sizeof(java_array_t) + size * sizeof(int8_t));
- java_handle_bytearray_t *h = (java_handle_bytearray_t*) LLNI_WRAP(
- (java_object_t*) ba);
-
- if (h != NULL) {
- LLNI_array_size(h) = size;
- }
-
- return h;
-}
-
-
-/* code ***********************************************************************/
-
-void code_free_code_of_method(methodinfo *m)
-{
-}
-
-
-methodinfo *code_get_methodinfo_for_pv(void *pv)
-{
- return NULL;
-}
-
-
-/* codegen ********************************************************************/
-
-u1 *codegen_generate_stub_compiler(methodinfo *m)
-{
- return NULL;
-}
-
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
-{
- return NULL;
-}
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_createcompilerstub(methodinfo *m)
-{
- return NULL;
-}
-#endif
-
-void removecompilerstub(u1 *stub)
-{
-}
-
-void removenativestub(u1 *stub)
-{
-}
-
-
-/* exceptions *****************************************************************/
-
-void exceptions_clear_exception(void)
-{
-}
-
-void exceptions_print_current_exception(void)
-{
- abort();
-}
-
-void exceptions_throw_abstractmethoderror(void)
-{
- fprintf(stderr, "java.lang.AbstractMethodError\n");
-
- abort();
-}
-
-void exceptions_throw_classcircularityerror(classinfo *c)
-{
- fprintf(stderr, "java.lang.ClassCircularityError: ");
-
- utf_display_printable_ascii(c->name);
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_classformaterror(classinfo *c, const char *message, ...)
-{
- va_list ap;
-
- fprintf(stderr, "java.lang.ClassFormatError: ");
-
- utf_display_printable_ascii(c->name);
- fprintf(stderr, ": ");
-
- va_start(ap, message);
- vfprintf(stderr, message, ap);
- va_end(ap);
-
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
-{
- fprintf(stderr, "java.lang.IncompatibleClassChangeError: ");
-
- if (c != NULL)
- utf_fprint_printable_ascii_classname(stderr, c->name);
-
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_internalerror(const char *message, ...)
-{
- va_list ap;
-
- fprintf(stderr, "java.lang.InternalError: ");
-
- va_start(ap, message);
- vfprintf(stderr, message, ap);
- va_end(ap);
-
- abort();
-}
-
-void exceptions_throw_linkageerror(const char *message, classinfo *c)
-{
- fprintf(stderr, "java.lang.LinkageError: %s", message);
-
- if (c != NULL)
- utf_fprint_printable_ascii_classname(stderr, c->name);
-
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_noclassdeffounderror(utf *name)
-{
- fprintf(stderr, "java.lang.NoClassDefFoundError: ");
- utf_fprint_printable_ascii(stderr, name);
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name)
-{
- fprintf(stderr, "java.lang.NoClassDefFoundError: ");
- utf_fprint_printable_ascii(stderr, c->name);
- fprintf(stderr, " (wrong name: ");
- utf_fprint_printable_ascii(stderr, name);
- fprintf(stderr, ")\n");
-
- abort();
-}
-
-void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...)
-{
- fprintf(stderr, "java.lang.VerifyError: ");
- utf_fprint_printable_ascii(stderr, m->name);
- fprintf(stderr, ": %s", message);
-
- abort();
-}
-
-void exceptions_throw_nosuchfielderror(classinfo *c, utf *name)
-{
- fprintf(stderr, "java.lang.NoSuchFieldError: ");
- utf_fprint_printable_ascii(stderr, c->name);
- fprintf(stderr, ".");
- utf_fprint_printable_ascii(stderr, name);
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc)
-{
- fprintf(stderr, "java.lang.NoSuchMethodError: ");
- utf_fprint_printable_ascii(stderr, c->name);
- fprintf(stderr, ".");
- utf_fprint_printable_ascii(stderr, name);
- utf_fprint_printable_ascii(stderr, desc);
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi)
-{
- fprintf(stderr, "java.lang.UnsupportedClassVersionError: " );
- utf_display_printable_ascii(c->name);
- fprintf(stderr, " (Unsupported major.minor version %d.%d)\n", ma, mi);
-
- abort();
-}
-
-void exceptions_throw_classnotfoundexception(utf *name)
-{
- fprintf(stderr, "java.lang.ClassNotFoundException: ");
- utf_fprint_printable_ascii(stderr, name);
- fputc('\n', stderr);
-
- abort();
-}
-
-void exceptions_throw_nullpointerexception(void)
-{
- fprintf(stderr, "java.lang.NullPointerException\n");
-
- abort();
-}
-
-
-/* finalizer ******************************************************************/
-
-void finalizer_notify(void)
-{
- vm_abort("finalizer_notify");
-}
-
-void finalizer_run(void *o, void *p)
-{
- vm_abort("finalizer_run");
-}
-
-
-/* gc *************************************************************************/
-
-void gc_reference_register(java_object_t **ref, int32_t reftype)
-{
- vm_abort("gc_reference_register");
-}
-
-int64_t gc_get_heap_size(void)
-{
- return 0;
-}
-
-int64_t gc_get_free_bytes(void)
-{
- return 0;
-}
-
-int64_t gc_get_total_bytes(void)
-{
- return 0;
-}
-
-int64_t gc_get_max_heap_size(void)
-{
- return 0;
-}
-
-
-/* heap ***********************************************************************/
-
-void *heap_alloc_uncollectable(size_t bytelength)
-{
- return calloc(bytelength, 1);
-}
-
-s4 heap_get_hashcode(java_object_t *o)
-{
- return 0;
-}
-
-
-/* instruction ****************************************************************/
-
-methoddesc *instruction_call_site(const instruction *iptr)
-{
- return NULL;
-}
-
-
-/* jit ************************************************************************/
-
-icmdtable_entry_t icmd_table[256] = {};
-
-void jit_invalidate_code(methodinfo *m)
-{
- vm_abort("jit_invalidate_code");
-}
-
-
-/* llni ***********************************************************************/
-
-void llni_critical_start()
-{
-}
-
-void llni_critical_end()
-{
-}
-
-
-/* localref *******************************************************************/
-
-java_handle_t *localref_add(java_object_t *o)
-{
-#if defined(ENABLE_HANDLES)
- java_handle_t *h = (java_handle_t*) mem_alloc(sizeof(java_handle_t));
-
- h->heap_object = o;
-
- return h;
-#else
- return (java_handle_t*) o;
-#endif
-}
-
-
-/* lock ***********************************************************************/
-
-void lock_init_object_lock(java_object_t *o)
-{
-}
-
-bool lock_monitor_enter(java_handle_t *o)
-{
- return true;
-}
-
-bool lock_monitor_exit(java_handle_t *o)
-{
- return true;
-}
-
-
-/* md *************************************************************************/
-
-void md_param_alloc(methoddesc *md)
-{
-}
-
-void md_param_alloc_native(methoddesc *md)
-{
-}
-
-
-/* memory *********************************************************************/
-
-void *mem_alloc(int32_t size)
-{
- /* real implementation in src/mm/memory.c clears memory */
-
- return calloc(size, 1);
-}
-
-void *mem_realloc(void *src, int32_t len1, int32_t len2)
-{
- return realloc(src, len2);
-}
-
-void mem_free(void *m, int32_t size)
-{
- free(m);
-}
-
-void *dumpmemory_get(size_t size)
-{
- return malloc(size);
-}
-
-int32_t dumpmemory_marker(void)
-{
- return 0;
-}
-
-void dumpmemory_release(int32_t size)
-{
-}
-
-
-/* package ********************************************************************/
-
-/* void Package_add(java_handle_t *packagename) */
-void Package_add(utf *packagename)
-{
- /* Do nothing. */
-}
-
-
-/* primitive ******************************************************************/
-
-classinfo *Primitive_get_arrayclass_by_type(int type)
-{
- return NULL;
-}
-
-classinfo *Primitive_get_class_by_type(int type)
-{
- abort();
- return NULL;
-}
-
-classinfo *Primitive_get_class_by_char(char ch)
-{
- abort();
- return NULL;
-}
-
-
-/* properties *****************************************************************/
-
-void properties_add(char *key, char *value)
-{
-}
-
-char *properties_get(char *key)
-{
- return NULL;
-}
-
-
-/* reflect ********************************************************************/
-
-java_handle_t *reflect_constructor_new(fieldinfo *f)
-{
- vm_abort("reflect_constructor_new: Not implemented.");
- return NULL;
-}
-
-java_handle_t *reflect_field_new(fieldinfo *f)
-{
- vm_abort("reflect_field_new: Not implemented.");
- return NULL;
-}
-
-java_handle_t *reflect_method_new(methodinfo *m)
-{
- vm_abort("reflect_method_new: Not implemented.");
- return NULL;
-}
-
-
-/* resolve ********************************************************************/
-
-void resolve_handle_pending_exception(bool throwError)
-{
- vm_abort("resolve_handle_pending_exception: Not implemented.");
-}
-
-bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
-{
- abort();
-
- return false;
-}
-
-/* stupid resolving implementation used by resolve_classref_or_classinfo_eager */
-/* This function does eager resolving without any access checks. */
-
-static classinfo * dummy_resolve_class_from_name(classinfo *referer,
- utf *classname,
- bool checkaccess)
-{
- classinfo *cls = NULL;
- char *utf_ptr;
- int len;
-
- assert(referer);
- assert(classname);
-
- /* lookup if this class has already been loaded */
-
- cls = classcache_lookup(referer->classloader, classname);
-
- if (!cls) {
- /* resolve array types */
-
- if (classname->text[0] == '[') {
- utf_ptr = classname->text + 1;
- len = classname->blength - 1;
-
- /* classname is an array type name */
-
- switch (*utf_ptr) {
- case 'L':
- utf_ptr++;
- len -= 2;
- /* FALLTHROUGH */
- case '[':
- /* the component type is a reference type */
- /* resolve the component type */
- if ((cls = dummy_resolve_class_from_name(referer,
- utf_new(utf_ptr,len),
- checkaccess)) == NULL)
- return NULL; /* exception */
-
- /* create the array class */
- cls = class_array_of(cls,false);
- if (!cls)
- return NULL; /* exception */
- }
- }
-
- /* load the class */
- if (!cls) {
- if (!(cls = load_class_from_classloader(classname,
- referer->classloader)))
- return false; /* exception */
- }
- }
-
- /* the class is now loaded */
- assert(cls);
- assert(cls->state & CLASS_LOADED);
-
- return cls;
-}
-
-
-classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls,
- bool checkaccess)
-{
- classinfo *c;
-
- assert(cls.any);
-
- if (IS_CLASSREF(cls)) {
- /* we must resolve this reference */
-
- if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name,
- checkaccess)) == NULL)
- return NULL;
- }
- else {
- /* cls has already been resolved */
- c = cls.cls;
- }
-
- assert(c);
- assert(c->state & CLASS_LOADED);
-
- /* succeeded */
- return c;
-}
-
-
-/* stacktrace *****************************************************************/
-
-java_handle_objectarray_t *stacktrace_getClassContext()
-{
- return NULL;
-}
-
-
-/* threads ********************************************************************/
-
-#if defined(HAVE___THREAD)
-__thread threadobject *thread_current;
-#else
-#include <pthread.h>
-pthread_key_t thread_current_key;
-#endif
-
-intptr_t threads_get_current_tid(void)
-{
- return 0;
-}
-
-void threads_cast_stopworld(void)
-{
-}
-
-void threads_cast_startworld(void)
-{
-}
-
-
-/* vm *************************************************************************/
-
-void vm_printconfig(void)
-{
-}
-
-void vm_abort(const char *text, ...)
-{
- va_list ap;
-
- va_start(ap, text);
- vfprintf(stderr, text, ap);
- va_end(ap);
-
- os::abort();
-}
-
-void vm_abort_errno(const char *text, ...)
-{
- va_list ap;
-
- va_start(ap, text);
- vm_abort_errnum(errno, text, ap);
- va_end(ap);
-}
-
-void vm_abort_errnum(int errnum, const char *text, ...)
-{
- va_list ap;
-
- log_start();
-
- va_start(ap, text);
- log_vprint(text, ap);
- va_end(ap);
-
- log_print(": %s", os::strerror(errnum));
- log_finish();
-
- os::abort();
-}
-
-java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...)
-{
- return NULL;
-}
-
-
-/* XXX */
-
-void stringtable_update(void)
-{
- log_println("stringtable_update: REMOVE ME!");
-}
-
-java_object_t *literalstring_new(utf *u)
-{
- log_println("literalstring_new: REMOVE ME!");
-
- return NULL;
-}
-
-
-void print_dynamic_super_statistics(void)
-{
-}
-
-
-#if defined(ENABLE_VMLOG)
-void vmlog_cacao_set_prefix(const char *arg)
-{
-}
-
-void vmlog_cacao_set_stringprefix(const char *arg)
-{
-}
-
-void vmlog_cacao_set_ignoreprefix(const char *arg)
-{
-}
-#endif
-
-
-/* Legacy C interface *********************************************************/
-
-bool VM_is_initializing() { return true; }
-
-} // extern "C"
-
-
-/*
- * 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/cacaoh/headers.c - functions for header generation
-
- Copyright (C) 1996-2005, 2006, 2007, 2008
- CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
- 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 <assert.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(ENABLE_THREADS)
-# if defined(__DARWIN__)
-# include <signal.h>
-# endif
-# include <ucontext.h>
-#endif
-
-#include "mm/gc.hpp"
-#include "mm/memory.h"
-
-#include "toolbox/chain.h"
-#include "toolbox/logging.h"
-
-#include "vm/builtin.h"
-#include "vm/global.h"
-#include "vm/string.hpp"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-
-
-/************************ global variables **********************/
-
-#define ACC_NATIVELY_OVERLOADED 0x10000000
-
-#if defined(ENABLE_HANDLES)
-# define HEAP_PREFIX "heap_"
-#else
-# define HEAP_PREFIX ""
-#endif
-
-chain *ident_chain; /* chain with method and field names in current class */
-FILE *file = NULL;
-static uint32_t outputsize;
-static bool dopadding;
-
-
-static void printIDpart(int c)
-{
- if ((c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') ||
- (c >= '0' && c <= '9') ||
- (c == '_'))
- putc(c, file);
- else
- putc('_', file);
-}
-
-
-void printID(utf *u)
-{
- char *utf_ptr = u->text;
- int i;
-
- for (i = 0; i < utf_get_number_of_u2s(u); i++)
- printIDpart(utf_nextu2(&utf_ptr));
-}
-
-
-static void addoutputsize(int len)
-{
- uint32_t newsize;
- int32_t i;
-
- if (!dopadding)
- return;
-
- newsize = MEMORY_ALIGN(outputsize, len);
-
- for (i = outputsize; i < newsize; i++)
- fprintf(file, " uint8_t pad%d\n", (int) i);
-
- outputsize = newsize;
-}
-
-
-void printOverloadPart(utf *desc)
-{
- char *utf_ptr=desc->text;
- uint16_t c;
-
- fprintf(file, "__");
-
- while ((c = utf_nextu2(&utf_ptr)) != ')') {
- switch (c) {
- case 'I':
- case 'S':
- case 'B':
- case 'C':
- case 'Z':
- case 'J':
- case 'F':
- case 'D':
- fprintf(file, "%c", (char) c);
- break;
- case '[':
- fprintf(file, "_3");
- break;
- case 'L':
- putc('L', file);
- while ((c = utf_nextu2(&utf_ptr)) != ';')
- printIDpart(c);
- fprintf(file, "_2");
- break;
- case '(':
- break;
- default:
- log_text("invalid method descriptor");
- assert(0);
- }
- }
-}
-
-static char *printtype(char *utf_ptr, char *prefix, char *infix)
-{
- uint16_t c;
-
- switch (utf_nextu2(&utf_ptr)) {
- case 'V':
- fprintf(file, "void");
- break;
- case 'I':
- case 'S':
- case 'B':
- case 'C':
- case 'Z':
- addoutputsize(4);
- fprintf(file, "int32_t");
- break;
- case 'J':
- addoutputsize(8);
- fprintf(file, "int64_t");
- break;
- case 'F':
- addoutputsize(4);
- fprintf(file, "float");
- break;
- case 'D':
- addoutputsize(8);
- fprintf(file, "double");
- break;
- case '[':
- addoutputsize ( sizeof(java_array_t*) );
- switch (utf_nextu2(&utf_ptr)) {
- case 'I': fprintf (file, "java%s_intarray_t*", infix); break;
- case 'J': fprintf (file, "java%s_longarray_t*", infix); break;
- case 'Z': fprintf (file, "java%s_booleanarray_t*", infix); break;
- case 'B': fprintf (file, "java%s_bytearray_t*", infix); break;
- case 'S': fprintf (file, "java%s_shortarray_t*", infix); break;
- case 'C': fprintf (file, "java%s_chararray_t*", infix); break;
- case 'F': fprintf (file, "java%s_floatarray_t*", infix); break;
- case 'D': fprintf (file, "java%s_doublearray_t*", infix); break;
-
- case '[': fprintf(file, "java%s_objectarray_t*", infix);
- while ((c = utf_nextu2(&utf_ptr)) == '[');
- if (c == 'L')
- while (utf_nextu2(&utf_ptr) != ';');
- break;
-
- case 'L': fprintf(file, "java%s_objectarray_t*", infix);
- while (utf_nextu2(&utf_ptr) != ';');
- break;
- default:
- log_text("invalid type descriptor");
- assert(0);
- }
- break;
-
- case 'L':
- addoutputsize ( sizeof(java_object_t*));
- fprintf (file, "struct %s", prefix);
- while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c);
- fprintf (file, "*");
- break;
-
- default:
- log_text("Unknown type in field descriptor");
- assert(0);
- }
-
- return utf_ptr;
-}
-
-
-/***** determine the number of entries of a utf string in the ident chain *****/
-
-static int searchidentchain_utf(utf *ident)
-{
- utf *u = chain_first(ident_chain); /* first element of list */
- int count = 0;
-
- while (u) {
- if (u==ident) count++; /* string found */
- u = chain_next(ident_chain); /* next element in list */
- }
-
- return count;
-}
-
-
-/************** print structure for direct access to objects ******************/
-
-static void printfields(classinfo *c)
-{
- int32_t i;
- fieldinfo *f;
- int ident_count;
-
- if (!c) {
- addoutputsize(sizeof(java_object_t));
- fprintf(file, " java_object_t header;\n");
- return;
- }
-
- printfields(c->super);
-
- for (i = 0; i < c->fieldscount; i++) {
- f = &(c->fields[i]);
-
- if (!(f->flags & ACC_STATIC)) {
- fprintf(file, " ");
- printtype(f->descriptor->text, HEAP_PREFIX, "");
- fprintf(file, " ");
- utf_fprint_printable_ascii(file, f->name);
-
- /* rename multiple fieldnames */
- if ((ident_count = searchidentchain_utf(f->name)))
- fprintf(file, "%d", ident_count - 1);
- chain_addlast(ident_chain, f->name);
-
- fprintf(file, ";\n");
- }
- }
-}
-
-
-/***************** store prototype for native method in file ******************/
-
-void printmethod(methodinfo *m)
-{
- char *utf_ptr;
- int32_t paramnum = 1;
-
- /* search for return-type in descriptor */
- utf_ptr = m->descriptor->text;
- while (utf_nextu2(&utf_ptr) != ')');
-
- /* create remarks */
- fprintf(file, "\n/*\n * Class: ");
- utf_fprint_printable_ascii(file, m->clazz->name);
- fprintf(file, "\n * Method: ");
- utf_fprint_printable_ascii(file, m->name);
- fprintf(file, "\n * Signature: ");
- utf_fprint_printable_ascii(file, m->descriptor);
- fprintf(file, "\n */\n");
-
- /* create prototype */
- fprintf(file, "JNIEXPORT ");
- printtype(utf_ptr, "", "_handle");
- fprintf(file, " JNICALL Java_");
- printID(m->clazz->name);
-
- chain_addlast(ident_chain, m->name);
-
- fprintf(file, "_");
- printID(m->name);
-
- /* ATTENTION: We use a dummy flag here. */
-
- if (m->flags & ACC_NATIVELY_OVERLOADED)
- printOverloadPart(m->descriptor);
-
- fprintf(file, "(JNIEnv *env");
-
- utf_ptr = m->descriptor->text + 1;
-
- if (!(m->flags & ACC_STATIC)) {
- fprintf(file, ", struct ");
- printID(m->clazz->name);
- fprintf(file, "* _this");
-
- } else {
- fprintf(file, ", jclass clazz");
- }
-
- if ((*utf_ptr) != ')') fprintf(file, ", ");
-
- while ((*utf_ptr) != ')') {
- utf_ptr = printtype(utf_ptr, "", "_handle");
- fprintf(file, " par%d", paramnum++);
- if ((*utf_ptr)!=')') fprintf(file, ", ");
- }
-
- fprintf(file, ");\n\n");
-}
-
-
-/******* remove package-name in fully-qualified classname *********************/
-
-void gen_header_filename(char *buffer, utf *u)
-{
- int32_t i;
-
- for (i = 0; i < utf_get_number_of_u2s(u); i++) {
- if ((u->text[i] == '/') || (u->text[i] == '$')) {
- buffer[i] = '_'; /* convert '$' and '/' to '_' */
-
- } else {
- buffer[i] = u->text[i];
- }
- }
- buffer[utf_get_number_of_u2s(u)] = '\0';
-}
-
-
-/* create headerfile for classes and store native methods in chain ************/
-
-void headerfile_generate(classinfo *c, char *opt_directory)
-{
- char header_filename[1024] = "";
- char classname[1024];
- char uclassname[1024];
- int32_t i;
- methodinfo *m;
- int32_t j;
- methodinfo *m2;
- bool nativelyoverloaded;
-
- /* prevent compiler warnings */
-
- nativelyoverloaded = false;
-
- /* open headerfile for class */
- gen_header_filename(classname, c->name);
-
- /* create chain for renaming fields */
- ident_chain = chain_new();
-
- if (opt_directory) {
- sprintf(header_filename, "%s/%s.h", opt_directory, classname);
-
- } else {
- sprintf(header_filename, "%s.h", classname);
- }
-
- file = fopen(header_filename, "w");
- if (!file) {
- log_text("Can not open file to store header information");
- assert(0);
- }
-
- fprintf(file, "/* This file is machine generated, don't edit it! */\n\n");
-
- /* convert to uppercase */
- for (i = 0; classname[i]; i++) {
- uclassname[i] = toupper(classname[i]);
- }
- uclassname[i] = '\0';
-
- fprintf(file, "#ifndef _%s_H\n#define _%s_H\n\n", uclassname, uclassname);
-
- /* create structure for direct access to objects */
- fprintf(file, "/* Structure information for class: ");
- utf_fprint_printable_ascii(file, c->name);
- fprintf(file, " */\n\n");
- fprintf(file, "typedef struct %s", HEAP_PREFIX);
- printID(c->name);
- fprintf(file, " {\n");
- outputsize = 0;
- dopadding = true;
-
- printfields(c);
-
- fprintf(file, "} %s", HEAP_PREFIX);
- printID(c->name);
- fprintf(file, ";\n\n");
-
-#if defined(ENABLE_HANDLES)
- /* create structure for indirection cell */
- fprintf(file, "typedef struct ");
- printID(c->name);
- fprintf(file, " {\n");
- fprintf(file, " %s", HEAP_PREFIX);
- printID(c->name);
- fprintf(file, " *heap_object;\n");
- fprintf(file, "} ");
- printID(c->name);
- fprintf(file, ";\n\n");
-#endif
-
- /* create chain for renaming overloaded methods */
- chain_free(ident_chain);
- ident_chain = chain_new();
-
- /* create method-prototypes */
-
- /* find overloaded methods */
-
- for (i = 0; i < c->methodscount; i++) {
- m = &(c->methods[i]);
-
- if (!(m->flags & ACC_NATIVE))
- continue;
-
- /* We use a dummy flag here. */
-
- if (!(m->flags & ACC_NATIVELY_OVERLOADED)) {
- nativelyoverloaded = false;
-
- for (j = i + 1; j < c->methodscount; j++) {
- m2 = &(c->methods[j]);
-
- if (!(m2->flags & ACC_NATIVE))
- continue;
-
- if (m->name == m2->name) {
- m2->flags |= ACC_NATIVELY_OVERLOADED;
- nativelyoverloaded = true;
- }
- }
- }
-
- if (nativelyoverloaded == true)
- m->flags |= ACC_NATIVELY_OVERLOADED;
- }
-
- for (i = 0; i < c->methodscount; i++) {
- m = &(c->methods[i]);
-
- if (m->flags & ACC_NATIVE)
- printmethod(m);
- }
-
- chain_free(ident_chain);
-
- fprintf(file, "#endif\n\n");
-
- fclose(file);
-}
-
-
-/******** print classname, '$' used to seperate inner-class name ***********/
-
-void print_classname(classinfo *clazz)
-{
- utf *u = clazz->name;
- char *endpos = u->text + u->blength;
- char *utf_ptr = u->text;
- uint16_t c;
-
- while (utf_ptr < endpos) {
- if ((c = utf_nextu2(&utf_ptr)) == '_')
- putc('$', file);
- else
- putc(c, file);
- }
-}
-
-
-/*
- * 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/cacaoh/headers.h - export functions for header generation
-
- 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
-
- 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 _HEADERS_H
-#define _HEADERS_H
-
-#include "config.h"
-
-#include "toolbox/chain.h"
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/utf8.h"
-
-
-/* export variables ***********************************************************/
-
-extern chain *nativemethod_chain;
-extern chain *nativeclass_chain;
-extern chain *ident_chain;
-extern FILE *file;
-
-
-/* function prototypes ********************************************************/
-
-void printID(utf *u);
-void printOverloadPart(utf *desc);
-void printmethod(methodinfo *m);
-void gen_header_filename(char *buffer, utf *u);
-void headerfile_generate(classinfo *c, char *opt_directory);
-void print_classname(classinfo *clazz);
-
-#endif /* _HEADERS_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:
- */
LIBS =
SUBDIRS = \
- include \
vm
if ENABLE_JVMTI
## 02110-1301, USA.
-JAVAH = $(CACAOH)
-JAVAHCMD = $(JAVAH) -bootclasspath $(BOOTCLASSPATH)
+JAVAH = javah
+JAVAHCMD = $(JAVAH) -jni -bootclasspath $(BOOTCLASSPATH)
-COMMON_HEADER_FILES = \
- java_lang_Class.h \
- java_lang_Object.h \
- java_lang_String.h \
- java_lang_Thread.h \
- java_lang_Throwable.h \
- \
- java_io_InputStream.h \
- java_io_PrintStream.h \
- \
- java_lang_Boolean.h \
- java_lang_Byte.h \
- java_lang_Character.h \
- java_lang_Double.h \
- java_lang_Float.h \
- java_lang_Integer.h \
- java_lang_Long.h \
- java_lang_Short.h
-
-JAVASE_HEADER_FILES = \
- java_lang_ClassLoader.h \
- java_lang_Cloneable.h \
- java_lang_ThreadGroup.h \
- java_util_Properties.h \
- \
- java_lang_Process.h \
- java_lang_StackTraceElement.h \
- java_lang_reflect_Constructor.h \
- java_lang_reflect_Field.h \
- java_lang_reflect_Method.h \
- java_nio_Buffer.h \
- java_security_ProtectionDomain.h \
- java_util_HashMap.h \
- java_util_Map.h \
- java_util_concurrent_atomic_AtomicLong.h \
- sun_misc_Unsafe.h
-
-if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
-JAVASE_HEADER_FILES += \
- java_lang_VMThread.h \
- java_lang_VMThrowable.h \
- \
- gnu_classpath_Pointer.h \
- gnu_classpath_Pointer32.h \
- gnu_classpath_Pointer64.h \
- gnu_java_lang_VMCPStringBuilder.h \
- java_lang_VMObject.h \
- java_lang_reflect_VMConstructor.h \
- java_lang_reflect_VMField.h \
- java_lang_reflect_VMMethod.h \
- java_nio_DirectByteBufferImpl.h
-
-if ENABLE_ANNOTATIONS
-JAVASE_HEADER_FILES += \
- sun_reflect_ConstantPool.h
-endif
-endif
-
-if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
-JAVASE_HEADER_FILES += \
- java_lang_AssertionStatusDirectives.h \
- java_nio_ByteBuffer.h \
- sun_reflect_ConstantPool.h
-endif
-
-JAVAME_CLDC1_1_HEADER_FILES = \
+if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
+IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
com_sun_cldc_io_ResourceInputStream.h \
com_sun_cldc_io_j2me_socket_Protocol.h \
com_sun_cldchi_io_ConsoleOutputStream.h \
com_sun_cldchi_jvm_FileDescriptor.h \
com_sun_cldchi_jvm_JVM.h \
+ java_lang_Class.h \
java_lang_Math.h \
java_lang_Runtime.h \
java_lang_System.h
-
-JVMTI_HEADER_FILES = \
- gnu_classpath_jdwp_VMFrame.h \
- gnu_classpath_jdwp_VMMethod.h \
- gnu_classpath_jdwp_VMVirtualMachine.h \
- gnu_classpath_jdwp_event_EventRequest.h \
- gnu_classpath_jdwp_util_VariableTable.h
+endif
if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
-ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
+IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
gnu_classpath_VMStackWalker.h \
gnu_classpath_VMSystemProperties.h \
+ gnu_java_lang_VMCPStringBuilder.h \
gnu_java_lang_management_VMClassLoadingMXBeanImpl.h \
gnu_java_lang_management_VMMemoryMXBeanImpl.h \
gnu_java_lang_management_VMRuntimeMXBeanImpl.h \
gnu_java_lang_management_VMThreadMXBeanImpl.h \
java_lang_VMClass.h \
java_lang_VMClassLoader.h \
+ java_lang_VMObject.h \
java_lang_VMRuntime.h \
java_lang_VMString.h \
java_lang_VMSystem.h \
- java_lang_management_MemoryUsage.h \
- java_lang_management_ThreadInfo.h \
+ java_lang_VMThread.h \
+ java_lang_VMThrowable.h \
java_lang_management_VMManagementFactory.h \
+ java_lang_reflect_VMConstructor.h \
+ java_lang_reflect_VMField.h \
+ java_lang_reflect_VMMethod.h \
java_lang_reflect_VMProxy.h \
- java_security_VMAccessController.h
-endif
-
-CLEANFILES = \
- *.h
-
-DO_HEADER_FILES = \
- $(COMMON_HEADER_FILES)
+ java_security_VMAccessController.h \
+ java_util_concurrent_atomic_AtomicLong.h \
+ sun_misc_Unsafe.h
-if ENABLE_JAVASE
-DO_HEADER_FILES += \
- $(JAVASE_HEADER_FILES) \
- $(ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES)
+if ENABLE_ANNOTATIONS
+IMPLEMENTED_VM_CLASSES_HEADER_FILES += \
+ sun_reflect_ConstantPool.h
+endif
endif
-if ENABLE_JAVAME_CLDC1_1
-DO_HEADER_FILES += \
- $(JAVAME_CLDC1_1_HEADER_FILES)
+if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
+IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
+ sun_misc_Unsafe.h
endif
if ENABLE_JVMTI
-DO_HEADER_FILES += \
- $(GEN_JVMTI_HEADER_FILES)
+JVMTI_HEADER_FILES = \
+ gnu_classpath_jdwp_VMFrame.h \
+ gnu_classpath_jdwp_VMMethod.h \
+ gnu_classpath_jdwp_VMVirtualMachine.h \
+ gnu_classpath_jdwp_event_EventRequest.h \
+ gnu_classpath_jdwp_util_VariableTable.h
endif
+CLEANFILES = \
+ *.h
+
+DO_HEADER_FILES = \
+ $(IMPLEMENTED_VM_CLASSES_HEADER_FILES)
+
if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
if ENABLE_ZLIB
VM_ZIP = $(top_builddir)/src/classes/vm.zip
#include "native/localref.h"
#include "native/native.h"
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/gnu_classpath_Pointer.h"
-
-# if SIZEOF_VOID_P == 8
-# include "native/include/gnu_classpath_Pointer64.h"
-# else
-# include "native/include/gnu_classpath_Pointer32.h"
-# endif
-# endif
-#endif
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(ENABLE_JAVASE)
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-# endif
-
-/* java_lang_ClassLoader is used in java_lang_Class and vice versa, so
- we pre-define it here to prevent a compiler warning for Sun
- configurations. */
-
-struct java_lang_ClassLoader;
-
-# include "native/include/java_lang_Class.h"
-# include "native/include/java_lang_ClassLoader.h"
-
-# include "native/include/java_lang_reflect_Constructor.h"
-# include "native/include/java_lang_reflect_Field.h"
-# include "native/include/java_lang_reflect_Method.h"
-
-# include "native/include/java_nio_Buffer.h"
-
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_reflect_VMConstructor.h"
-# include "native/include/java_lang_reflect_VMField.h"
-# include "native/include/java_lang_reflect_VMMethod.h"
-
-# include "native/include/java_nio_DirectByteBufferImpl.h"
-# endif
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-# include "native/include/java_lang_Class.h"
-#endif
-
#if defined(ENABLE_JVMTI)
# include "native/jvmti/cacaodbg.h"
#endif
-#if defined(ENABLE_JAVASE)
-# include "native/vm/reflect.h"
-#endif
-
#include "threads/lock-common.h"
#include "threads/thread.hpp"
#include "vm/jit/stacktrace.hpp"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/loader.h"
#include "vmcore/options.h"
#include "vmcore/statistics.h"
*******************************************************************************/
-jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
- const jbyte *buf, jsize bufLen)
+jclass jni_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize bufLen)
{
#if defined(ENABLE_JAVASE)
- utf *u;
- classloader_t *cl;
- classinfo *c;
- java_lang_Class *co;
+ utf *u;
+ classloader_t *cl;
+ classinfo *c;
+ java_handle_t* h;
- TRACEJNICALLS(("_Jv_JNI_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d)", env, name, loader, buf, bufLen));
+ TRACEJNICALLS(("jni_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d)", env, name, loader, buf, bufLen));
u = utf_new_char(name);
cl = loader_hashtable_classloader_add((java_handle_t *) loader);
c = class_define(u, cl, bufLen, (uint8_t *) buf, NULL);
- co = LLNI_classinfo_wrap(c);
+ h = LLNI_classinfo_wrap(c);
- return (jclass) jni_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) h);
#else
- vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration");
+ vm_abort("jni_DefineClass: Not implemented in this configuration");
- /* keep compiler happy */
+ // Keep compiler happy.
return 0;
#endif
{
#if defined(ENABLE_JAVASE)
- utf *u;
- classinfo *cc;
- classinfo *c;
- java_lang_Class *co;
+ utf* u;
+ classinfo* cc;
+ classinfo* c;
+ java_handle_t* h;
TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name));
if (!link_class(c))
return NULL;
- co = LLNI_classinfo_wrap(c);
+ h = LLNI_classinfo_wrap(c);
- return (jclass) jni_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) h);
#elif defined(ENABLE_JAVAME_CLDC1_1)
*******************************************************************************/
-jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
+jclass jni_GetSuperclass(JNIEnv *env, jclass sub)
{
- classinfo *c;
- classinfo *super;
- java_lang_Class *co;
+ classinfo* c;
+ classinfo* super;
- TRACEJNICALLS(("_Jv_JNI_GetSuperclass(env=%p, sub=%p)", env, sub));
+ TRACEJNICALLS(("jni_GetSuperclass(env=%p, sub=%p)", env, sub));
c = LLNI_classinfo_unwrap(sub);
super = class_get_superclass(c);
- co = LLNI_classinfo_wrap(super);
+ java_handle_t* h = LLNI_classinfo_wrap(super);
- return (jclass) jni_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) h);
}
*******************************************************************************/
-jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj)
+jclass jni_GetObjectClass(JNIEnv *env, jobject obj)
{
- java_handle_t *o;
- classinfo *c;
- java_lang_Class *co;
+ java_handle_t* o;
+ classinfo* c;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_GetObjectClass(env=%p, obj=%p)", env, obj));
o = (java_handle_t *) obj;
LLNI_class_get(o, c);
- co = LLNI_classinfo_wrap(c);
+ java_handle_t* h = LLNI_classinfo_wrap(c);
- return (jclass) jni_NewLocalRef(env, (jobject) co);
+ return (jclass) jni_NewLocalRef(env, (jobject) h);
}
jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
{
#if defined(ENABLE_JAVASE)
- java_handle_t *o;
- java_lang_reflect_Method *rm;
- java_lang_reflect_Constructor *rc;
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMMethod *rvmm;
- java_lang_reflect_VMConstructor *rvmc;
-#endif
+ java_handle_t* o;
+ methodinfo* m;
TRACEJNICALLS(("jni_FromReflectedMethod(env=%p, method=%p)", env, method));
if (o == NULL)
return NULL;
+ // FIXME We can't access the object here directly.
if (o->vftbl->clazz == class_java_lang_reflect_Constructor) {
- rc = (java_lang_reflect_Constructor *) method;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- LLNI_field_get_ref(rc, cons , rvmc);
- LLNI_field_get_cls(rvmc, clazz, c);
- LLNI_field_get_val(rvmc, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
- LLNI_field_get_cls(rc, clazz, c);
- LLNI_field_get_val(rc, slot , slot);
-
-#else
-# error unknown configuration
-#endif
+ java_lang_reflect_Constructor rc(method);
+ m = rc.get_method();
}
else {
+ // FIXME We can't access the object here directly.
assert(o->vftbl->clazz == class_java_lang_reflect_Method);
- rm = (java_lang_reflect_Method *) method;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- LLNI_field_get_ref(rm, m , rvmm);
- LLNI_field_get_cls(rvmm, clazz, c);
- LLNI_field_get_val(rvmm, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
- LLNI_field_get_cls(rm, clazz, c);
- LLNI_field_get_val(rm, slot , slot);
-
-#else
-# error unknown configuration
-#endif
+ java_lang_reflect_Method rm(method);
+ m = rm.get_method();
}
- m = &(c->methods[slot]);
-
return (jmethodID) m;
#else
vm_abort("jni_FromReflectedMethod: Not implemented in this configuration.");
- /* Keep compiler happy. */
-
+ // Keep compiler happy.
return NULL;
#endif
}
jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
{
#if defined(ENABLE_JAVASE)
- java_lang_reflect_Field *rf;
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMField *rvmf;
-#endif
TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field));
- rf = (java_lang_reflect_Field *) field;
+ java_lang_reflect_Field rf(field);
- if (rf == NULL)
+ if (rf.is_null())
return NULL;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- LLNI_field_get_ref(rf, f, rvmf);
- LLNI_field_get_cls(rvmf, clazz, c);
- LLNI_field_get_val(rvmf, slot , slot);
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
- LLNI_field_get_cls(rf, clazz, c);
- LLNI_field_get_val(rf, slot , slot);
-
-#else
-# error unknown configuration
-#endif
-
- f = &(c->fields[slot]);
+ fieldinfo* f = rf.get_field();
return (jfieldID) f;
#else
vm_abort("jni_FromReflectedField: Not implemented in this configuration.");
- /* Keep compiler happy. */
-
+ // Keep compiler happy.
return NULL;
#endif
}
*******************************************************************************/
-jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID,
- jboolean isStatic)
+jobject jni_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic)
{
#if defined(ENABLE_JAVASE)
- methodinfo *m;
- java_lang_reflect_Constructor *rc;
- java_lang_reflect_Method *rm;
+ TRACEJNICALLS(("jni_ToReflectedMethod(env=%p, cls=%p, methodID=%p, isStatic=%d)", env, cls, methodID, isStatic));
- TRACEJNICALLS(("_Jv_JNI_ToReflectedMethod(env=%p, cls=%p, methodID=%p, isStatic=%d)", env, cls, methodID, isStatic));
-
- m = (methodinfo *) methodID;
+ methodinfo* m = (methodinfo *) methodID;
/* HotSpot does the same assert. */
assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0));
- if (m->name == utf_init) {
- rc = reflect_constructor_new(m);
+ java_handle_t* h;
- return (jobject) rc;
+ if (m->name == utf_init) {
+ h = java_lang_reflect_Constructor(m).get_handle();
}
else {
- rm = reflect_method_new(m);
-
- return (jobject) rm;
+ h = java_lang_reflect_Method(m).get_handle();
}
+
+ return (jobject) h;
#else
- vm_abort("_Jv_JNI_ToReflectedMethod: not implemented in this configuration");
+ vm_abort("jni_ToReflectedMethod: Not implemented in this configuration.");
/* keep compiler happy */
*******************************************************************************/
-jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len)
+jstring jni_NewString(JNIEnv *env, const jchar *buf, jsize len)
{
- java_lang_String *s;
- java_handle_chararray_t *a;
- int32_t i;
-
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_NewString(env=%p, buf=%p, len=%d)", env, buf, len));
- s = (java_lang_String *) builtin_new(class_java_lang_String);
- a = builtin_newarray_char(len);
+ java_handle_chararray_t* a = builtin_newarray_char(len);
- /* javastring or characterarray could not be created */
- if ((a == NULL) || (s == NULL))
+ if (a == NULL)
return NULL;
/* copy text */
- for (i = 0; i < len; i++)
+ for (jsize i = 0; i < len; i++)
LLNI_array_direct(a, i) = buf[i];
- LLNI_field_set_ref(s, value , a);
- LLNI_field_set_val(s, offset, 0);
- LLNI_field_set_val(s, count , len);
+ java_handle_t* h = builtin_new(class_java_lang_String);
+
+ if (h == NULL)
+ return NULL;
- return (jstring) jni_NewLocalRef(env, (jobject) s);
+ java_lang_String s(h, a, len, 0);
+
+ return (jstring) jni_NewLocalRef(env, (jobject) s.get_handle());
}
*******************************************************************************/
-jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
+jsize jni_GetStringLength(JNIEnv *env, jstring str)
{
- java_lang_String *s;
- jsize len;
-
- TRACEJNICALLS(("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str));
+ TRACEJNICALLSENTER(("jni_GetStringLength(env=%p, str=%p)", env, str));
- s = (java_lang_String *) str;
+ java_lang_String s(str);
+ jsize count = s.get_count();
- LLNI_field_get_val(s, count, len);
+ TRACEJNICALLSEXIT(("->%d)", count));
- return len;
+ return count;
}
const jchar* jni_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy)
{
- java_lang_String *s;
- java_handle_chararray_t *a;
- u2 *stringbuffer;
- int32_t count;
- int32_t offset;
- int32_t i;
+ u2 *stringbuffer;
+ int32_t i;
TRACEJNICALLS(("jni_GetStringChars(env=%p, str=%p, isCopy=%p)", env, str, isCopy));
// FIXME This is really ugly.
return emptyStringJ;
- s = (java_lang_String *) str;
-
- LLNI_field_get_ref(s, value, a);
+ java_lang_String s(str);
- if (a == NULL)
+ java_handle_chararray_t* ca = s.get_value();
+ int32_t count = s.get_count();
+ int32_t offset = s.get_offset();
+
+ if (ca == NULL)
return NULL;
- LLNI_field_get_val(s, count, count);
- LLNI_field_get_val(s, offset, offset);
-
/* allocate memory */
stringbuffer = MNEW(u2, count + 1);
/* copy text */
for (i = 0; i < count; i++)
- stringbuffer[i] = LLNI_array_direct(a, offset + i);
+ stringbuffer[i] = LLNI_array_direct(ca, offset + i);
/* terminate string */
void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)
{
- java_lang_String *s;
-
- STATISTICS(jniinvokation());
+ TRACEJNICALLS(("jni_ReleaseStringChars(env=%p, str=%p, chars=%p)", env, str, chars));
+ // FIXME
if (chars == emptyStringJ)
return;
- s = (java_lang_String *) str;
+ java_lang_String s(str);
+ int32_t count = s.get_count();
- MFREE(((jchar *) chars), jchar, LLNI_field_direct(s, count) + 1);
+ MFREE(((jchar*) chars), jchar, count + 1);
}
*******************************************************************************/
-jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
+jstring jni_NewStringUTF(JNIEnv *env, const char *bytes)
{
- java_lang_String *s;
-
- TRACEJNICALLS(("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes));
+ TRACEJNICALLS(("jni_NewStringUTF(env=%p, bytes=%s)", env, bytes));
- s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
+ java_handle_t *h = javastring_safe_new_from_utf8(bytes);
- return (jstring) jni_NewLocalRef(env, (jobject) s);
+ return (jstring) jni_NewLocalRef(env, (jobject) h);
}
/****************** returns the utf8 length in bytes of a string *******************/
-jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string)
+jsize jni_GetStringUTFLength(JNIEnv *env, jstring string)
{
- java_lang_String *s;
- s4 length;
+ TRACEJNICALLS(("jni_GetStringUTFLength(env=%p, string=%p)", env, string));
- TRACEJNICALLS(("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string));
+ java_lang_String s(string);
+ java_handle_chararray_t* ca = s.get_value();
+ int32_t count = s.get_count();
- s = (java_lang_String *) string;
-
- length = u2_utflength(LLNI_field_direct(s, value)->data, LLNI_field_direct(s, count));
+ // FIXME GC critical section!
+ int32_t length = u2_utflength(ca->data, count);
return length;
}
*******************************************************************************/
-void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len,
- jchar *buf)
+void jni_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf)
{
- java_lang_String *s;
- java_handle_chararray_t *ca;
+ java_lang_String s(str);
+ java_handle_chararray_t* ca = s.get_value();
+ int32_t count = s.get_count();
- STATISTICS(jniinvokation());
-
- s = (java_lang_String *) str;
- LLNI_field_get_ref(s, value, ca);
-
- if ((start < 0) || (len < 0) || (start > LLNI_field_direct(s, count)) ||
- (start + len > LLNI_field_direct(s, count))) {
+ if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) {
exceptions_throw_stringindexoutofboundsexception();
return;
}
*******************************************************************************/
-void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start,
- jsize len, char *buf)
+void jni_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start, jsize len, char *buf)
{
- java_lang_String *s;
- java_handle_chararray_t *ca;
- s4 i;
- int32_t count;
- int32_t offset;
-
- TRACEJNICALLS(("_Jv_JNI_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf));
+ TRACEJNICALLS(("jni_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf));
- s = (java_lang_String *) str;
- LLNI_field_get_ref(s, value, ca);
- LLNI_field_get_val(s, count, count);
- LLNI_field_get_val(s, offset, offset);
+ java_lang_String s(str);
+ java_handle_chararray_t* ca = s.get_value();
+ int32_t count = s.get_count();
+ int32_t offset = s.get_offset();
if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) {
exceptions_throw_stringindexoutofboundsexception();
return;
}
+ int32_t i;
+
for (i = 0; i < len; i++)
buf[i] = LLNI_array_direct(ca, offset + start + i);
{
#if defined(ENABLE_JAVASE)
# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_handle_t *nbuf;
-
-# if SIZEOF_VOID_P == 8
- gnu_classpath_Pointer64 *paddress;
-# else
- gnu_classpath_Pointer32 *paddress;
-# endif
-
TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity));
- /* alocate a gnu.classpath.Pointer{32,64} object */
+ // Allocate a gnu.classpath.Pointer{32,64} object.
# if SIZEOF_VOID_P == 8
- if (!(paddress = (gnu_classpath_Pointer64 *)
- builtin_new(class_gnu_classpath_Pointer64)))
+ java_handle_t* h = builtin_new(class_gnu_classpath_Pointer64);
# else
- if (!(paddress = (gnu_classpath_Pointer32 *)
- builtin_new(class_gnu_classpath_Pointer32)))
+ java_handle_t* h = builtin_new(class_gnu_classpath_Pointer32);
# endif
- return NULL;
- /* fill gnu.classpath.Pointer{32,64} with address */
+ if (h == NULL)
+ return NULL;
- LLNI_field_set_val(paddress, data, (ptrint) address);
+ gnu_classpath_Pointer p(h, address);
- /* create a java.nio.DirectByteBufferImpl$ReadWrite object */
+ // Create a java.nio.DirectByteBufferImpl$ReadWrite object.
- nbuf = (java_handle_t*) jni_NewObject(env, (jclass) class_java_nio_DirectByteBufferImpl_ReadWrite,
- (jmethodID) dbbirw_init, NULL, paddress,
- (jint) capacity, (jint) capacity, (jint) 0);
+ java_handle_t* nbuf =
+ (java_handle_t*) jni_NewObject(env, (jclass) class_java_nio_DirectByteBufferImpl_ReadWrite,
+ (jmethodID) dbbirw_init, NULL, p.get_handle(),
+ (jint) capacity, (jint) capacity, (jint) 0);
- /* add local reference and return the value */
+ // Add a local reference and return the value.
TRACEJNICALLSEXIT(("->%p", nbuf));
*******************************************************************************/
-void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
+void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf)
{
#if defined(ENABLE_JAVASE)
- java_handle_t *h;
-
# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_nio_DirectByteBufferImpl *nbuf;
- gnu_classpath_Pointer *po;
-# if SIZEOF_VOID_P == 8
- gnu_classpath_Pointer64 *paddress;
- int64_t address;
-# else
- gnu_classpath_Pointer32 *paddress;
- int32_t address;
-# endif
- void *p;
-
- TRACEJNICALLSENTER(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
+ TRACEJNICALLSENTER(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
/* Prevent compiler warning. */
- h = (java_handle_t *) buf;
+ java_handle_t* h = (java_handle_t *) buf;
if ((h != NULL) && !builtin_instanceof(h, class_java_nio_Buffer))
return NULL;
- nbuf = (java_nio_DirectByteBufferImpl *) buf;
-
- LLNI_field_get_ref(nbuf, address, po);
+ java_nio_DirectByteBufferImpl dbb(buf);
+ java_handle_t* address = dbb.get_address();
-# if SIZEOF_VOID_P == 8
- paddress = (gnu_classpath_Pointer64 *) po;
-# else
- paddress = (gnu_classpath_Pointer32 *) po;
-# endif
-
- if (paddress == NULL) {
+ if (address == NULL) {
TRACEJNICALLSEXIT(("->%p", NULL));
return NULL;
}
- LLNI_field_get_val(paddress, data, address);
-
- p = (void *) (intptr_t) address;
+ gnu_classpath_Pointer p(address);
+ void* data = p.get_data();
- TRACEJNICALLSEXIT(("->%p", p));
+ TRACEJNICALLSEXIT(("->%p", data));
- return p;
+ return data;
# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- java_nio_Buffer *o;
- int64_t address;
- void *p;
+ TRACEJNICALLS(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
- TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
+ java_nio_Buffer jnb(buf);
- /* Prevent compiler warning. */
-
- h = (java_handle_t *) buf;
-
- if ((h != NULL) && !builtin_instanceof(h, class_sun_nio_ch_DirectBuffer))
+ if (jnb.is_non_null() && !builtin_instanceof(jnb.get_handle(), class_sun_nio_ch_DirectBuffer))
return NULL;
- o = (java_nio_Buffer *) buf;
-
- LLNI_field_get_val(o, address, address);
+ void* address = jnb.get_address();
- p = (void *) (intptr_t) address;
-
- return p;
+ return address;
# else
# error unknown classpath configuration
#else
- vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
-
- /* keep compiler happy */
+ vm_abort("jni_GetDirectBufferAddress: Not implemented in this configuration.");
+ // Keep compiler happy.
return NULL;
#endif
*******************************************************************************/
-jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
+jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
{
#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_handle_t *o;
- java_nio_Buffer *nbuf;
- jlong capacity;
+ TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf));
- STATISTICS(jniinvokation());
+ java_handle_t* h = (java_handle_t *) buf;
- o = (java_handle_t *) buf;
-
- if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl))
+ if (!builtin_instanceof(h, class_java_nio_DirectByteBufferImpl))
return -1;
- nbuf = (java_nio_Buffer *) o;
-
- LLNI_field_get_val(nbuf, cap, capacity);
+ java_nio_Buffer b(h);
+ jlong capacity = b.get_cap();
return capacity;
#else
- vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration");
+ vm_abort("jni_GetDirectBufferCapacity: not implemented in this configuration");
- /* keep compiler happy */
+ // Keep compiler happy.
return 0;
#endif
NULL,
_Jv_JNI_GetVersion,
- _Jv_JNI_DefineClass,
+ jni_DefineClass,
jni_FindClass,
jni_FromReflectedMethod,
jni_FromReflectedField,
- _Jv_JNI_ToReflectedMethod,
- _Jv_JNI_GetSuperclass,
+ jni_ToReflectedMethod,
+ jni_GetSuperclass,
_Jv_JNI_IsAssignableFrom,
_Jv_JNI_ToReflectedField,
_Jv_JNI_NewObjectV,
_Jv_JNI_NewObjectA,
- _Jv_JNI_GetObjectClass,
+ jni_GetObjectClass,
_Jv_JNI_IsInstanceOf,
_Jv_JNI_GetMethodID,
_Jv_JNI_SetStaticFloatField,
_Jv_JNI_SetStaticDoubleField,
- _Jv_JNI_NewString,
- _Jv_JNI_GetStringLength,
+ jni_NewString,
+ jni_GetStringLength,
jni_GetStringChars,
_Jv_JNI_ReleaseStringChars,
- _Jv_JNI_NewStringUTF,
- _Jv_JNI_GetStringUTFLength,
+ jni_NewStringUTF,
+ jni_GetStringUTFLength,
_Jv_JNI_GetStringUTFChars,
_Jv_JNI_ReleaseStringUTFChars,
/* New JNI 1.2 functions. */
- _Jv_JNI_GetStringRegion,
- _Jv_JNI_GetStringUTFRegion,
+ jni_GetStringRegion,
+ jni_GetStringUTFRegion,
jni_GetPrimitiveArrayCritical,
jni_ReleasePrimitiveArrayCritical,
/* New JNI 1.4 functions. */
jni_NewDirectByteBuffer,
- _Jv_JNI_GetDirectBufferAddress,
- _Jv_JNI_GetDirectBufferCapacity,
+ jni_GetDirectBufferAddress,
+ jni_GetDirectBufferCapacity,
/* New JNI 1.6 functions. */
* Emacs will automagically detect them.
* ---------------------------------------------------------------------
* Local variables:
- * mode: c
+ * mode: c++
* indent-tabs-mode: t
* c-basic-offset: 4
* tab-width: 4
#include "threads/thread.hpp"
-/* LLNI macros *****************************************************************
-
- The following macros should be used whenever a Java Object is
- accessed in native code without the use of an JNI function.
-
- LLNI_field_set_val, LLNI_field_get_val:
- Deal with primitive values like integer and float values. Do
- not use these macros to access pointers or references!
-
- LLNI_field_set_ref, LLNI_field_get_ref:
- Deal with references to other objects.
-
- LLNI_field_set_cls, LLNI_field_get_cls:
- Deal with references to Java Classes which are internally
- represented by classinfo or java_lang_Class.
-
-*******************************************************************************/
-
-#define LLNI_field_set_val(obj, field, value) \
- LLNI_field_direct(obj, field) = (value)
-
-#define LLNI_field_set_ref(obj, field, reference) \
- LLNI_field_direct(obj, field) = LLNI_UNWRAP(reference)
-
-#define LLNI_field_set_cls(obj, field, value) \
- LLNI_field_direct(obj, field) = (java_lang_Class *) (value)
-
-#define LLNI_field_get_val(obj, field, variable) \
- (variable) = LLNI_field_direct(obj, field)
-
-#define LLNI_field_get_ref(obj, field, variable) \
- (variable) = LLNI_WRAP(LLNI_field_direct(obj, field))
-
-#define LLNI_field_get_cls(obj, field, variable) \
- (variable) = (classinfo *) LLNI_field_direct(obj, field)
-
#define LLNI_class_get(obj, variable) \
(variable) = LLNI_field_direct((java_handle_t *) obj, vftbl->clazz)
*******************************************************************************/
#define LLNI_classinfo_wrap(classinfo) \
- ((java_lang_Class *) LLNI_WRAP(classinfo))
+ ((java_handle_t*) LLNI_WRAP(classinfo))
#define LLNI_classinfo_unwrap(clazz) \
((classinfo *) LLNI_UNWRAP((java_handle_t *) (clazz)))
endif
if ENABLE_JAVASE
-REFLECT_SOURCES = \
- reflect.c \
- reflect.h
+REFLECTION_SOURCES = \
+ reflection.c \
+ reflection.h
SUN_MISC_UNSAFE_SOURCES = \
sun_misc_Unsafe.cpp
libnativevm_la_SOURCES = \
nativevm.c \
nativevm.h \
- $(REFLECT_SOURCES) \
+ $(REFLECTION_SOURCES) \
$(SUN_MISC_UNSAFE_SOURCES)
libnativevm_la_LIBADD = \
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/com_sun_cldchi_jvm_FileDescriptor.h"
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldc_io_ResourceInputStream.h"
+#endif
-// FIXME
-extern "C" {
-#include "native/include/com_sun_cldc_io_ResourceInputStream.h"
-}
+#include "threads/lock-common.h"
#include "vm/types.h"
#include "vm/builtin.h"
#include "vm/exceptions.hpp"
#include "vm/string.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/zip.h"
-#include "threads/lock-common.h"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "open", (char*) "(Ljava/lang/String;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_open },
- { (char*) "bytesRemain", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain },
- { (char*) "readByte", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readByte },
- { (char*) "readBytes", (char*) "(Ljava/lang/Object;[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readBytes },
- { (char*) "clone", (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_clone },
-};
-
-/* _Jv_com_sun_cldc_io_ResourceInputStream_init ********************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_com_sun_cldc_io_ResourceInputStream_init(void)
-{
- utf *u;
-
- u = utf_new_char("com/sun/cldc/io/ResourceInputStream");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-static struct com_sun_cldchi_jvm_FileDescriptor* zip_read_resource(list_classpath_entry *lce, utf *name)
+static java_handle_t* zip_read_resource(list_classpath_entry *lce, utf *name)
{
hashtable_zipfile_entry *htzfe;
lfh lfh;
int err;
classinfo *ci;
- com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL;
/* try to find the class in the current archive */
htzfe->compressionmethod);
}
- /* Create a file descriptor object */
+ // Create a file descriptor object.
ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
- fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
- LLNI_field_set_val(fileDescriptor, pointer, (int64_t)outdata);
- LLNI_field_set_val(fileDescriptor, length, htzfe->uncompressedsize);
- LLNI_field_set_val(fileDescriptor, position, 0);
- return fileDescriptor;
-
+ java_handle_t* h = native_new_and_init(ci);
+
+ if (h == NULL)
+ return NULL;
+
+ com_sun_cldchi_jvm_FileDescriptor fd(h, (int64_t) outdata, 0, htzfe->uncompressedsize);
+
+ return fd.get_handle();
}
-static struct com_sun_cldchi_jvm_FileDescriptor* file_read_resource(char *path)
+
+static java_handle_t* file_read_resource(char *path)
{
int len;
struct stat statBuffer;
u1 *filep;
- com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL;
classinfo *ci;
int fd;
/* Create a file descriptor object */
ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
- fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
- LLNI_field_set_val(fileDescriptor, pointer, (int64_t)filep);
- LLNI_field_set_val(fileDescriptor, length, len);
- LLNI_field_set_val(fileDescriptor, position, 0);
-
- return fileDescriptor;
-
- } else {
+ java_handle_t* h = native_new_and_init(ci);
+
+ if (h == NULL)
+ return NULL;
+
+ com_sun_cldchi_jvm_FileDescriptor fd(h, (int64_t) filep, 0, len);
+
+ return fd.get_handle();
+ }
+ else {
return NULL;
}
-
}
* Method: open
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
-JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name)
+JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, jstring name)
{
-
list_classpath_entry *lce;
char *filename;
s4 filenamelen;
char *path;
utf *uname;
- com_sun_cldchi_jvm_FileDescriptor* descriptor;
+ java_handle_t* descriptor;
/* get the classname as char string (do it here for the warning at
the end of the function) */
if (descriptor != NULL) { /* file exists */
break;
}
-
#if defined(ENABLE_ZLIB)
}
#endif
-
}
MFREE(filename, char, filenamelen);
- return (java_lang_Object*) descriptor;
-
+ return (jobject) descriptor;
}
/*
- * Class: com_sun_cldc_io_ResourceInputStream
+ * Class: com/sun/cldc/io/ResourceInputStream
* Method: bytesRemain
* Signature: (Ljava/lang/Object;)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
-
- com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
- int32_t length;
- int32_t position;
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, jobject jobj)
+{
+ com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+ int32_t length = fd.get_position();
+ int32_t position = fd.get_length();
- fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
- LLNI_field_get_val(fileDescriptor, position, position);
- LLNI_field_get_val(fileDescriptor, length, length);
-
return length - position;
-
}
+
/*
- * Class: com_sun_cldc_io_ResourceInputStream
+ * Class: com/sun/cldc/io/ResourceInputStream
* Method: readByte
* Signature: (Ljava/lang/Object;)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
-
- com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
- u1 byte;
- int32_t length;
- int32_t position;
- int64_t filep;
-
- fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
- LLNI_field_get_val(fileDescriptor, position, position);
- LLNI_field_get_val(fileDescriptor, length, length);
- LLNI_field_get_val(fileDescriptor, pointer, filep);
-
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, jobject jobj)
+{
+ com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+
+ int64_t filep = fd.get_pointer();
+ int32_t position = fd.get_position();
+ int32_t length = fd.get_length();
+
+ uint8_t byte;
+
if (position < length) {
- byte = ((u1*)(int)filep)[position];
+ byte = ((uint8_t*) filep)[position];
position++;
- } else {
+ }
+ else {
return -1; /* EOF */
}
- /* Update access position */
- LLNI_field_set_val(fileDescriptor, position, position);
+ // Update access position.
+ fd.set_position(position);
return (byte & 0xFF);
-
}
+
/*
- * Class: com_sun_cldc_io_ResourceInputStream
+ * Class: com/sun/cldc/io/ResourceInputStream
* Method: readBytes
* Signature: (Ljava/lang/Object;[BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj, java_handle_bytearray_t* byteArray, s4 off, s4 len) {
-
- com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
- s4 readBytes = -1;
- int32_t fileLength;
- int32_t position;
- s4 available;
- int64_t filep;
- void *buf;
-
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, jobject jobj, jbyteArray byteArray, jint off, jint len)
+{
/* get pointer to the buffer */
- buf = &(LLNI_array_direct(byteArray, off));
-
- fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
- LLNI_field_get_val(fileDescriptor, position, position);
- LLNI_field_get_val(fileDescriptor, length, fileLength);
- LLNI_field_get_val(fileDescriptor, pointer, filep);
+ // XXX Not GC safe.
+ void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) byteArray, off));
+ com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+
+ int64_t filep = fd.get_pointer();
+ int32_t position = fd.get_position();
+ int32_t fileLength = fd.get_length();
+
+ int32_t readBytes = -1;
+
if (position < fileLength) {
- available = fileLength - position;
+ int32_t available = fileLength - position;
+
if (available < len) {
readBytes = available;
} else {
readBytes = len;
}
- memcpy(buf, ((u1*)(int)filep) + position, readBytes * sizeof(u1));
+
+ os::memcpy(buf, ((uint8_t*) filep) + position, readBytes * sizeof(uint8_t));
position += readBytes;
- } else {
+ }
+ else {
return -1; /* EOF */
}
- /* Update access position */
- LLNI_field_set_val(fileDescriptor, position, position);
+ // Update access position.
+ fd.set_position(position);
return readBytes;
}
+
/*
- * Class: com_sun_cldc_io_ResourceInputStream
+ * Class: com/sun/cldc/io/ResourceInputStream
* Method: clone
* Signature: (Ljava/lang/Object;)Ljava/lang/Object;
*/
-JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
-
- classinfo *ci;
- com_sun_cldchi_jvm_FileDescriptor *srcFileDescriptor;
- com_sun_cldchi_jvm_FileDescriptor *dstFileDescriptor;
- int32_t srcLength;
- int32_t srcPosition;
- int64_t srcFilePointer;
-
- srcFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
- LLNI_field_get_val(srcFileDescriptor, position, srcPosition);
- LLNI_field_get_val(srcFileDescriptor, length, srcLength);
- LLNI_field_get_val(srcFileDescriptor, pointer, srcFilePointer);
-
- ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
- dstFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
- LLNI_field_set_val(dstFileDescriptor, position, srcPosition);
- LLNI_field_set_val(dstFileDescriptor, length, srcLength);
- LLNI_field_set_val(dstFileDescriptor, pointer, srcFilePointer);
-
- return (java_lang_Object*) dstFileDescriptor;
+JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, jobject jobj)
+{
+ com_sun_cldchi_jvm_FileDescriptor fd(jobj);
+
+ classinfo* c = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
+ java_handle_t* h = native_new_and_init(c);
+
+ if (h == NULL)
+ return NULL;
+ com_sun_cldchi_jvm_FileDescriptor clonefd(h, fd);
+
+ return (jobject) clonefd.get_handle();
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "open", (char*) "(Ljava/lang/String;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_open },
+ { (char*) "bytesRemain", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain },
+ { (char*) "readByte", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readByte },
+ { (char*) "readBytes", (char*) "(Ljava/lang/Object;[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readBytes },
+ { (char*) "clone", (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_clone },
+};
+
+
+/* _Jv_com_sun_cldc_io_ResourceInputStream_init ********************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_com_sun_cldc_io_ResourceInputStream_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("com/sun/cldc/io/ResourceInputStream");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h"
+#endif
#include "vm/global.h"
#include "vm/vm.hpp" /* REMOVE ME: temporarily */
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "open0", (char*) "([BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_open0 },
- { (char*) "readBuf", (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf },
- { (char*) "readByte", (char*) "(I)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readByte },
- { (char*) "writeBuf", (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf },
- { (char*) "writeByte", (char*) "(II)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte },
- { (char*) "available0", (char*) "(I)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_available0 },
- { (char*) "close0", (char*) "(I)V", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_close0 },
-};
-
-
-/* _Jv_com_sun_cldc_io_j2me_socket_Protocol_init *******************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init(void)
-{
- utf *u;
-
- u = utf_new_char("com/sun/cldc/io/j2me/socket/Protocol");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: open0
* Signature: ([BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, java_handle_bytearray_t *hostname, s4 port, s4 mode)
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, jbyteArray hostname, jint port, jint mode)
{
struct hostent *phostent;
struct sockaddr_in serv_addr;
- char *name;
- s4 sockfd;
- s4 result;
- /* The hostname byte-array is a NULL terminated C-string. */
-
- name = (char *) &(LLNI_array_data(hostname));
+ // The hostname byte-array is a NULL terminated C-string.
+ // XXX Not GC safe.
+ char* name = (char*) &(LLNI_array_data((java_handle_bytearray_t*) hostname));
/* get the host */
/* create the socket */
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
return -1;
/* connect the socket */
- result = connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
+ int result = connect(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr));
if (result < 0)
return -1;
* Method: readBuf
* Signature: (I[BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t *b, s4 off, s4 len)
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, jint handle, jbyteArray b, jint off, jint len)
{
- void *buf;
- ssize_t result;
-
- /* get pointer to the buffer */
-
- buf = &(LLNI_array_direct(b, off));
+ // Get pointer to the buffer.
+ // XXX Not GC safe.
+ void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off));
- /* receive from the socket */
-
- result = recv(handle, buf, len, 0);
+ // Receive from the socket.
+ ssize_t result = recv(handle, buf, len, 0);
if (result == 0) {
- /* the peer has performed an orderly shutdown */
-
+ // The peer has performed an orderly shutdown.
return -1;
}
else if (result < 0) {
* Method: readByte
* Signature: (I)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv *env, jclass clazz, s4 handle) {
-
- char byte;
- ssize_t result;
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv *env, jclass clazz, jint handle)
+{
+ char byte;
- /* receive from the socket */
-
- result = recv(handle, &byte, 1, 0);
+ // Receive from the socket.
+ ssize_t result = recv(handle, &byte, 1, 0);
if (result == 0) {
- /* the peer has performed an orderly shutdown */
-
+ // The peer has performed an orderly shutdown.
return -1;
}
else if (result < 0) {
- /* should throw an IOException */
-
+ // TODO Should throw an IOException.
vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed");
}
* Method: writeBuf
* Signature: (I[BII)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t * b, s4 off, s4 len) {
-
- void *buf;
- ssize_t result;
-
- /* get pointer to the buffer */
-
- buf = &(LLNI_array_direct(b, off));
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, jint handle, jbyteArray b, jint off, jint len)
+{
+ // Get pointer to the buffer.
+ // XXX Not GC safe.
+ void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off));
- /* send the given byte to the socket */
-
- result = send(handle, buf, len, 0);
-
- if (result < 0)
- /* should throw an IOException */
+ // Send the given byte to the socket.
+ ssize_t result = send(handle, buf, len, 0);
+ if (result < 0) {
+ // TODO Should throw an IOException.
vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed");
+ }
return result;
-
}
* Method: writeByte
* Signature: (II)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEnv *env, jclass clazz, s4 handle, s4 b)
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEnv *env, jclass clazz, jint handle, jint b)
{
- char byte;
- ssize_t result;
-
- byte = (char) b;
+ char byte = (char) b;
- /* send the given byte to the socket */
-
- result = send(handle, &byte, 1, 0);
+ // Send the given byte to the socket.
+ ssize_t result = send(handle, &byte, 1, 0);
if (result < 0)
vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed");
* Method: available0
* Signature: (I)I
*/
-JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_available0(JNIEnv *env, jclass clazz, s4 handle)
+JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_available0(JNIEnv *env, jclass clazz, jint handle)
{
- /* NOTE: Sun doesn't have an implementation too */
-
+ // NOTE: Sun doesn't have an implementation too.
return 0;
}
* Method: close0
* Signature: (I)V
*/
-JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv *env, jclass clazz, s4 handle)
+JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv *env, jclass clazz, jint handle)
{
- int result;
-
- /* close the file descriptor */
-
- result = close(handle);
+ // Close the file descriptor.
+ int result = close(handle);
if (result < 0)
vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed");
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "open0", (char*) "([BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_open0 },
+ { (char*) "readBuf", (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf },
+ { (char*) "readByte", (char*) "(I)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readByte },
+ { (char*) "writeBuf", (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf },
+ { (char*) "writeByte", (char*) "(II)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte },
+ { (char*) "available0", (char*) "(I)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_available0 },
+ { (char*) "close0", (char*) "(I)V", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_close0 },
+};
+
+
+/* _Jv_com_sun_cldc_io_j2me_socket_Protocol_init *******************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("com/sun/cldc/io/j2me/socket/Protocol");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h"
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h"
+#endif
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class: com/sun/cldchi/io/ConsoleOutputStream
+ * Method: write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, jobject _this, jint c)
+{
+ (void) fputc(c, stdout);
}
+} // extern "C"
+
/* native methods implemented by this file ************************************/
}
-// Native functions are exported as C functions.
-extern "C" {
-
-/*
- * Class: com/sun/cldchi/io/ConsoleOutputStream
- * Method: write
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, com_sun_cldchi_io_ConsoleOutputStream *_this, int32_t c)
-{
- (void) fputc(c, stdout);
-}
-
-} // extern "C"
-
-
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_String.h"
-
-// FIXME
-extern "C" {
-#include "native/include/com_sun_cldchi_jvm_JVM.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/com_sun_cldchi_jvm_JVM.h"
+#endif
#include "vm/exceptions.hpp"
#include "vm/string.hpp"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "loadLibrary", (char*) "(Ljava/lang/String;)V", (void*) (uintptr_t) &Java_com_sun_cldchi_jvm_JVM_loadLibrary },
-};
-
-
-/* _Jv_com_sun_cldchi_jvm_JVM_init *********************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_com_sun_cldchi_jvm_JVM_init(void)
-{
- utf *u;
-
- u = utf_new_char("com/sun/cldchi/jvm/JVM");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: loadLibrary
* Signature: (Ljava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jclass clazz, java_lang_String *libName)
+JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jclass clazz, jstring libName)
{
- int result;
- utf *name;
-
- /* REMOVEME When we use Java-strings internally. */
-
if (libName == NULL) {
exceptions_throw_nullpointerexception();
return;
}
- name = javastring_toutf((java_handle_t *) libName, false);
+ /* REMOVEME When we use Java-strings internally. */
+
+ utf* name = javastring_toutf((java_handle_t *) libName, false);
- result = native_library_load(env, name, NULL);
+ int result = native_library_load(env, name, NULL);
/* Check for error and throw an exception in case. */
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "loadLibrary", (char*) "(Ljava/lang/String;)V", (void*) (uintptr_t) &Java_com_sun_cldchi_jvm_JVM_loadLibrary },
+};
+
+
+/* _Jv_com_sun_cldchi_jvm_JVM_init *********************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_com_sun_cldchi_jvm_JVM_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("com/sun/cldchi/jvm/JVM");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_String.h" /* required by j.l.C */
-#include "native/include/java_lang_Object.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Class.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Class.h"
+#endif
#include "vm/exceptions.hpp"
#include "vm/initialize.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "forName", (char*) "(Ljava/lang/String;)Ljava/lang/Class;",(void*) (uintptr_t) &Java_java_lang_Class_forName },
- { (char*) "newInstance", (char*) "()Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_Class_newInstance },
- { (char*) "isInstance", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_Class_isInstance },
- { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_Class_isAssignableFrom },
- { (char*) "isInterface", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Class_isInterface },
- { (char*) "isArray", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Class_isArray },
- { (char*) "getName", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_Class_getName },
-};
-
-/* _Jv_java_lang_Class_init ****************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Class_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Class");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: forName
* Signature: (Ljava/lang/String;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Class_forName(JNIEnv *env, jclass clazz, java_lang_String *name)
+JNIEXPORT jclass JNICALL Java_java_lang_Class_forName(JNIEnv *env, jclass clazz, jstring name)
{
utf *ufile;
utf *uname;
classinfo *c;
- u2 *pos;
- s4 i;
+ char* pos;
+ int32_t i;
/* illegal argument */
/* name must not contain '/' (mauve test) */
- for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) {
+ // FIXME Move this check into a function.
+ for (i = 0, pos = uname->text; i < uname->blength; i++, pos++) {
if (*pos == '/') {
exceptions_throw_classnotfoundexception(uname);
return NULL;
if (!initialize_class(c))
return NULL;
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: newInstance
* Signature: ()Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, java_lang_Class* _this)
+JNIEXPORT jobject JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, jclass _this)
{
classinfo *c;
java_handle_t *o;
o = native_new_and_init(c);
- return (java_lang_Object *) o;
+ return (jobject) o;
}
* Method: isInstance
* Signature: (Ljava/lang/Object;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isInstance(JNIEnv *env, java_lang_Class *_this, java_lang_Object *obj)
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isInstance(JNIEnv *env, jclass _this, jobject obj)
{
classinfo *c;
java_handle_t *h;
* Method: isAssignableFrom
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isAssignableFrom(JNIEnv *env, java_lang_Class *_this, java_lang_Class *cls)
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isAssignableFrom(JNIEnv *env, jclass _this, jclass cls)
{
classinfo *to;
classinfo *from;
* Method: isInterface
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isInterface(JNIEnv *env, java_lang_Class *_this)
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isInterface(JNIEnv *env, jclass _this)
{
classinfo *c;
* Method: isArray
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_Class_isArray(JNIEnv *env, java_lang_Class *_this)
+JNIEXPORT jboolean JNICALL Java_java_lang_Class_isArray(JNIEnv *env, jclass _this)
{
classinfo *c;
* Method: getName
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_Class_getName(JNIEnv *env, java_lang_Class *_this)
+JNIEXPORT jstring JNICALL Java_java_lang_Class_getName(JNIEnv *env, jclass _this)
{
classinfo *c;
c = LLNI_classinfo_unwrap(_this);
- return (java_lang_String*) class_get_classname(c);
+ return (jstring) class_get_classname(c);
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "forName", (char*) "(Ljava/lang/String;)Ljava/lang/Class;",(void*) (uintptr_t) &Java_java_lang_Class_forName },
+ { (char*) "newInstance", (char*) "()Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_Class_newInstance },
+ { (char*) "isInstance", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_Class_isInstance },
+ { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_Class_isAssignableFrom },
+ { (char*) "isInterface", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Class_isInterface },
+ { (char*) "isArray", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Class_isArray },
+ { (char*) "getName", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_Class_getName },
+};
+
+/* _Jv_java_lang_Class_init ****************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Class_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Class");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Double.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Double.h"
+#endif
#include "vm/builtin.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "doubleToLongBits", (char*) "(D)J", (void*) (uintptr_t) &Java_java_lang_Double_doubleToLongBits },
- { (char*) "longBitsToDouble", (char*) "(J)D", (void*) (uintptr_t) &Java_java_lang_Double_longBitsToDouble },
-};
-
-
-/* _Jv_java_lang_Double_init ***************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Double_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Double");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: doubleToLongBits
* Signature: (D)J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, double doubleValue)
+JNIEXPORT jlong JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, jdouble doubleValue)
{
jvalue val;
s8 e, f;
* Method: longBitsToDouble
* Signature: (J)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, int64_t longValue)
+JNIEXPORT jdouble JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, jlong longValue)
{
jvalue val;
val.j = longValue;
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "doubleToLongBits", (char*) "(D)J", (void*) (uintptr_t) &Java_java_lang_Double_doubleToLongBits },
+ { (char*) "longBitsToDouble", (char*) "(J)D", (void*) (uintptr_t) &Java_java_lang_Double_longBitsToDouble },
+};
+
+
+/* _Jv_java_lang_Double_init ***************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Double_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Double");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-// FIXME
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Float.h"
+#endif
+
+#include "vm/builtin.h"
+
+
+// Native functions are exported as C functions.
extern "C" {
-#include "native/include/java_lang_Float.h"
+
+/*
+ * Class: java/lang/Float
+ * Method: floatToIntBits
+ * Signature: (F)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass clazz, jfloat value)
+{
+ imm_union val;
+ int e, f;
+
+ val.f = value;
+
+ e = val.i & 0x7f800000;
+ f = val.i & 0x007fffff;
+
+ if (e == FLT_POSINF && f != 0)
+ return FLT_NAN;
+
+ return val.i;
}
-#include "vm/builtin.h"
+} // extern "C"
/* native methods implemented by this file ************************************/
}
-// Native functions are exported as C functions.
-extern "C" {
-
-/*
- * Class: java/lang/Float
- * Method: floatToIntBits
- * Signature: (F)I
- */
-JNIEXPORT int32_t JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass clazz, float value)
-{
- imm_union val;
- int e, f;
-
- val.f = value;
-
- e = val.i & 0x7f800000;
- f = val.i & 0x007fffff;
-
- if (e == FLT_POSINF && f != 0)
- return FLT_NAN;
-
- return val.i;
-}
-
-} // extern "C"
-
-
/*
* 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
-/* src/native/vm/cldc1.1/java_lang_Math.c
+/* src/native/vm/cldc1.1/java_lang_Math.cpp
Copyright (C) 2006, 2007, 2008
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Math.h"
-}
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "ceil", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_ceil },
- { (char*) "cos", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_cos },
- { (char*) "floor", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_floor },
- { (char*) "sin", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sin },
- { (char*) "sqrt", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sqrt },
- { (char*) "tan", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_tan },
-};
-
-
-/* _Jv_java_lang_Math_init *****************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Math_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Math");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Math.h"
+#endif
// Native functions are exported as C functions.
* Method: ceil
* Signature: (D)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, double a)
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, jdouble a)
{
return ceil(a);
}
* Method: cos
* Signature: (D)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, double a)
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, jdouble a)
{
return cos(a);
}
* Method: floor
* Signature: (D)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, double a)
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, jdouble a)
{
return floor(a);
}
* Method: sin
* Signature: (D)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, double a)
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, jdouble a)
{
return sin(a);
}
* Method: sqrt
* Signature: (D)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, double a)
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, jdouble a)
{
return sqrt(a);
}
* Method: tan
* Signature: (D)D
*/
-JNIEXPORT double JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, double a)
+JNIEXPORT jdouble JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, jdouble a)
{
return tan(a);
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "ceil", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_ceil },
+ { (char*) "cos", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_cos },
+ { (char*) "floor", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_floor },
+ { (char*) "sin", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sin },
+ { (char*) "sqrt", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sqrt },
+ { (char*) "tan", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_tan },
+};
+
+
+/* _Jv_java_lang_Math_init *****************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Math_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Math");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_String.h" /* required by j.l.C */
-#include "native/include/java_lang_Class.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Object.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Object.h"
+#endif
#include "threads/lock-common.h"
#include "vm/exceptions.hpp"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass },
- { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode },
- { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify },
- { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
- { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait },
-};
-
-
-/* _Jv_java_lang_Object_init ***************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Object_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Object");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: getClass
* Signature: ()Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj)
+JNIEXPORT jclass JNICALL Java_java_lang_Object_getClass(JNIEnv *env, jobject obj)
{
classinfo *c;
LLNI_class_get(obj, c);
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: hashCode
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, java_lang_Object *_this)
+JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_GC_CACAO)
assert(0);
#else
- return (int32_t) ((intptr_t) _this);
+ return (int32_t) ((uintptr_t) _this);
#endif
}
* Method: notify
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, java_lang_Object *_this)
+JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
lock_notify_object((java_handle_t *) _this);
* Method: notifyAll
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, java_lang_Object *_this)
+JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
lock_notify_all_object((java_handle_t *) _this);
* Method: wait
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, java_lang_Object *_this, s8 timeout)
+JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout)
{
#if defined(ENABLE_JVMTI)
/* Monitor Wait */
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass },
+ { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode },
+ { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify },
+ { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll },
+ { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait },
+};
+
+
+/* _Jv_java_lang_Object_init ***************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Object_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Object");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Runtime.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Runtime.h"
+#endif
#include "vm/vm.hpp"
#include "vmcore/utf8.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "exitInternal", (char*) "(I)V", (void*) (uintptr_t) &Java_java_lang_Runtime_exitInternal },
- { (char*) "freeMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_Runtime_freeMemory },
- { (char*) "totalMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_Runtime_totalMemory },
- { (char*) "gc", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Runtime_gc },
-};
-
-
-/* _Jv_java_lang_Runtime_init **************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Runtime_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Runtime");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: exitInternal
* Signature: (I)V
*/
-JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal(JNIEnv *env, java_lang_Runtime *_this, int32_t status)
+JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal(JNIEnv *env, jobject _this, jint status)
{
vm_shutdown(status);
}
* Method: freeMemory
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_Runtime_freeMemory(JNIEnv *env, java_lang_Runtime *_this)
+JNIEXPORT jlong JNICALL Java_java_lang_Runtime_freeMemory(JNIEnv *env, jobject _this)
{
return gc_get_free_bytes();
}
* Method: totalMemory
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_Runtime_totalMemory(JNIEnv *env, java_lang_Runtime *_this)
+JNIEXPORT jlong JNICALL Java_java_lang_Runtime_totalMemory(JNIEnv *env, jobject _this)
{
return gc_get_heap_size();
}
* Method: gc
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(JNIEnv *env, java_lang_Runtime *_this)
+JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(JNIEnv *env, jobject _this)
{
gc_call();
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "exitInternal", (char*) "(I)V", (void*) (uintptr_t) &Java_java_lang_Runtime_exitInternal },
+ { (char*) "freeMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_Runtime_freeMemory },
+ { (char*) "totalMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_Runtime_totalMemory },
+ { (char*) "gc", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Runtime_gc },
+};
+
+
+/* _Jv_java_lang_Runtime_init **************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Runtime_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Runtime");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_String.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_String.h"
+#endif
#include "vm/string.hpp"
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_String_hashCode },
- { (char*) "indexOf", (char*) "(I)I", (void*) (uintptr_t) &Java_java_lang_String_indexOf__I },
- { (char*) "indexOf", (char*) "(II)I", (void*) (uintptr_t) &Java_java_lang_String_indexOf__II },
- { (char*) "lastIndexOf", (char*) "(I)I", (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__I },
- { (char*) "lastIndexOf", (char*) "(II)I", (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__II },
-#if 0
- { (char*) "equals", (char*) "(Ljava/lang/Object;)Z;", (void*) (uintptr_t) &Java_java_lang_String_equals },
-#endif
- { (char*) "intern", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_String_intern },
-};
-
-
-/* _Jv_java_lang_String_init ***************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_String_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/String");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
+#include "vmcore/javaobjects.hpp"
// Native functions are exported as C functions.
* Method: hashCode
* Signature: ()I
*/
-JNIEXPORT s4 JNICALL Java_java_lang_String_hashCode(JNIEnv *env, java_lang_String *_this)
+JNIEXPORT jint JNICALL Java_java_lang_String_hashCode(JNIEnv *env, jstring _this)
{
- java_handle_chararray_t *value;
- int32_t offset;
- int32_t count;
- s4 hash;
- s4 i;
+ java_lang_String jls(_this);
- /* get values from Java object */
-
- LLNI_field_get_val(_this, offset, offset);
- LLNI_field_get_val(_this, count, count);
- LLNI_field_get_ref(_this, value, value);
+ java_handle_chararray_t* value = jls.get_value();
+ int32_t offset = jls.get_offset();
+ int32_t count = jls.get_count();
- hash = 0;
+ int32_t hash = 0;
- for (i = 0; i < count; i++) {
+ for (int32_t i = 0; i < count; i++) {
hash = (31 * hash) + LLNI_array_direct(value, offset + i);
}
* Method: indexOf
* Signature: (I)I
*/
-JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, java_lang_String *_this, s4 ch)
+JNIEXPORT jint JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, jstring _this, jint ch)
{
- java_handle_chararray_t *value;
- int32_t offset;
- int32_t count;
- s4 i;
-
- /* get values from Java object */
+ java_lang_String jls(_this);
- LLNI_field_get_val(_this, offset, offset);
- LLNI_field_get_val(_this, count, count);
- LLNI_field_get_ref(_this, value, value);
+ java_handle_chararray_t* value = jls.get_value();
+ int32_t offset = jls.get_offset();
+ int32_t count = jls.get_count();
- for (i = 0; i < count; i++) {
+ for (int32_t i = 0; i < count; i++) {
if (LLNI_array_direct(value, offset + i) == ch) {
return i;
}
* Method: indexOf
* Signature: (II)I
*/
-JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, java_lang_String *_this, s4 ch, s4 fromIndex)
+JNIEXPORT jint JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, jstring _this, jint ch, jint fromIndex)
{
- java_handle_chararray_t *value;
- int32_t offset;
- int32_t count;
- s4 i;
+ java_lang_String jls(_this);
- /* get values from Java object */
-
- LLNI_field_get_val(_this, offset, offset);
- LLNI_field_get_val(_this, count, count);
- LLNI_field_get_ref(_this, value, value);
+ java_handle_chararray_t* value = jls.get_value();
+ int32_t offset = jls.get_offset();
+ int32_t count = jls.get_count();
if (fromIndex < 0) {
fromIndex = 0;
}
else if (fromIndex >= count) {
- /* Note: fromIndex might be near -1>>>1. */
+ // Note: fromIndex might be near -1>>>1.
return -1;
}
- for (i = fromIndex ; i < count ; i++) {
+ for (int32_t i = fromIndex ; i < count ; i++) {
if (LLNI_array_direct(value, offset + i) == ch) {
return i;
}
}
-/*
- * Class: java/lang/String
- * Method: lastIndexOf
- * Signature: (I)I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, java_lang_String *_this, s4 ch)
-{
- int32_t count;
-
- LLNI_field_get_val(_this, count, count);
-
- return Java_java_lang_String_lastIndexOf__II(env, _this, ch, count - 1);
-}
-
-
/*
* Class: java/lang/String
* Method: lastIndexOf
* Signature: (II)I
*/
-JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, java_lang_String *_this, s4 ch, s4 fromIndex)
+JNIEXPORT jint JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, jstring _this, jint ch, jint fromIndex)
{
- java_handle_chararray_t *value;
- int32_t offset;
- int32_t count;
- s4 start;
- s4 i;
+ java_lang_String jls(_this);
- /* get values from Java object */
+ java_handle_chararray_t* value = jls.get_value();
+ int32_t offset = jls.get_offset();
+ int32_t count = jls.get_count();
- LLNI_field_get_val(_this, offset, offset);
- LLNI_field_get_val(_this, count, count);
- LLNI_field_get_ref(_this, value, value);
+ int32_t start = ((fromIndex >= count) ? count - 1 : fromIndex);
- start = ((fromIndex >= count) ? count - 1 : fromIndex);
-
- for (i = start; i >= 0; i--) {
+ for (int32_t i = start; i >= 0; i--) {
if (LLNI_array_direct(value, offset + i) == ch) {
return i;
}
}
-#if 0
/*
* Class: java/lang/String
- * Method: equals
- * Signature: (Ljava/lang/Object;)Z;
+ * Method: lastIndexOf
+ * Signature: (I)I
*/
-JNIEXPORT s4 JNICALL Java_java_lang_String_equals(JNIEnv *env, java_lang_String* _this, java_lang_Object *o)
+JNIEXPORT jint JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, jstring _this, jint ch)
{
- java_lang_String* s;
- java_handle_chararray_t *value;
- int32_t offset;
- int32_t count;
- java_handle_chararray_t *dvalue;
- int32_t doffset;
- int32_t dcount;
- classinfo *c;
-
- LLNI_field_get_val(_this, offset, offset);
- LLNI_field_get_val(_this, count, count);
- LLNI_field_get_ref(_this, value, value);
- LLNI_class_get(o, c);
-
- /* TODO: is this the correct implementation for short-circuiting on object identity? */
- if ((java_lang_Object*)_this == o)
- return 1;
+ java_lang_String jls(_this);
- if (c != class_java_lang_String)
- return 0;
-
- s = (java_lang_String *) o;
- LLNI_field_get_val(_this, offset, doffset);
- LLNI_field_get_val(_this, count, dcount);
- LLNI_field_get_ref(_this, value, dvalue);
-
- if (count != dcount)
- return 0;
-
- return ( 0 == memcmp((void*)(LLNI_array_direct(value, offset)),
- (void*)(LLNI_array_direct(dvalue, doffset),
- count) );
-
+ return Java_java_lang_String_lastIndexOf__II(env, _this, ch, jls.get_count() - 1);
}
-#endif
/*
* Method: intern
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_String_intern(JNIEnv *env, java_lang_String *_this)
+JNIEXPORT jstring JNICALL Java_java_lang_String_intern(JNIEnv *env, jstring _this)
{
- if (_this == NULL)
+ java_lang_String jls(_this);
+
+ if (jls.is_null())
return NULL;
- return (java_lang_String *) javastring_intern((java_handle_t *) _this);
+ return (jstring) javastring_intern(jls.get_handle());
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_String_hashCode },
+ { (char*) "indexOf", (char*) "(I)I", (void*) (uintptr_t) &Java_java_lang_String_indexOf__I },
+ { (char*) "indexOf", (char*) "(II)I", (void*) (uintptr_t) &Java_java_lang_String_indexOf__II },
+ { (char*) "lastIndexOf", (char*) "(II)I", (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__II },
+ { (char*) "lastIndexOf", (char*) "(I)I", (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__I },
+#if 0
+ { (char*) "equals", (char*) "(Ljava/lang/Object;)Z;", (void*) (uintptr_t) &Java_java_lang_String_equals },
+#endif
+ { (char*) "intern", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_String_intern },
+};
+
+
+/* _Jv_java_lang_String_init ***************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_String_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/String");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_System.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_System.h"
+#endif
#include "vm/builtin.h"
#include "vm/properties.h"
#include "vm/string.hpp"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "arraycopy", (char*) "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void*) (uintptr_t) &Java_java_lang_System_arraycopy },
- { (char*) "getProperty0", (char*) "(Ljava/lang/String;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_System_getProperty0 },
-};
-
-
-/* _Jv_java_lang_System_init ***************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_System_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/System");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: arraycopy
* Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
*/
-JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, s4 srcStart, java_lang_Object *dest, s4 destStart, s4 len)
+JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, jobject src, jint srcStart, jobject dest, jint destStart, jint len)
{
builtin_arraycopy((java_handle_t *) src, srcStart,
(java_handle_t *) dest, destStart, len);
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, java_lang_String *s)
+JNIEXPORT jstring JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, jstring s)
{
java_handle_t *so;
char* key;
result = javastring_new_from_ascii(value);
- return (java_lang_String *) result;
+ return (jstring) result;
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "arraycopy", (char*) "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void*) (uintptr_t) &Java_java_lang_System_arraycopy },
+ { (char*) "getProperty0", (char*) "(Ljava/lang/String;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_System_getProperty0 },
+};
+
+
+/* _Jv_java_lang_System_init ***************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_System_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/System");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Thread.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Thread.h"
+#endif
#include "threads/thread.hpp"
#include "vm/builtin.h"
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "currentThread", (char*) "()Ljava/lang/Thread;", (void*) (uintptr_t) &Java_java_lang_Thread_currentThread },
- { (char*) "setPriority0", (char*) "(II)V", (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0 },
- { (char*) "sleep", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Thread_sleep },
- { (char*) "start0", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_start0 },
- { (char*) "isAlive", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Thread_isAlive },
-#if 0
- { (char*) "activeCount", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Thread_activeCount },
- { (char*) "setPriority0", (char*) "(II)V", (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0 },
- { (char*) "interrupt0", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_interrupt0 },
- { (char*) "internalExit", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_internalExit },
-#endif
- { (char*) "yield", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_yield },
-};
-
-
-/* _Jv_java_lang_Thread_init ***************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Thread_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Thread");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
+#include "vmcore/javaobjects.hpp"
// Native functions are exported as C functions.
* Method: currentThread
* Signature: ()Ljava/lang/Thread;
*/
-JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
+JNIEXPORT jobject JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz)
{
- java_lang_Thread *to;
-
- to = (java_lang_Thread *) thread_get_current_object();
-
- return to;
+ return (jobject) thread_get_current_object();
}
* Method: setPriority0
* Signature: (II)V
*/
-JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, java_lang_Thread *_this, s4 oldPriority, s4 newPriority)
+JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, jobject _this, jint oldPriority, jint newPriority)
{
#if defined(ENABLE_THREADS)
- threadobject *t;
-
- t = (threadobject *) _this->vm_thread;
-
- /* The threadobject is null when a thread is created in Java. The
- priority is set later during startup. */
+ java_lang_Thread jlt(_this);
+ threadobject* t = jlt.get_vm_thread();
+ // The threadobject is null when a thread is created in Java. The
+ // priority is set later during startup.
if (t == NULL)
return;
* Method: sleep
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 millis)
+JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, jlong millis)
{
#if defined(ENABLE_THREADS)
threads_sleep(millis, 0);
* Method: start0
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, java_lang_Thread *_this)
+JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
- threads_thread_start((java_handle_t *) _this);
+ java_lang_Thread jlt(_this);
+ threads_thread_start(jlt.get_handle());
#endif
}
* Method: isAlive
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *_this)
+JNIEXPORT jboolean JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
- threadobject *t;
- bool result;
-
- t = (threadobject *) _this->vm_thread;
+ java_lang_Thread jlt(_this);
+ threadobject* t = jlt.get_vm_thread();
if (t == NULL)
return 0;
- result = threads_thread_is_alive(t);
+ bool result = threads_thread_is_alive(t);
return result;
#else
- /* If threads are disabled, the only thread running is alive. */
-
+ // If threads are disabled, the only thread running is alive.
return 1;
#endif
}
}
-/*
- * Class: java/lang/Thread
- * Method: setPriority0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, struct java_lang_Thread* _this, s4 par1, s4 par2)
-{
-}
-
-
/*
* Class: java/lang/Thread
* Method: interrupt0
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, struct java_lang_Thread* _this)
+JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, jobject _this)
{
}
* Method: internalExit
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, struct java_lang_Thread* _this)
+JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, jobject _this)
{
}
#endif
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "currentThread", (char*) "()Ljava/lang/Thread;", (void*) (uintptr_t) &Java_java_lang_Thread_currentThread },
+ { (char*) "setPriority0", (char*) "(II)V", (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0 },
+ { (char*) "sleep", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Thread_sleep },
+ { (char*) "start0", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_start0 },
+ { (char*) "isAlive", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Thread_isAlive },
+#if 0
+ { (char*) "activeCount", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Thread_activeCount },
+ { (char*) "setPriority0", (char*) "(II)V", (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0 },
+ { (char*) "interrupt0", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_interrupt0 },
+ { (char*) "internalExit", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_internalExit },
+#endif
+ { (char*) "yield", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_yield },
+};
+
+
+/* _Jv_java_lang_Thread_init ***************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Thread_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Thread");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_Throwable.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_lang_Throwable.h"
+#endif
#include "vm/exceptions.hpp"
-#include "vm/jit/stacktrace.hpp"
-
-
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "printStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_printStackTrace },
- { (char*) "fillInStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace },
-};
+#include "vm/jit/stacktrace.hpp"
-/* _Jv_java_lang_Throwable_init ************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_Throwable_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/Throwable");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
+#include "vmcore/javaobjects.hpp"
// Native functions are exported as C functions.
* Method: printStackTrace
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, java_lang_Throwable *_this)
+JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, jobject _this)
{
- java_handle_t *o;
-
- o = (java_handle_t *) _this;
+ java_lang_Throwable jlt(_this);
- exceptions_print_exception(o);
- stacktrace_print_exception(o);
+ exceptions_print_exception(jlt.get_handle());
+ stacktrace_print_exception(jlt.get_handle());
}
* Method: fillInStackTrace
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, java_lang_Throwable *_this)
+JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject _this)
{
- java_handle_bytearray_t *ba;
-
- ba = stacktrace_get_current();
+ java_handle_bytearray_t* ba = stacktrace_get_current();
if (ba == NULL)
return;
- LLNI_field_set_ref(_this, backtrace, (java_lang_Object *) ba);
+ java_lang_Throwable jlt(_this);
+ jlt.set_backtrace(ba);
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "printStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_printStackTrace },
+ { (char*) "fillInStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace },
+};
+
+
+/* _Jv_java_lang_Throwable_init ************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_Throwable_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/Throwable");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-
-// FIXME
-extern "C" {
-#include "native/include/gnu_classpath_VMStackWalker.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_classpath_VMStackWalker.h"
+#endif
#include "vm/global.h"
* Method: getClassContext
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
+JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
{
java_handle_objectarray_t *oa;
oa = stacktrace_getClassContext();
- return oa;
+ return (jobjectArray) oa;
}
* Method: getCallingClass
* Signature: ()Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
+JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
{
classinfo *c;
c = stacktrace_get_caller_class(2);
- return (java_lang_Class *) c;
+ return (jclass) c;
}
* Method: getCallingClassLoader
* Signature: ()Ljava/lang/ClassLoader;
*/
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
+JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
{
classinfo *c;
classloader_t *cl;
c = stacktrace_get_caller_class(2);
cl = class_get_classloader(c);
- return (java_lang_ClassLoader *) cl;
+ return (jobject) cl;
}
* Method: firstNonNullClassLoader
* Signature: ()Ljava/lang/ClassLoader;
*/
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
+JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
{
classloader_t *cl;
cl = stacktrace_first_nonnull_classloader();
- return (java_lang_ClassLoader *) cl;
+ return (jobject) cl;
}
} // extern "C"
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_util_Properties.h"
-
-/// FIXME
-extern "C" {
-#include "native/include/gnu_classpath_VMSystemProperties.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/gnu_classpath_VMSystemProperties.h"
+#endif
#include "vm/exceptions.hpp"
#include "vm/properties.h"
* Method: preInit
* Signature: (Ljava/util/Properties;)V
*/
-JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
+JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, jobject properties)
{
java_handle_t *p;
* Method: postInit
* Signature: (Ljava/util/Properties;)V
*/
-JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties)
+JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, jobject properties)
{
java_handle_t *p;
#if defined(ENABLE_JRE_LAYOUT)
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_String.h"
-
// FIXME
-extern "C" {
-#include "native/include/gnu_java_lang_VMCPStringBuilder.h"
-}
+//#include "native/include/gnu_java_lang_VMCPStringBuilder.h"
#include "vm/builtin.h"
#include "vm/exceptions.hpp"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
/*
* Method: toString
* Signature: ([CII)Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, java_handle_chararray_t *value, int32_t startIndex, int32_t count)
+JNIEXPORT jstring JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, jcharArray value, jint startIndex, jint count)
{
- int32_t length;
- java_handle_t *o;
- java_lang_String *s;
-
/* This is a native version of
java.lang.String.<init>([CIIZ)Ljava/lang/String; */
/* equivalent to: offset + count < 0 || offset + count > data.length */
+ java_handle_chararray_t* ca = (java_handle_chararray_t*) value;
+
LLNI_CRITICAL_START;
- length = LLNI_array_size(value);
+ int32_t length = LLNI_array_size(ca);
LLNI_CRITICAL_END;
if (length - startIndex < count) {
return NULL;
}
- o = builtin_new(class_java_lang_String);
+ java_handle_t* h = builtin_new(class_java_lang_String);
- if (o == NULL)
+ if (h == NULL)
return NULL;
- s = (java_lang_String *) o;
-
- LLNI_field_set_ref(s, value, value);
- LLNI_field_set_val(s, count, count);
- LLNI_field_set_val(s, offset, startIndex);
+ java_lang_String s(h, ca, (int32_t) count, (int32_t) startIndex);
- return s;
+ return (jstring) s.get_handle();
}
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
+#endif
#include "toolbox/logging.h"
* Method: getLoadedClassCount
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
+JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz)
{
int32_t count;
* Method: getUnloadedClassCount
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz)
{
log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!");
* Method: isVerbose
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
+JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
{
/* return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose; */
#warning Move to C++
* Method: setVerbose
* Signature: (Z)V
*/
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose)
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
{
/* _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose; */
#warning Move to C++
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_management_MemoryUsage.h"
-
-// FIXME
-extern "C" {
-#include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
+#endif
#include "vm/builtin.h"
#include "vm/global.h"
* Method: getHeapMemoryUsage
* Signature: ()Ljava/lang/management/MemoryUsage;
*/
-JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
+JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
{
- classinfo *class_java_lang_management_MemoryUsage;
- java_handle_t *o;
- java_lang_management_MemoryUsage *mu;
- methodinfo *m;
- int64_t init;
- int64_t used;
- int64_t commited;
- int64_t maximum;
+ classinfo *class_java_lang_management_MemoryUsage;
+ java_handle_t *o;
+ methodinfo *m;
+ int64_t init;
+ int64_t used;
+ int64_t commited;
+ int64_t maximum;
/* get the class */
/* XXX optimize me! sometime... */
if (o == NULL)
return NULL;
- /* cast the object to a MemoryUsage object (for debugability) */
-
- mu = (java_lang_management_MemoryUsage *) o;
-
/* find initializer */
m = class_findmethod(class_java_lang_management_MemoryUsage,
(void) vm_call_method(m, o, init, used, commited, maximum);
- return mu;
+ return (jobject) o;
}
* Method: getNonHeapMemoryUsage
* Signature: ()Ljava/lang/management/MemoryUsage;
*/
-JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
+JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
{
log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
* Method: getObjectPendingFinalizationCount
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
+JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
{
log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
* Method: isVerbose
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
+JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
{
/* return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose; */
#warning Move to C++
* Method: setVerbose
* Signature: (Z)V
*/
-JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose)
+JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose)
{
/* _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose; */
#warning Move to C++
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
+#endif
#include "vm/builtin.h"
#include "vm/global.h"
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_management_ThreadInfo.h"
-
-// FIXME
-extern "C" {
-#include "native/include/gnu_java_lang_management_VMThreadMXBeanImpl.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/gnu_java_lang_management_VMThreadMXBeanImpl.h"
+#endif
#include "toolbox/logging.h"
* Method: findMonitorDeadlockedThreads
* Signature: ()[J
*/
-JNIEXPORT java_handle_longarray_t* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz)
+JNIEXPORT jlongArray JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz)
{
log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!");
* Method: getCurrentThreadCpuTime
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz)
{
log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!");
* Method: getCurrentThreadUserTime
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz)
{
log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!");
* Method: getPeakThreadCount
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz)
+JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz)
{
/* return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount; */
#warning Move to C++
* Method: getThreadCpuTime
* Signature: (J)J
*/
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, int64_t id)
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, jlong id)
{
log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!");
* Method: getThreadInfoForId
* Signature: (JI)Ljava/lang/management/ThreadInfo;
*/
-JNIEXPORT java_lang_management_ThreadInfo* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, int64_t id, int32_t maxDepth)
+JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, jlong id, jint maxDepth)
{
log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!");
* Method: getThreadUserTime
* Signature: (J)J
*/
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, int64_t par1)
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, jlong par1)
{
log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!");
* Method: getTotalStartedThreadCount
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz)
{
/* return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount; */
#warning Move to C++
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Method.h"
-
-//FIXME
-extern "C" {
-#include "native/include/java_lang_VMClass.h"
-}
+// FIXME
+//#include "native/include/java_lang_VMClass.h"
#include "vm/exceptions.hpp"
#include "vm/initialize.h"
#include "vmcore/class.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-
#include "vm/vm.hpp"
#include "vmcore/annotation.h"
#endif
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "isInstance", (char*) "(Ljava/lang/Class;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isInstance },
- { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom },
- { (char*) "isInterface", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isInterface },
- { (char*) "isPrimitive", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isPrimitive },
- { (char*) "getName", (char*) "(Ljava/lang/Class;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMClass_getName },
- { (char*) "getSuperclass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getSuperclass },
- { (char*) "getInterfaces", (char*) "(Ljava/lang/Class;)[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getInterfaces },
- { (char*) "getComponentType", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getComponentType },
- { (char*) "getModifiers", (char*) "(Ljava/lang/Class;Z)I", (void*) (uintptr_t) &Java_java_lang_VMClass_getModifiers },
- { (char*) "getDeclaringClass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass },
- { (char*) "getDeclaredClasses", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses },
- { (char*) "getDeclaredFields", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields },
- { (char*) "getDeclaredMethods", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods },
- { (char*) "getDeclaredConstructors", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors },
- { (char*) "getClassLoader", (char*) "(Ljava/lang/Class;)Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_java_lang_VMClass_getClassLoader },
- { (char*) "forName", (char*) "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_forName },
- { (char*) "isArray", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isArray },
- { (char*) "throwException", (char*) "(Ljava/lang/Throwable;)V", (void*) (uintptr_t) &Java_java_lang_VMClass_throwException },
-#if defined(ENABLE_ANNOTATIONS)
- { (char*) "getDeclaredAnnotations", (char*) "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations },
-#endif
- { (char*) "getEnclosingClass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass },
- { (char*) "getEnclosingConstructor", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor },
- { (char*) "getEnclosingMethod", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Method;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod },
- { (char*) "getClassSignature", (char*) "(Ljava/lang/Class;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMClass_getClassSignature },
- { (char*) "isAnonymousClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass },
- { (char*) "isLocalClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isLocalClass },
- { (char*) "isMemberClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isMemberClass },
-};
-
-
-/* _Jv_java_lang_VMClass_init **************************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_VMClass_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/VMClass");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: isInstance
* Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, jclass klass, jobject o)
{
classinfo *c;
java_handle_t *h;
* Method: isAssignableFrom
* Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, jclass klass, jclass c)
{
classinfo *to;
classinfo *from;
* Method: isInterface
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
* Method: isPrimitive
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
* Method: getName
* Signature: (Ljava/lang/Class;)Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jstring JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo* c;
c = LLNI_classinfo_unwrap(klass);
- return (java_lang_String*) class_get_classname(c);
+ return (jstring) class_get_classname(c);
}
* Method: getSuperclass
* Signature: (Ljava/lang/Class;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
classinfo *super;
super = class_get_superclass(c);
- return LLNI_classinfo_wrap(super);
+ return (jclass) LLNI_classinfo_wrap(super);
}
* Method: getInterfaces
* Signature: (Ljava/lang/Class;)[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
java_handle_objectarray_t *oa;
oa = class_get_interfaces(c);
- return oa;
+ return (jobjectArray) oa;
}
* Method: getComponentType
* Signature: (Ljava/lang/Class;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
classinfo *component;
component = class_get_componenttype(c);
- return LLNI_classinfo_wrap(component);
+ return (jclass) LLNI_classinfo_wrap(component);
}
* Method: getModifiers
* Signature: (Ljava/lang/Class;Z)I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t ignoreInnerClassesAttrib)
+JNIEXPORT jint JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, jclass klass, jboolean ignoreInnerClassesAttrib)
{
classinfo *c;
int32_t flags;
* Method: getDeclaringClass
* Signature: (Ljava/lang/Class;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
classinfo *dc;
dc = class_get_declaringclass(c);
- return LLNI_classinfo_wrap(dc);
+ return (jclass) LLNI_classinfo_wrap(dc);
}
* Method: getDeclaredClasses
* Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
{
classinfo *c;
java_handle_objectarray_t *oa;
oa = class_get_declaredclasses(c, publicOnly);
- return oa;
+ return (jobjectArray) oa;
}
* Method: getDeclaredFields
* Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
{
classinfo *c;
java_handle_objectarray_t *oa;
oa = class_get_declaredfields(c, publicOnly);
- return oa;
+ return (jobjectArray) oa;
}
* Method: getDeclaredMethods
* Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
{
classinfo *c;
java_handle_objectarray_t *oa;
oa = class_get_declaredmethods(c, publicOnly);
- return oa;
+ return (jobjectArray) oa;
}
* Method: getDeclaredConstructors
* Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly)
{
classinfo *c;
java_handle_objectarray_t *oa;
oa = class_get_declaredconstructors(c, publicOnly);
- return oa;
+ return (jobjectArray) oa;
}
* Method: getClassLoader
* Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader;
*/
-JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
classloader_t *cl;
c = LLNI_classinfo_unwrap(klass);
cl = class_get_classloader(c);
- return (java_lang_ClassLoader *) cl;
+ return (jobject) cl;
}
* Method: forName
* Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, java_lang_String *name, int32_t initialize, java_lang_ClassLoader *loader)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, jstring name, jboolean initialize, jobject loader)
{
classloader_t *cl;
utf *ufile;
utf *uname;
classinfo *c;
- u2 *pos;
+ char* pos;
int32_t i;
cl = loader_hashtable_classloader_add((java_handle_t *) loader);
/* name must not contain '/' (mauve test) */
- for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) {
+ // FIXME Move this check into a function.
+ for (i = 0, pos = uname->text; i < uname->blength; i++, pos++) {
if (*pos == '/') {
exceptions_throw_classnotfoundexception(uname);
return NULL;
if (!initialize_class(c))
return NULL;
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: isArray
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
* Method: throwException
* Signature: (Ljava/lang/Throwable;)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
+JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, jobject t)
{
java_handle_t *o;
* Method: getDeclaredAnnotations
* Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, jclass klass)
{
- classinfo *c = NULL; /* classinfo for the java.lang.Class object 'klass' */
- static methodinfo *m_parseAnnotationsIntoArray = NULL; /* parser method (cached, therefore static) */
- utf *utf_parseAnnotationsIntoArray = NULL; /* parser method name */
- utf *utf_desc = NULL; /* parser method descriptor (signature) */
- java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
- sun_reflect_ConstantPool *constantPool = NULL; /* constant pool of klass */
- java_lang_Object *constantPoolOop = (java_lang_Object*)klass; /* constantPoolOop field of */
- /* sun.reflect.ConstantPool */
+ static methodinfo* m_parseAnnotationsIntoArray = NULL;
if (klass == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- c = LLNI_classinfo_unwrap(klass);
+ classinfo* c = LLNI_classinfo_unwrap(klass);
/* get annotations: */
- annotations = class_get_annotations(c);
+ java_handle_bytearray_t* annotations = class_get_annotations(c);
- constantPool =
- (sun_reflect_ConstantPool*)native_new_and_init(
- class_sun_reflect_ConstantPool);
+ java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
- if (constantPool == NULL) {
- /* out of memory */
+ if (h == NULL)
return NULL;
- }
- LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
+ sun_reflect_ConstantPool cp(h);
+ cp.set_constantPoolOop(klass);
/* only resolve the parser method the first time */
if (m_parseAnnotationsIntoArray == NULL) {
- utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
- utf_desc = utf_new_char(
- "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
- "[Ljava/lang/annotation/Annotation;");
+ utf* utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
+ utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
+ "[Ljava/lang/annotation/Annotation;");
if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) {
/* out of memory */
}
}
- return (java_handle_objectarray_t*)vm_call_method(
- m_parseAnnotationsIntoArray, NULL,
- annotations, constantPool, klass);
+ java_handle_objectarray_t* oa = (java_handle_objectarray_t*) vm_call_method(m_parseAnnotationsIntoArray, NULL, annotations, cp.get_handle(), klass);
+ return (jobjectArray) oa;
}
#endif
* Method: getEnclosingClass
* Signature: (Ljava/lang/Class;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
classinfo *result;
result = class_get_enclosingclass(c);
- return LLNI_classinfo_wrap(result);
+ return (jclass) LLNI_classinfo_wrap(result);
}
* Method: getEnclosingConstructor
* Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
*/
-JNIEXPORT java_lang_reflect_Constructor* JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo* c;
java_handle_t* h;
c = LLNI_classinfo_unwrap(klass);
h = class_get_enclosingconstructor(c);
- return (java_lang_reflect_Constructor*) h;
+ return (jobject) h;
}
* Method: getEnclosingMethod
* Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method;
*/
-JNIEXPORT java_lang_reflect_Method* JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo* c;
java_handle_t* h;
c = LLNI_classinfo_unwrap(klass);
h = class_get_enclosingmethod(c);
- return (java_lang_reflect_Method*) h;
+ return (jobject) h;
}
* Method: getClassSignature
* Signature: (Ljava/lang/Class;)Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, java_lang_Class* klass)
+JNIEXPORT jstring JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, jclass klass)
{
classinfo *c;
utf *u;
/* in error case s is NULL */
- return (java_lang_String *) s;
+ return (jstring) s;
}
* Method: isAnonymousClass
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, jclass klass)
{
return class_is_anonymousclass(LLNI_classinfo_unwrap(klass));
}
* Method: isLocalClass
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, jclass klass)
{
return class_is_localclass(LLNI_classinfo_unwrap(klass));
}
* Method: isMemberClass
* Signature: (Ljava/lang/Class;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, jclass klass)
{
return class_is_memberclass(LLNI_classinfo_unwrap(klass));
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "isInstance", (char*) "(Ljava/lang/Class;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isInstance },
+ { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom },
+ { (char*) "isInterface", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isInterface },
+ { (char*) "isPrimitive", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isPrimitive },
+ { (char*) "getName", (char*) "(Ljava/lang/Class;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMClass_getName },
+ { (char*) "getSuperclass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getSuperclass },
+ { (char*) "getInterfaces", (char*) "(Ljava/lang/Class;)[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getInterfaces },
+ { (char*) "getComponentType", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getComponentType },
+ { (char*) "getModifiers", (char*) "(Ljava/lang/Class;Z)I", (void*) (uintptr_t) &Java_java_lang_VMClass_getModifiers },
+ { (char*) "getDeclaringClass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass },
+ { (char*) "getDeclaredClasses", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses },
+ { (char*) "getDeclaredFields", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields },
+ { (char*) "getDeclaredMethods", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods },
+ { (char*) "getDeclaredConstructors", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors },
+ { (char*) "getClassLoader", (char*) "(Ljava/lang/Class;)Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_java_lang_VMClass_getClassLoader },
+ { (char*) "forName", (char*) "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_forName },
+ { (char*) "isArray", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isArray },
+ { (char*) "throwException", (char*) "(Ljava/lang/Throwable;)V", (void*) (uintptr_t) &Java_java_lang_VMClass_throwException },
+#if defined(ENABLE_ANNOTATIONS)
+ { (char*) "getDeclaredAnnotations", (char*) "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations },
+#endif
+ { (char*) "getEnclosingClass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass },
+ { (char*) "getEnclosingConstructor", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor },
+ { (char*) "getEnclosingMethod", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Method;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod },
+ { (char*) "getClassSignature", (char*) "(Ljava/lang/Class;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMClass_getClassSignature },
+ { (char*) "isAnonymousClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass },
+ { (char*) "isLocalClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isLocalClass },
+ { (char*) "isMemberClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isMemberClass },
+};
+
+
+/* _Jv_java_lang_VMClass_init **************************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_VMClass_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/VMClass");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_security_ProtectionDomain.h" /* required by... */
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_util_HashMap.h"
-#include "native/include/java_util_Map.h"
-#include "native/include/java_lang_Boolean.h"
// FIXME
-extern "C" {
-#include "native/include/java_lang_VMClassLoader.h"
-}
+//#include "native/include/java_lang_VMClassLoader.h"
#include "toolbox/logging.h"
#include "toolbox/list.h"
#include "vmcore/class.h"
#include "vmcore/classcache.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/linker.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
* Method: defineClass
* Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name, java_handle_bytearray_t *data, int32_t offset, int32_t len, java_security_ProtectionDomain *pd)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, jobject cl, jstring name, jbyteArray data, jint offset, jint len, jobject pd)
{
utf *utfname;
classinfo *c;
classloader_t *loader;
- java_lang_Class *o;
+ java_handle_bytearray_t* ba;
+ uint8_t* stream;
#if defined(ENABLE_JVMTI)
jint new_class_data_len = 0;
c = class_define(utfname, loader, new_class_data_len, new_class_data, pd);
else
#endif
- c = class_define(utfname, loader, len, (uint8_t *) &LLNI_array_direct(data, offset), (java_handle_t *) pd);
+ {
+ ba = (java_handle_bytearray_t*) data;
+ stream = (uint8_t *) &LLNI_array_direct(ba, offset);
+ c = class_define(utfname, loader, len, stream, (java_handle_t *) pd);
+ }
if (c == NULL)
return NULL;
- /* for convenience */
-
- o = LLNI_classinfo_wrap(c);
-
- /* set ProtectionDomain */
+ // REMOVEME
+ java_handle_t* h = LLNI_classinfo_wrap(c);
- LLNI_field_set_ref(o, pd, pd);
+ // Set ProtectionDomain.
+ java_lang_Class jlc(h);
+ jlc.set_pd(pd);
- return o;
+ return (jclass) jlc.get_handle();
}
* Method: getPrimitiveClass
* Signature: (C)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, int32_t type)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, jchar type)
{
classinfo *c;
return NULL;
}
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: resolveClass
* Signature: (Ljava/lang/Class;)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, java_lang_Class *c)
+JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, jclass c)
{
classinfo *ci;
* Method: loadClass
* Signature: (Ljava/lang/String;Z)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, java_lang_String *name, int32_t resolve)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, jstring name, jboolean resolve)
{
classinfo *c;
utf *u;
if (!link_class(c))
return NULL;
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: nativeGetResources
* Signature: (Ljava/lang/String;)Ljava/util/Vector;
*/
-JNIEXPORT struct java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name)
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, jstring name)
{
java_handle_t *o; /* vector being created */
methodinfo *m; /* "add" method of vector */
MFREE(buffer, char, bufsize);
- return (struct java_util_Vector *) o;
+ return (jobject) o;
return_NULL:
MFREE(buffer, char, bufsize);
* Method: defaultAssertionStatus
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz)
{
#if defined(ENABLE_ASSERTION)
return assertion_system_enabled;
* Method: userAssertionStatus
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz)
{
#if defined(ENABLE_ASSERTION)
return assertion_user_enabled;
/*
* Class: java/lang/VMClassLoader
* Method: packageAssertionStatus
- * Signature: ()Ljava_util_Map;
+ * Signature: (Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;
*/
-JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, jobject jtrue, jobject jfalse)
{
java_handle_t *hm;
#if defined(ENABLE_ASSERTION)
/* if nothing todo, return now */
if (assertion_package_count == 0) {
- return (java_util_Map *) hm;
+ return (jobject) hm;
}
/* get HashMap.put method */
}
#endif
- return (java_util_Map *) hm;
+ return (jobject) hm;
}
/*
* Class: java/lang/VMClassLoader
* Method: classAssertionStatus
- * Signature: ()Ljava_util_Map;
+ * Signature: (Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;
*/
-JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse)
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, jobject jtrue, jobject jfalse)
{
java_handle_t *hm;
#if defined(ENABLE_ASSERTION)
/* if nothing todo, return now */
if (assertion_class_count == 0) {
- return (java_util_Map *) hm;
+ return (jobject) hm;
}
/* get HashMap.put method */
}
#endif
- return (java_util_Map *) hm;
+ return (jobject) hm;
}
* Method: findLoadedClass
* Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *loader, java_lang_String *name)
+JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, jobject loader, jstring name)
{
classloader_t *cl;
classinfo *c;
if (c == NULL)
c = classcache_lookup(cl, u);
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
} // extern "C"
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h" /* required by j.l.VMO */
-#include "native/include/java_lang_Cloneable.h" /* required by j.l.VMO */
-#include "native/include/java_lang_Object.h" /* required by j.l.VMO */
-
-//FIXME
-extern "C" {
-#include "native/include/java_lang_VMObject.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMObject.h"
+#endif
#include "threads/lock-common.h"
* Method: getClass
* Signature: (Ljava/lang/Object;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, java_lang_Object *obj)
+JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, jobject obj)
{
classinfo *c;
LLNI_class_get(obj, c);
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: clone
* Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, java_lang_Cloneable *_this)
+JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, jobject _this)
{
java_handle_t *o;
java_handle_t *co;
co = builtin_clone(NULL, o);
- return (java_lang_Object *) co;
+ return (jobject) co;
}
* Method: notify
* Signature: (Ljava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *_this)
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, jobject _this)
{
#if defined(ENABLE_THREADS)
lock_notify_object((java_handle_t *) _this);
* Method: notifyAll
* Signature: (Ljava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *_this)
+JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, jobject _this)
{
#if defined(ENABLE_THREADS)
lock_notify_all_object((java_handle_t *) _this);
* Method: wait
* Signature: (Ljava/lang/Object;JI)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, int64_t ms, int32_t ns)
+JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, jobject o, jlong ms, jint ns)
{
#if defined(ENABLE_JVMTI)
/* Monitor Wait */
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_ClassLoader.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Process.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_VMRuntime.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMRuntime.h"
+#endif
#include "vm/builtin.h"
#include "vm/exceptions.hpp"
* Method: exit
* Signature: (I)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, int32_t status)
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, jint status)
{
if (finalizeOnExit)
gc_finalize_all();
* Method: freeMemory
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz)
{
return gc_get_free_bytes();
}
* Method: totalMemory
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
{
return gc_get_heap_size();
}
* Method: maxMemory
* Signature: ()J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
+JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
{
return gc_get_max_heap_size();
}
* Method: runFinalizersOnExit
* Signature: (Z)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, int32_t value)
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, jboolean value)
{
/* XXX threading */
* Method: traceInstructions
* Signature: (Z)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, int32_t par1)
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, jboolean par1)
{
/* not supported */
}
* Method: traceMethodCalls
* Signature: (Z)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, int32_t par1)
+JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, jboolean par1)
{
/* not supported */
}
* Method: availableProcessors
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
+JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
{
return os::processors_online();
}
* Method: nativeLoad
* Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *libname, java_lang_ClassLoader *loader)
+JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, jstring libname, jobject loader)
{
classloader_t *cl;
utf *name;
* Method: mapLibraryName
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, java_lang_String *libname)
+JNIEXPORT jstring JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, jstring libname)
{
utf *u;
char *buffer;
DRELEASE;
- return (java_lang_String *) o;
+ return (jstring) o;
}
} // extern "C"
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_String.h"
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_VMString.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMString.h"
+#endif
#include "vm/string.hpp"
* Method: intern
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, java_lang_String *str)
+JNIEXPORT jstring JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, jstring str)
{
if (str == NULL)
return NULL;
- return (java_lang_String *) javastring_intern((java_handle_t *) str);
+ return (jstring) javastring_intern((java_handle_t *) str);
}
} // extern "C"
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_io_InputStream.h" /* required by j.l.VMS */
-#include "native/include/java_io_PrintStream.h" /* required by j.l.VMS */
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_VMSystem.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vminclude/java_lang_VMSystem.h"
+#endif
#include "vm/builtin.h"
* Method: arraycopy
* Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, int32_t srcStart, java_lang_Object *dest, int32_t destStart, int32_t len)
+JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, jobject src, jint srcStart, jobject dest, jint destStart, jint len)
{
builtin_arraycopy((java_handle_t *) src, srcStart,
(java_handle_t *) dest, destStart, len);
* Method: identityHashCode
* Signature: (Ljava/lang/Object;)I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o)
+JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, jobject o)
{
int32_t hashcode;
+ // XXX This critical section should be inside the heap function.
LLNI_CRITICAL_START;
hashcode = heap_hashcode(LLNI_UNWRAP((java_handle_t *) o));
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_ThreadGroup.h"
-#include "native/include/java_lang_Object.h" /* java_lang_Thread.h */
-#include "native/include/java_lang_Throwable.h" /* java_lang_Thread.h */
-
-// FIXME
-extern "C" {
-#include "native/include/java_lang_VMThread.h"
-}
-
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Thread.h"
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_lang_VMThread.h"
+#endif
#include "threads/lock-common.h"
#include "threads/thread.hpp"
#include "vm/exceptions.hpp"
#include "vm/string.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/utf8.h"
* Method: countStackFrames
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *_this)
+JNIEXPORT jint JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, jobject _this)
{
log_println("Java_java_lang_VMThread_countStackFrames: Deprecated. Not implemented.");
* Method: start
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *_this, int64_t stacksize)
+JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, jobject _this, jlong stacksize)
{
- java_lang_Thread *thread;
-
- LLNI_field_get_ref(_this, thread, thread);
-
#if defined(ENABLE_THREADS)
- threads_thread_start((java_handle_t *) thread);
+ java_lang_VMThread jlvmt(_this);
+
+ threads_thread_start(jlvmt.get_thread());
#endif
}
* Method: interrupt
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *_this)
+JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
java_handle_t *h;
* Method: isInterrupted
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *_this)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
java_handle_t *h;
* Method: suspend
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *_this)
+JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
log_println("Java_java_lang_VMThread_suspend: Deprecated. Not implemented.");
* Method: resume
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *_this)
+JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
log_println("Java_java_lang_VMThread_resume: Deprecated. Not implemented.");
* Method: nativeSetPriority
* Signature: (I)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *_this, int32_t priority)
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, jobject _this, jint priority)
{
#if defined(ENABLE_THREADS)
java_handle_t *h;
* Method: nativeStop
* Signature: (Ljava/lang/Throwable;)V
*/
-JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *_this, java_lang_Throwable *t)
+JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, jobject _this, jobject t)
{
#if defined(ENABLE_THREADS)
log_println("Java_java_lang_VMThread_nativeStop: Deprecated. Not implemented.");
* Method: currentThread
* Signature: ()Ljava/lang/Thread;
*/
-JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
+JNIEXPORT jobject JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz)
{
- java_lang_Thread *to;
+ java_handle_t* h;
- to = (java_lang_Thread *) thread_get_current_object();
+ h = thread_get_current_object();
- return to;
+ return (jobject) h;
}
* Method: interrupted
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz)
{
#if defined(ENABLE_THREADS)
threadobject *t;
* Method: holdsLock
* Signature: (Ljava/lang/Object;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o)
+JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, jobject o)
{
#if defined(ENABLE_THREADS)
java_handle_t *h;
* Method: getState
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *_this)
+JNIEXPORT jstring JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, jobject _this)
{
#if defined(ENABLE_THREADS)
java_handle_t *h;
o = javastring_new(u);
- return (java_lang_String *) o;
+ return (jstring) o;
#else
return NULL;
#endif
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-
// FIXME
-extern "C" {
-#include "native/include/java_lang_VMThrowable.h"
-}
+//#include "native/include/java_lang_VMThrowable.h"
#include "vm/array.h"
#include "vm/builtin.h"
#include "vm/jit/stacktrace.hpp"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/loader.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "fillInStackTrace", (char*) "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_fillInStackTrace },
- { (char*) "getStackTrace", (char*) "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_getStackTrace },
-};
-
-
-/* _Jv_java_lang_VMThrowable_init **********************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-extern "C" {
-void _Jv_java_lang_VMThrowable_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/VMThrowable");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: fillInStackTrace
* Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable;
*/
-JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, java_lang_Throwable *t)
+JNIEXPORT jobject JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, jobject t)
{
- java_lang_VMThrowable *vmto;
- java_handle_bytearray_t *ba;
- java_lang_Object *o;
+ java_handle_t* h;
+ java_handle_bytearray_t* ba;
- vmto = (java_lang_VMThrowable *)
- native_new_and_init(class_java_lang_VMThrowable);
+ h = native_new_and_init(class_java_lang_VMThrowable);
- if (vmto == NULL)
+ if (h == NULL)
return NULL;
+ java_lang_VMThrowable vmt(h);
+
ba = stacktrace_get_current();
if (ba == NULL)
return NULL;
- o = (java_lang_Object *) ba;
-
- LLNI_field_set_ref(vmto, vmdata, o);
+ vmt.set_vmdata(ba);
- return vmto;
+ return (jobject) vmt.get_handle();
}
* Method: getStackTrace
* Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *_this, java_lang_Throwable *t)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, jobject _this, jobject t)
{
- java_lang_Object *o;
- java_handle_bytearray_t *ba;
- stacktrace_t *st;
- stacktrace_entry_t *ste;
- java_handle_objectarray_t *oa;
- java_lang_StackTraceElement *steo;
- codeinfo *code;
- methodinfo *m;
- java_lang_String *filename;
- s4 linenumber;
- java_handle_t *declaringclass;
- int i;
+ java_lang_VMThrowable vmt(_this);
- /* Get the stacktrace from the VMThrowable object. */
+ // Get the stacktrace from the VMThrowable object.
- LLNI_field_get_ref(_this, vmdata, o);
+ java_handle_bytearray_t* ba = vmt.get_vmdata();
- ba = (java_handle_bytearray_t *) o;
-
- st = (stacktrace_t *) LLNI_array_data(ba);
+ // XXX Critical GC section?
+ stacktrace_t* st = (stacktrace_t*) LLNI_array_data(ba);
assert(st != NULL);
- ste = st->entries;
+ stacktrace_entry_t* ste = st->entries;
/* Create the stacktrace element array. */
- oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
+ java_handle_objectarray_t* oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement);
if (oa == NULL)
return NULL;
- for (i = 0; i < st->length; i++, ste++) {
- /* allocate a new stacktrace element */
-
- steo = (java_lang_StackTraceElement *)
- builtin_new(class_java_lang_StackTraceElement);
-
- if (steo == NULL)
- return NULL;
-
+ for (int i = 0; i < st->length; i++, ste++) {
/* Get the codeinfo and methodinfo. */
- code = ste->code;
- m = code->m;
+ codeinfo* code = ste->code;
+ methodinfo* m = code->m;
/* Get filename. */
+ java_handle_t* filename;
+
if (!(m->flags & ACC_NATIVE)) {
if (m->clazz->sourcefile)
- filename = (java_lang_String *) javastring_new(m->clazz->sourcefile);
+ filename = javastring_new(m->clazz->sourcefile);
else
filename = NULL;
}
/* get line number */
+ int32_t linenumber;
+
if (m->flags & ACC_NATIVE) {
linenumber = -1;
}
/* get declaring class name */
- declaringclass = class_get_classname(m->clazz);
+ java_handle_t* declaringclass = class_get_classname(m->clazz);
- /* Fill the java.lang.StackTraceElement object. */
+ /* allocate a new stacktrace element */
- LLNI_field_set_ref(steo, fileName , filename);
- LLNI_field_set_val(steo, lineNumber , linenumber);
- LLNI_field_set_ref(steo, declaringClass, (java_lang_String*) declaringclass);
- LLNI_field_set_ref(steo, methodName , (java_lang_String *) javastring_new(m->name));
- LLNI_field_set_val(steo, isNative , (m->flags & ACC_NATIVE) ? 1 : 0);
+ java_handle_t* h = builtin_new(class_java_lang_StackTraceElement);
- array_objectarray_element_set(oa, i, (java_handle_t *) steo);
+ if (h == NULL)
+ return NULL;
+
+ java_lang_StackTraceElement ste(h, filename, linenumber, declaringclass, javastring_new(m->name), ((m->flags & ACC_NATIVE) ? 1 : 0));
+
+ array_objectarray_element_set(oa, i, ste.get_handle());
}
- return oa;
+ return (jobjectArray) oa;
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "fillInStackTrace", (char*) "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_fillInStackTrace },
+ { (char*) "getStackTrace", (char*) "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_getStackTrace },
+};
+
+
+/* _Jv_java_lang_VMThrowable_init **********************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+extern "C" {
+void _Jv_java_lang_VMThrowable_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/VMThrowable");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_management_VMManagementFactory.h"
+// FIXME
+//#include "native/include/java_lang_management_VMManagementFactory.h"
#include "toolbox/logging.h"
#include "vmcore/globals.hpp"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { "getMemoryPoolNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames },
- { "getMemoryManagerNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames },
- { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames },
-};
-
-
-/* _Jv_java_lang_management_VMManagementFactory_init ***************************
-
- Register native functions.
-
-*******************************************************************************/
-
-void _Jv_java_lang_management_VMManagementFactory_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/management/VMManagementFactory");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-
-
/*
* Class: java/lang/management/VMManagementFactory
* Method: getMemoryPoolNames
* Signature: ()[Ljava/lang/String;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz)
{
java_handle_objectarray_t *oa;
* Method: getMemoryManagerNames
* Signature: ()[Ljava/lang/String;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz)
{
java_handle_objectarray_t *oa;
* Method: getGarbageCollectorNames
* Signature: ()[Ljava/lang/String;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz)
{
java_handle_objectarray_t *oa;
}
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { "getMemoryPoolNames", "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames },
+ { "getMemoryManagerNames", "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames },
+ { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames },
+};
+
+
+/* _Jv_java_lang_management_VMManagementFactory_init ***************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_management_VMManagementFactory_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/management/VMManagementFactory");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Constructor.h"
// FIXME
-extern "C" {
-#include "native/include/java_lang_reflect_VMConstructor.h"
-}
+//#include "native/include/java_lang_reflect_VMConstructor.h"
-#include "native/vm/reflect.h"
+#include "native/vm/reflection.hpp"
#include "vm/string.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/utf8.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal },
- { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes },
- { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes },
- { (char*) "construct", (char*) "([Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_construct },
- { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getSignature },
-#if defined(ENABLE_ANNOTATIONS)
- { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations },
- { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMConstructor_init ************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-extern "C" {
-void _Jv_java_lang_reflect_VMConstructor_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/reflect/VMConstructor");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: getModifiersInternal
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
-
- m = &(c->methods[slot]);
-
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
return m->flags;
}
* Method: getParameterTypes
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_handle_objectarray_t* hoa = method_get_parametertypearray(m);
- m = &(c->methods[slot]);
-
- return method_get_parametertypearray(m);
+ return (jobjectArray) hoa;
}
* Method: getExceptionTypes
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
- m = &(c->methods[slot]);
+ java_handle_objectarray_t* hoa = method_get_exceptionarray(m);
- return method_get_exceptionarray(m);
+ return (jobjectArray) hoa;
}
* Method: construct
* Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, java_lang_reflect_VMConstructor *_this, java_handle_objectarray_t *args)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, jobject _this, jobjectArray args)
{
- classinfo *c;
- int32_t slot;
- java_lang_reflect_Constructor *rc;
- int32_t override;
- methodinfo *m;
- java_handle_t *o;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_lang_reflect_VMConstructor jlrvmc(_this);
+ java_lang_reflect_Constructor jlrc(jlrvmc.get_cons());
- LLNI_field_get_ref(_this, cons, rc);
- LLNI_field_get_val(rc, flag, override);
+ java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args);
- m = &(c->methods[slot]);
-
- o = reflect_constructor_newinstance(m, args, override);
-
- return (java_lang_Object *) o;
+ return (jobject) o;
}
* Method: getSignature
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
+ java_lang_reflect_VMConstructor rvmc(_this);
+ methodinfo* m = rvmc.get_method();
java_handle_t *o;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
-
- m = &(c->methods[slot]);
if (m->signature == NULL)
return NULL;
/* In error case o is NULL. */
- return (java_lang_String *) o;
+ return (jstring) o;
}
* Parses the annotations (if they aren't parsed yet) and stores them into
* the declaredAnnotations map and return this map.
*/
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, jobject _this)
{
- java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
- java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
- java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMConstructor rvmc(_this);
- LLNI_field_get_ref(_this, declaredAnnotations, declaredAnnotations);
+ java_handle_t* declaredAnnotations = rvmc.get_declaredAnnotations();
/* are the annotations parsed yet? */
if (declaredAnnotations == NULL) {
- LLNI_field_get_ref(_this, annotations, annotations);
- LLNI_field_get_ref(_this, clazz, declaringClass);
+ java_handle_bytearray_t* annotations = rvmc.get_annotations();
+ classinfo* declaringClass = rvmc.get_clazz();
+
+ classinfo *referer;
LLNI_class_get(_this, referer);
- declaredAnnotations = reflect_get_declaredannotations(annotations, (classinfo*) declaringClass, referer);
+ declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
- LLNI_field_set_ref(_this, declaredAnnotations, declaredAnnotations);
+ rvmc.set_declaredAnnotations(declaredAnnotations);
}
- return declaredAnnotations;
+ return (jobject) declaredAnnotations;
}
*
* Parses the parameter annotations and returns them in an 2 dimensional array.
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, jobject _this)
{
- java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */
- int32_t slot = -1; /* slot of the method */
- classinfo *c;
- methodinfo *m;
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMConstructor rvmc(_this);
+
+ java_handle_bytearray_t* parameterAnnotations = rvmc.get_parameterAnnotations();
+ methodinfo* m = rvmc.get_method();
- LLNI_field_get_ref(_this, parameterAnnotations, parameterAnnotations);
- LLNI_field_get_val(_this, slot, slot);
- LLNI_field_get_cls(_this, clazz, c);
- m = &(c->methods[slot]);
+ classinfo* referer;
+ LLNI_class_get((java_lang_reflect_VMConstructor*) _this, referer);
- LLNI_class_get(_this, referer);
+ java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer);
- return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, m, referer);
+ return (jobjectArray) oa;
}
#endif
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal },
+ { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes },
+ { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes },
+ { (char*) "construct", (char*) "([Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_construct },
+ { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getSignature },
+#if defined(ENABLE_ANNOTATIONS)
+ { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations },
+ { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMConstructor_init ************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+extern "C" {
+void _Jv_java_lang_reflect_VMConstructor_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/reflect/VMConstructor");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Boolean.h"
-#include "native/include/java_lang_Byte.h"
-#include "native/include/java_lang_Character.h"
-#include "native/include/java_lang_Short.h"
-#include "native/include/java_lang_Integer.h"
-#include "native/include/java_lang_Long.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Double.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-
-#include "native/include/java_lang_reflect_Field.h"
-
// FIXME
-extern "C" {
-#include "native/include/java_lang_reflect_VMField.h"
-}
+//#include "native/include/java_lang_reflect_VMField.h"
#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/java_util_Map.h"
-#include "native/include/sun_reflect_ConstantPool.h"
-#include "native/vm/reflect.h"
+// REMOVEME
+# include "native/vm/reflection.hpp"
#endif
#include "vm/access.h"
#include "vm/resolve.h"
#include "vm/string.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/loader.h"
#include "vmcore/utf8.h"
-/* native methods implemented by this file ************************************/
-
-static const JNINativeMethod methods[] = {
- { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal },
- { (char*) "getType", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getType },
- { (char*) "get", (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_get },
- { (char*) "getBoolean", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getBoolean },
- { (char*) "getByte", (char*) "(Ljava/lang/Object;)B", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getByte },
- { (char*) "getChar", (char*) "(Ljava/lang/Object;)C", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getChar },
- { (char*) "getShort", (char*) "(Ljava/lang/Object;)S", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getShort },
- { (char*) "getInt", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getInt },
- { (char*) "getLong", (char*) "(Ljava/lang/Object;)J", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getLong },
- { (char*) "getFloat", (char*) "(Ljava/lang/Object;)F", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getFloat },
- { (char*) "getDouble", (char*) "(Ljava/lang/Object;)D", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getDouble },
- { (char*) "set", (char*) "(Ljava/lang/Object;Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_set },
- { (char*) "setBoolean", (char*) "(Ljava/lang/Object;Z)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setBoolean },
- { (char*) "setByte", (char*) "(Ljava/lang/Object;B)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setByte },
- { (char*) "setChar", (char*) "(Ljava/lang/Object;C)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setChar },
- { (char*) "setShort", (char*) "(Ljava/lang/Object;S)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setShort },
- { (char*) "setInt", (char*) "(Ljava/lang/Object;I)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setInt },
- { (char*) "setLong", (char*) "(Ljava/lang/Object;J)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setLong },
- { (char*) "setFloat", (char*) "(Ljava/lang/Object;F)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setFloat },
- { (char*) "setDouble", (char*) "(Ljava/lang/Object;D)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setDouble },
- { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getSignature },
-#if defined(ENABLE_ANNOTATIONS)
- { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMField_init ******************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_reflect_VMField_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/reflect/VMField");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
/* _field_access_check *********************************************************
Checks if the field can be accessed.
*******************************************************************************/
-static bool _field_access_check(java_lang_reflect_VMField *_this,
- fieldinfo *f, java_handle_t *o)
+static bool _field_access_check(const java_lang_reflect_VMField& rvmf, fieldinfo *f, java_handle_t *o)
{
- java_lang_reflect_Field *rf;
- int32_t flag;
-
- /* check if we should bypass security checks (AccessibleObject) */
+ // Check if we should bypass security checks (AccessibleObject).
- LLNI_field_get_ref(_this, f, rf);
- LLNI_field_get_val(rf, flag, flag);
+ java_lang_reflect_Field rf(rvmf.get_f());
+ int32_t override = rf.get_flag();
- if (flag == false) {
+ if (override == false) {
/* This function is always called like this:
[0] java.lang.reflect.VMField.xxx (Native Method)
[1] java.lang.reflect.Field.xxx
*******************************************************************************/
#define _FIELD_GET_TYPE(name, type, uniontype) \
-static inline type _field_get_##name(fieldinfo *f, java_lang_Object *o) \
+static inline type _field_get_##name(fieldinfo *f, java_handle_t* h) \
{ \
type ret; \
if (f->flags & ACC_STATIC) { \
ret = f->value->uniontype; \
} else { \
LLNI_CRITICAL_START; \
- ret = *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset); \
+ ret = *(type *) (((intptr_t) LLNI_DIRECT(h)) + f->offset); \
LLNI_CRITICAL_END; \
} \
return ret; \
}
-static inline java_handle_t *_field_get_handle(fieldinfo *f, java_lang_Object *o)
+static inline java_handle_t *_field_get_handle(fieldinfo *f, java_handle_t* h)
{
- java_object_t *obj;
- java_handle_t *hdl;
+ java_object_t* result;
+ java_handle_t* hresult;
LLNI_CRITICAL_START;
if (f->flags & ACC_STATIC) {
- obj = (java_object_t*) f->value->a;
+ result = (java_object_t*) f->value->a;
} else {
- obj = *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset);
+ result = *(java_object_t**) (((intptr_t) LLNI_DIRECT(h)) + f->offset);
}
- hdl = LLNI_WRAP(obj);
+ hresult = LLNI_WRAP(result);
LLNI_CRITICAL_END;
- return hdl;
+ return hresult;
}
_FIELD_GET_TYPE(int, int32_t, i)
*******************************************************************************/
#define _FIELD_SET_TYPE(name, type, uniontype) \
-static inline void _field_set_##name(fieldinfo *f, java_lang_Object *o, type value) \
+static inline void _field_set_##name(fieldinfo* f, java_handle_t* h, type value) \
{ \
if (f->flags & ACC_STATIC) { \
f->value->uniontype = value; \
} else { \
LLNI_CRITICAL_START; \
- *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = value; \
+ *(type *) (((intptr_t) LLNI_DIRECT(h)) + f->offset) = value; \
LLNI_CRITICAL_END; \
} \
}
-static inline void _field_set_handle(fieldinfo *f, java_lang_Object *o, java_handle_t *value)
+static inline void _field_set_handle(fieldinfo* f, java_handle_t* h, java_handle_t* hvalue)
{
LLNI_CRITICAL_START;
if (f->flags & ACC_STATIC) {
- f->value->a = LLNI_DIRECT(value);
+ f->value->a = LLNI_DIRECT(hvalue);
} else {
- *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = LLNI_DIRECT(value);
+ *(java_object_t**) (((intptr_t) LLNI_DIRECT(h)) + f->offset) = LLNI_DIRECT(hvalue);
}
LLNI_CRITICAL_END;
* Method: getModifiersInternal
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMField *_this)
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, jobject _this)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &(c->fields[slot]);
-
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
return f->flags;
}
* Method: getType
* Signature: ()Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, java_lang_reflect_VMField *_this)
+JNIEXPORT jclass JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, jobject _this)
{
- classinfo *c;
- typedesc *desc;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
classinfo *ret;
- int32_t slot;
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- desc = c->fields[slot].parseddesc;
+ typedesc* desc = f->parseddesc;
if (desc == NULL)
return NULL;
if (!resolve_class_from_typedesc(desc, true, false, &ret))
return NULL;
- return LLNI_classinfo_wrap(ret);
+ return (jclass) LLNI_classinfo_wrap(ret);
}
* Method: get
* Signature: (Ljava/lang/Object;)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
- imm_union value;
- java_handle_t *object;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return NULL;
+ imm_union value;
+
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_BOOLEAN:
case PRIMITIVETYPE_BYTE:
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- value.i = _field_get_int(f, o);
+ value.i = _field_get_int(f, ho);
break;
case PRIMITIVETYPE_LONG:
- value.l = _field_get_long(f, o);
+ value.l = _field_get_long(f, ho);
break;
case PRIMITIVETYPE_FLOAT:
- value.f = _field_get_float(f, o);
+ value.f = _field_get_float(f, ho);
break;
case PRIMITIVETYPE_DOUBLE:
- value.d = _field_get_double(f, o);
+ value.d = _field_get_double(f, ho);
break;
case TYPE_ADR:
- return (java_lang_Object *) _field_get_handle(f, o);
+ return (jobject) _field_get_handle(f, ho);
}
/* Now box the primitive types. */
- object = Primitive::box(f->parseddesc->primitivetype, value);
+ java_handle_t* object = Primitive::box(f->parseddesc->primitivetype, value);
- return (java_lang_Object *) object;
+ return (jobject) object;
}
* Method: getBoolean
* Signature: (Ljava/lang/Object;)Z
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jboolean JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- /* get the class and the field */
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_BOOLEAN:
- return (int32_t) _field_get_int(f, o);
+ return (int32_t) _field_get_int(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getByte
* Signature: (Ljava/lang/Object;)B
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jbyte JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- return (int32_t) _field_get_int(f, o);
+ return (int32_t) _field_get_int(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getChar
* Signature: (Ljava/lang/Object;)C
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jchar JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- /* get the class and the field */
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_CHAR:
- return (int32_t) _field_get_int(f, o);
+ return (int32_t) _field_get_int(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getShort
* Signature: (Ljava/lang/Object;)S
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jshort JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
case PRIMITIVETYPE_SHORT:
- return (int32_t) _field_get_int(f, o);
+ return (int32_t) _field_get_int(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getInt
* Signature: (Ljava/lang/Object;)I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- /* get the class and the field */
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- return (int32_t) _field_get_int(f, o);
+ return (int32_t) _field_get_int(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getLong
* Signature: (Ljava/lang/Object;)J
*/
-JNIEXPORT int64_t JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jlong JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- return (int64_t) _field_get_int(f, o);
+ return (int64_t) _field_get_int(f, ho);
case PRIMITIVETYPE_LONG:
- return (int64_t) _field_get_long(f, o);
+ return (int64_t) _field_get_long(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getFloat
* Signature: (Ljava/lang/Object;)F
*/
-JNIEXPORT float JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jfloat JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- /* get the class and the field */
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- return (float) _field_get_int(f, o);
+ return (float) _field_get_int(f, ho);
case PRIMITIVETYPE_LONG:
- return (float) _field_get_long(f, o);
+ return (float) _field_get_long(f, ho);
case PRIMITIVETYPE_FLOAT:
- return (float) _field_get_float(f, o);
+ return (float) _field_get_float(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: getDouble
* Signature: (Ljava/lang/Object;)D
*/
-JNIEXPORT double JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , java_lang_reflect_VMField *_this, java_lang_Object *o)
+JNIEXPORT jdouble JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , jobject _this, jobject o)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return 0;
/* check the field type and return the value */
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- return (double) _field_get_int(f, o);
+ return (jdouble) _field_get_int(f, ho);
case PRIMITIVETYPE_LONG:
- return (double) _field_get_long(f, o);
+ return (jdouble) _field_get_long(f, ho);
case PRIMITIVETYPE_FLOAT:
- return (double) _field_get_float(f, o);
+ return (jdouble) _field_get_float(f, ho);
case PRIMITIVETYPE_DOUBLE:
- return (double) _field_get_double(f, o);
+ return (jdouble) _field_get_double(f, ho);
default:
exceptions_throw_illegalargumentexception();
return 0;
* Method: set
* Signature: (Ljava/lang/Object;Ljava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, java_lang_Object *value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, jobject _this, jobject o, jobject value)
{
- classinfo *sc;
- classinfo *dc;
- fieldinfo *sf;
- fieldinfo *df;
- int32_t slot;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* df = rvmf.get_field();
- /* get the class and the field */
+ java_handle_t* ho = (java_handle_t*) o;
+ java_handle_t* hvalue = (java_handle_t*) value;
- LLNI_field_get_cls(_this, clazz, dc);
- LLNI_field_get_val(_this, slot , slot);
- df = &dc->fields[slot];
+ classinfo *sc;
+ fieldinfo *sf;
/* check if the field can be accessed */
- if (!_field_access_check(_this, df, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, df, ho))
return;
/* get the source classinfo from the object */
- if (value == NULL)
+ if (hvalue == NULL)
sc = NULL;
else
- LLNI_class_get(value, sc);
+ LLNI_class_get(hvalue, sc);
/* The fieldid is used to set the new value, for primitive
types the value has to be retrieved from the wrapping
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BOOLEAN:
- LLNI_field_get_val((java_lang_Boolean *) value, value, val);
+ val = java_lang_Boolean(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_int(df, o, val);
+ _field_set_int(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- LLNI_field_get_val((java_lang_Byte *) value, value, val);
+ val = java_lang_Byte(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_int(df, o, val);
+ _field_set_int(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_CHAR:
- LLNI_field_get_val((java_lang_Character *) value, value, val);
+ val = java_lang_Character(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_int(df, o, val);
+ _field_set_int(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- LLNI_field_get_val((java_lang_Byte *) value, value, val);
+ val = java_lang_Byte(hvalue).get_value();
break;
case PRIMITIVETYPE_SHORT:
- LLNI_field_get_val((java_lang_Short *) value, value, val);
+ val = java_lang_Short(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_int(df, o, val);
+ _field_set_int(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- LLNI_field_get_val((java_lang_Byte *) value, value, val);
+ val = java_lang_Byte(hvalue).get_value();
break;
case PRIMITIVETYPE_CHAR:
- LLNI_field_get_val((java_lang_Character *) value, value, val);
+ val = java_lang_Character(hvalue).get_value();
break;
case PRIMITIVETYPE_SHORT:
- LLNI_field_get_val((java_lang_Short *) value, value, val);
+ val = java_lang_Short(hvalue).get_value();
break;
case PRIMITIVETYPE_INT:
- LLNI_field_get_val((java_lang_Integer *) value, value, val);
+ val = java_lang_Integer(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_int(df, o, val);
+ _field_set_int(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- LLNI_field_get_val((java_lang_Byte *) value, value, val);
+ val = java_lang_Byte(hvalue).get_value();
break;
case PRIMITIVETYPE_CHAR:
- LLNI_field_get_val((java_lang_Character *) value, value, val);
+ val = java_lang_Character(hvalue).get_value();
break;
case PRIMITIVETYPE_SHORT:
- LLNI_field_get_val((java_lang_Short *) value, value, val);
+ val = java_lang_Short(hvalue).get_value();
break;
case PRIMITIVETYPE_INT:
- LLNI_field_get_val((java_lang_Integer *) value, value, val);
+ val = java_lang_Integer(hvalue).get_value();
break;
case PRIMITIVETYPE_LONG:
- LLNI_field_get_val((java_lang_Long *) value, value, val);
+ val = java_lang_Long(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_long(df, o, val);
+ _field_set_long(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- LLNI_field_get_val((java_lang_Byte *) value, value, val);
+ val = java_lang_Byte(hvalue).get_value();
break;
case PRIMITIVETYPE_CHAR:
- LLNI_field_get_val((java_lang_Character *) value, value, val);
+ val = java_lang_Character(hvalue).get_value();
break;
case PRIMITIVETYPE_SHORT:
- LLNI_field_get_val((java_lang_Short *) value, value, val);
+ val = java_lang_Short(hvalue).get_value();
break;
case PRIMITIVETYPE_INT:
- LLNI_field_get_val((java_lang_Integer *) value, value, val);
+ val = java_lang_Integer(hvalue).get_value();
break;
case PRIMITIVETYPE_LONG:
- LLNI_field_get_val((java_lang_Long *) value, value, val);
+ val = java_lang_Long(hvalue).get_value();
break;
case PRIMITIVETYPE_FLOAT:
- LLNI_field_get_val((java_lang_Float *) value, value, val);
+ val = java_lang_Float(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_float(df, o, val);
+ _field_set_float(df, ho, val);
return;
}
switch (sf->parseddesc->primitivetype) {
case PRIMITIVETYPE_BYTE:
- LLNI_field_get_val((java_lang_Byte *) value, value, val);
+ val = java_lang_Byte(hvalue).get_value();
break;
case PRIMITIVETYPE_CHAR:
- LLNI_field_get_val((java_lang_Character *) value, value, val);
+ val = java_lang_Character(hvalue).get_value();
break;
case PRIMITIVETYPE_SHORT:
- LLNI_field_get_val((java_lang_Short *) value, value, val);
+ val = java_lang_Short(hvalue).get_value();
break;
case PRIMITIVETYPE_INT:
- LLNI_field_get_val((java_lang_Integer *) value, value, val);
+ val = java_lang_Integer(hvalue).get_value();
break;
case PRIMITIVETYPE_LONG:
- LLNI_field_get_val((java_lang_Long *) value, value, val);
+ val = java_lang_Long(hvalue).get_value();
break;
case PRIMITIVETYPE_FLOAT:
- LLNI_field_get_val((java_lang_Float *) value, value, val);
+ val = java_lang_Float(hvalue).get_value();
break;
case PRIMITIVETYPE_DOUBLE:
- LLNI_field_get_val((java_lang_Double *) value, value, val);
+ val = java_lang_Double(hvalue).get_value();
break;
default:
exceptions_throw_illegalargumentexception();
return;
}
- _field_set_double(df, o, val);
+ _field_set_double(df, ho, val);
return;
}
/* if (!builtin_instanceof((java_handle_t *) value, df->class)) */
/* break; */
- _field_set_handle(df, o, (java_handle_t *) value);
+ _field_set_handle(df, ho, hvalue);
return;
}
* Method: setBoolean
* Signature: (Ljava/lang/Object;Z)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, int32_t value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, jobject _this, jobject o, jboolean value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- /* get the class and the field */
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_BOOLEAN:
- _field_set_int(f, o, value);
+ _field_set_int(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setByte
* Signature: (Ljava/lang/Object;B)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, int32_t value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, jobject _this, jobject o, jbyte value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
case PRIMITIVETYPE_BYTE:
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- _field_set_int(f, o, value);
+ _field_set_int(f, ho, value);
break;
case PRIMITIVETYPE_LONG:
- _field_set_long(f, o, value);
+ _field_set_long(f, ho, value);
break;
case PRIMITIVETYPE_FLOAT:
- _field_set_float(f, o, value);
+ _field_set_float(f, ho, value);
break;
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setChar
* Signature: (Ljava/lang/Object;C)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, int32_t value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, jobject _this, jobject o, jchar value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_CHAR:
case PRIMITIVETYPE_INT:
- _field_set_int(f, o, value);
+ _field_set_int(f, ho, value);
break;
case PRIMITIVETYPE_LONG:
- _field_set_long(f, o, value);
+ _field_set_long(f, ho, value);
break;
case PRIMITIVETYPE_FLOAT:
- _field_set_float(f, o, value);
+ _field_set_float(f, ho, value);
break;
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setShort
* Signature: (Ljava/lang/Object;S)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, int32_t value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, jobject _this, jobject o, jshort value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_SHORT:
case PRIMITIVETYPE_INT:
- _field_set_int(f, o, value);
+ _field_set_int(f, ho, value);
break;
case PRIMITIVETYPE_LONG:
- _field_set_long(f, o, value);
+ _field_set_long(f, ho, value);
break;
case PRIMITIVETYPE_FLOAT:
- _field_set_float(f, o, value);
+ _field_set_float(f, ho, value);
break;
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setInt
* Signature: (Ljava/lang/Object;I)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, int32_t value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, jobject _this, jobject o, jint value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_INT:
- _field_set_int(f, o, value);
+ _field_set_int(f, ho, value);
break;
case PRIMITIVETYPE_LONG:
- _field_set_long(f, o, value);
+ _field_set_long(f, ho, value);
break;
case PRIMITIVETYPE_FLOAT:
- _field_set_float(f, o, value);
+ _field_set_float(f, ho, value);
break;
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setLong
* Signature: (Ljava/lang/Object;J)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, int64_t value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, jobject _this, jobject o, jlong value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_LONG:
- _field_set_long(f, o, value);
+ _field_set_long(f, ho, value);
break;
case PRIMITIVETYPE_FLOAT:
- _field_set_float(f, o, value);
+ _field_set_float(f, ho, value);
break;
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setFloat
* Signature: (Ljava/lang/Object;F)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, float value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, jobject _this, jobject o, jfloat value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_FLOAT:
- _field_set_float(f, o, value);
+ _field_set_float(f, ho, value);
break;
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: setDouble
* Signature: (Ljava/lang/Object;D)V
*/
-JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, java_lang_reflect_VMField *_this, java_lang_Object *o, double value)
+JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, jobject _this, jobject o, jdouble value)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
- /* get the class and the field */
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_handle_t* ho = (java_handle_t*) o;
/* check if the field can be accessed */
- if (!_field_access_check(_this, f, (java_handle_t *) o))
+ if (!_field_access_check(rvmf, f, ho))
return;
/* check the field type and set the value */
switch (f->parseddesc->primitivetype) {
case PRIMITIVETYPE_DOUBLE:
- _field_set_double(f, o, value);
+ _field_set_double(f, ho, value);
break;
default:
exceptions_throw_illegalargumentexception();
}
-
- return;
}
* Method: getSignature
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, java_lang_reflect_VMField* _this)
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, jobject _this)
{
- classinfo *c;
- fieldinfo *f;
- java_handle_t *o;
- int32_t slot;
-
- /* get the class and the field */
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- f = &c->fields[slot];
+ java_lang_reflect_VMField rvmf(_this);
+ fieldinfo* f = rvmf.get_field();
if (f->signature == NULL)
return NULL;
- o = javastring_new(f->signature);
+ java_handle_t* o = javastring_new(f->signature);
/* in error case o is NULL */
- return (java_lang_String *) o;
+ return (jstring) o;
}
* Method: declaredAnnotations
* Signature: ()Ljava/util/Map;
*/
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMField *_this)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, jobject _this)
{
- java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
- java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
- java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMField rvmf(_this);
- LLNI_field_get_ref(_this, declaredAnnotations, declaredAnnotations);
+ java_handle_t* declaredAnnotations = rvmf.get_declaredAnnotations();
- /* are the annotations parsed yet? */
+ // Are the annotations parsed yet?
if (declaredAnnotations == NULL) {
- LLNI_field_get_ref(_this, annotations, annotations);
- LLNI_field_get_ref(_this, clazz, declaringClass);
+ java_handle_bytearray_t* annotations = rvmf.get_annotations();
+ classinfo* declaringClass = rvmf.get_clazz();
+
+ classinfo* referer;
LLNI_class_get(_this, referer);
- declaredAnnotations = reflect_get_declaredannotations(annotations, (classinfo*) declaringClass, referer);
+ declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
- LLNI_field_set_ref(_this, declaredAnnotations, declaredAnnotations);
+ rvmf.set_declaredAnnotations(declaredAnnotations);
}
- return declaredAnnotations;
+ return (jobject) declaredAnnotations;
}
#endif
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static const JNINativeMethod methods[] = {
+ { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal },
+ { (char*) "getType", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getType },
+ { (char*) "get", (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_get },
+ { (char*) "getBoolean", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getBoolean },
+ { (char*) "getByte", (char*) "(Ljava/lang/Object;)B", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getByte },
+ { (char*) "getChar", (char*) "(Ljava/lang/Object;)C", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getChar },
+ { (char*) "getShort", (char*) "(Ljava/lang/Object;)S", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getShort },
+ { (char*) "getInt", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getInt },
+ { (char*) "getLong", (char*) "(Ljava/lang/Object;)J", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getLong },
+ { (char*) "getFloat", (char*) "(Ljava/lang/Object;)F", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getFloat },
+ { (char*) "getDouble", (char*) "(Ljava/lang/Object;)D", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getDouble },
+ { (char*) "set", (char*) "(Ljava/lang/Object;Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_set },
+ { (char*) "setBoolean", (char*) "(Ljava/lang/Object;Z)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setBoolean },
+ { (char*) "setByte", (char*) "(Ljava/lang/Object;B)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setByte },
+ { (char*) "setChar", (char*) "(Ljava/lang/Object;C)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setChar },
+ { (char*) "setShort", (char*) "(Ljava/lang/Object;S)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setShort },
+ { (char*) "setInt", (char*) "(Ljava/lang/Object;I)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setInt },
+ { (char*) "setLong", (char*) "(Ljava/lang/Object;J)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setLong },
+ { (char*) "setFloat", (char*) "(Ljava/lang/Object;F)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setFloat },
+ { (char*) "setDouble", (char*) "(Ljava/lang/Object;D)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setDouble },
+ { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getSignature },
+#if defined(ENABLE_ANNOTATIONS)
+ { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMField_init ******************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_reflect_VMField_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/reflect/VMField");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-# include "native/include/java_util_Map.h"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/include/java_lang_reflect_Method.h"
-
// FIXME
-extern "C" {
-#include "native/include/java_lang_reflect_VMMethod.h"
-}
+//#include "native/include/java_lang_reflect_VMMethod.h"
-#include "native/vm/reflect.h"
+#include "native/vm/reflection.hpp"
#include "vm/access.h"
#include "vm/global.h"
#include "vm/resolve.h"
#include "vm/string.hpp"
+#include "vmcore/class.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/method.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal },
- { (char*) "getReturnType", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType },
- { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes },
- { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes },
- { (char*) "invoke", (char*) "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke },
- { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature },
-#if defined(ENABLE_ANNOTATIONS)
- { (char*) "getDefaultValue", (char*) "()Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue },
- { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations },
- { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations },
-#endif
-};
-
-
-/* _Jv_java_lang_reflect_VMMethod_init *****************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_java_lang_reflect_VMMethod_init(void)
-{
- utf *u;
-
- u = utf_new_char("java/lang/reflect/VMMethod");
-
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
// Native functions are exported as C functions.
extern "C" {
* Method: getModifiersInternal
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMMethod *_this)
+JNIEXPORT jint JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- m = &(c->methods[slot]);
-
+ java_lang_reflect_VMMethod rvmm(_this);
+ methodinfo* m = rvmm.get_method();
return m->flags;
}
* Method: getReturnType
* Signature: ()Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, java_lang_reflect_VMMethod *_this)
+JNIEXPORT jclass JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- classinfo *result;
- int32_t slot;
+ java_lang_reflect_VMMethod rvmm(_this);
+ methodinfo* m = rvmm.get_method();
+ classinfo* c = method_returntype_get(m);
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- m = &(c->methods[slot]);
-
- result = method_returntype_get(m);
-
- return LLNI_classinfo_wrap(result);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: getParameterTypes
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, java_lang_reflect_VMMethod *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- m = &(c->methods[slot]);
-
- return method_get_parametertypearray(m);
+ java_lang_reflect_VMMethod rvmm(_this);
+ methodinfo* m = rvmm.get_method();
+ java_handle_objectarray_t* oa = method_get_parametertypearray(m);
+ return (jobjectArray) oa;
}
* Method: getExceptionTypes
* Signature: ()[Ljava/lang/Class;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMMethod *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- m = &(c->methods[slot]);
-
- return method_get_exceptionarray(m);
+ java_lang_reflect_VMMethod rvmm(_this);
+ methodinfo* m = rvmm.get_method();
+ java_handle_objectarray_t* oa = method_get_exceptionarray(m);
+ return (jobjectArray) oa;
}
* Method: invoke
* Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, java_lang_reflect_VMMethod *_this, java_lang_Object *o, java_handle_objectarray_t *args)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, jobject _this, jobject o, jobjectArray args)
{
- classinfo *c;
- int32_t slot;
- java_lang_reflect_Method *rm;
- int32_t override;
- methodinfo *m;
- java_handle_t *ro;
+ java_lang_reflect_VMMethod jlrvmm(_this);
+ java_lang_reflect_Method jlrm(jlrvmm.get_m());
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot, slot);
+ java_handle_t* result = jlrm.invoke((java_handle_t*) o, (java_handle_objectarray_t*) args);
- LLNI_field_get_ref(_this, m, rm);
- LLNI_field_get_val(rm, flag, override);
-
- m = &(c->methods[slot]);
-
- ro = reflect_method_invoke(m, (java_handle_t *) o, args, override);
-
- return (java_lang_Object *) ro;
+ return (jobject) result;
}
* Method: getSignature
* Signature: ()Ljava/lang/String;
*/
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, java_lang_reflect_VMMethod* _this)
+JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, jobject _this)
{
- classinfo *c;
- methodinfo *m;
- java_handle_t *o;
- int32_t slot;
-
- LLNI_field_get_cls(_this, clazz, c);
- LLNI_field_get_val(_this, slot , slot);
- m = &(c->methods[slot]);
+ java_lang_reflect_VMMethod rvmm(_this);
+ methodinfo* m = rvmm.get_method();
if (m->signature == NULL)
return NULL;
- o = javastring_new(m->signature);
+ java_handle_t* s = javastring_new(m->signature);
/* in error case o is NULL */
- return (java_lang_String *) o;
+ return (jstring) s;
}
+
#if defined(ENABLE_ANNOTATIONS)
/*
* Class: java/lang/reflect/VMMethod
*
* Parses the annotation default value and returnes it (boxed, if it's a primitive).
*/
-JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, struct java_lang_reflect_VMMethod* _this)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, jobject _this)
{
- java_handle_bytearray_t *annotationDefault = NULL; /* unparsed annotation default value */
static methodinfo *m_parseAnnotationDefault = NULL; /* parser method (will be chached, therefore static) */
utf *utf_parseAnnotationDefault = NULL; /* parser method name */
utf *utf_desc = NULL; /* parser method descriptor (signature) */
- sun_reflect_ConstantPool *constantPool = NULL; /* constant pool object to use */
- java_lang_Class *constantPoolOop = NULL; /* methods declaring class */
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
- java_lang_reflect_Method* rm;
- java_handle_t* h;
if (_this == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- constantPool =
- (sun_reflect_ConstantPool*)native_new_and_init(
- class_sun_reflect_ConstantPool);
-
- if (constantPool == NULL) {
- /* out of memory */
+ // TODO Use a constructor.
+ java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+
+ if (h == NULL)
return NULL;
- }
- LLNI_field_get_ref(_this, clazz, constantPoolOop);
- LLNI_field_set_ref(constantPool, constantPoolOop, (java_lang_Object*)constantPoolOop);
+ sun_reflect_ConstantPool cp(h);
+
+ java_lang_reflect_VMMethod rvmm(_this);
+ classinfo* declaringClass = rvmm.get_clazz();
+ cp.set_constantPoolOop(declaringClass);
/* only resolve the parser method the first time */
if (m_parseAnnotationDefault == NULL) {
return NULL;
}
- LLNI_class_get(_this, referer);
+ classinfo *referer;
+ LLNI_class_get((java_lang_reflect_VMMethod *) _this, referer);
m_parseAnnotationDefault = class_resolveclassmethod(
class_sun_reflect_annotation_AnnotationParser,
}
}
- LLNI_field_get_ref(_this, m, rm);
- LLNI_field_get_ref(_this, annotationDefault, annotationDefault);
+ java_lang_reflect_Method rm(rvmm.get_m());
+ java_handle_bytearray_t* annotationDefault = rvmm.get_annotationDefault();
- h = vm_call_method(m_parseAnnotationDefault, NULL, rm, annotationDefault, constantPool);
+ java_handle_t* result = vm_call_method(m_parseAnnotationDefault, NULL, rm.get_handle(), annotationDefault, cp.get_handle());
- return (java_lang_Object*) h;
+ return (jobject) result;
}
* Class: java/lang/reflect/VMMethod
* Method: declaredAnnotations
* Signature: ()Ljava/util/Map;
- *
- * Parses the annotations (if they aren't parsed yet) and stores them into
- * the declaredAnnotations map and return this map.
*/
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *_this)
+JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, jobject _this)
{
- java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
- java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
- java_lang_Class *declaringClass = NULL; /* the constant pool of _this class is used */
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMMethod rvmm(_this);
+ java_handle_t* declaredAnnotations = rvmm.get_declaredAnnotations();
- LLNI_field_get_ref(_this, declaredAnnotations, declaredAnnotations);
-
- /* are the annotations parsed yet? */
+ // Are the annotations parsed yet?
if (declaredAnnotations == NULL) {
- LLNI_field_get_ref(_this, annotations, annotations);
- LLNI_field_get_ref(_this, clazz, declaringClass);
- LLNI_class_get(_this, referer);
+ java_handle_bytearray_t* annotations = rvmm.get_annotations();
+ classinfo* declaringClass = rvmm.get_clazz();
+
+ classinfo *referer;
+ LLNI_class_get((java_lang_reflect_VMMethod *) _this, referer);
- declaredAnnotations = reflect_get_declaredannotations(annotations, (classinfo*) declaringClass, referer);
+ declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer);
- LLNI_field_set_ref(_this, declaredAnnotations, declaredAnnotations);
+ rvmm.set_declaredAnnotations(declaredAnnotations);
}
- return declaredAnnotations;
+ return (jobject) declaredAnnotations;
}
* Class: java/lang/reflect/VMMethod
* Method: getParameterAnnotations
* Signature: ()[[Ljava/lang/annotation/Annotation;
- *
- * Parses the parameter annotations and returns them in an 2 dimensional array.
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *_this)
+JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, jobject _this)
{
- java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */
- int32_t slot = -1; /* slot of the method */
- classinfo *c;
- methodinfo* m;
- classinfo *referer = NULL; /* class, which calles the annotation parser */
- /* (for the parameter 'referer' of vm_call_method()) */
+ java_lang_reflect_VMMethod rvmm(_this);
+ java_handle_bytearray_t* parameterAnnotations = rvmm.get_parameterAnnotations();
+ methodinfo* m = rvmm.get_method();
- LLNI_field_get_ref(_this, parameterAnnotations, parameterAnnotations);
- LLNI_field_get_val(_this, slot, slot);
- LLNI_field_get_cls(_this, clazz, c);
- m = &(c->methods[slot]);
+ classinfo* referer;
+ LLNI_class_get((java_lang_reflect_VMMethod *) _this, referer);
- LLNI_class_get(_this, referer);
-
- return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, m, referer);
+ java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer);
+ return (jobjectArray) oa;
}
#endif
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal },
+ { (char*) "getReturnType", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType },
+ { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes },
+ { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes },
+ { (char*) "invoke", (char*) "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke },
+ { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature },
+#if defined(ENABLE_ANNOTATIONS)
+ { (char*) "getDefaultValue", (char*) "()Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue },
+ { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations },
+ { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations },
+#endif
+};
+
+
+/* _Jv_java_lang_reflect_VMMethod_init *****************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_java_lang_reflect_VMMethod_init(void)
+{
+ utf *u;
+
+ u = utf_new_char("java/lang/reflect/VMMethod");
+
+ native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
-/* src/native/vm/gnu/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
+/* src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
- 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
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "native/jni.h"
#include "native/native.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_ClassLoader.h"
-
-#include "native/include/java_lang_reflect_VMProxy.h"
+// FIXME
+//#include "native/include/java_lang_reflect_VMProxy.h"
/* native methods implemented by this file ************************************/
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/java_security_VMAccessController.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/vm/include/java_security_VMAccessController.h"
+#endif
#include "vm/global.h"
* Method: getStack
* Signature: ()[[Ljava/lang/Object;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
+JNIEXPORT jobjectArray JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
{
- return stacktrace_get_stack();
+ return (jobjectArray) stacktrace_get_stack();
}
} // extern "C"
-/* src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.cpp
+/* src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp
Copyright (C) 2007, 2008
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
#include "native/jni.h"
#include "native/native.h"
-// FIXME
-extern "C" {
-#include "native/include/java_util_concurrent_atomic_AtomicLong.h"
-}
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/java_util_concurrent_atomic_AtomicLong.h"
+#endif
#include "vmcore/utf8.h"
* Method: VMSupportsCS8
* Signature: ()Z
*/
-JNIEXPORT int32_t JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz)
+JNIEXPORT jboolean JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz)
{
- /* IMPLEMENT ME */
-
+ // IMPLEMENT ME
return 0;
}
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-
// FIXME
-extern "C" {
-#include "native/include/sun_reflect_ConstantPool.h"
-}
+//#include "native/include/sun_reflect_ConstantPool.h"
-#include "native/vm/reflect.h"
+#include "native/vm/reflection.hpp"
#include "toolbox/logging.h"
#include "vm/string.hpp"
#include "vmcore/class.h"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/utf8.h"
-/* native methods implemented by this file ************************************/
-
-static JNINativeMethod methods[] = {
- { (char*) "getSize0", (char*) "(Ljava/lang/Object;I)I", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getSize0 },
- { (char*) "getClassAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAt0 },
- { (char*) "getClassAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0 },
- { (char*) "getMethodAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0 },
- { (char*) "getMethodAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 },
- { (char*) "getFieldAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0 },
- { (char*) "getFieldAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0 },
- { (char*) "getMemberRefInfoAt0", (char*) "(Ljava/lang/Object;I)[Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0 },
- { (char*) "getIntAt0", (char*) "(Ljava/lang/Object;I)I", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getIntAt0 },
- { (char*) "getLongAt0", (char*) "(Ljava/lang/Object;I)J", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getLongAt0 },
- { (char*) "getFloatAt0", (char*) "(Ljava/lang/Object;I)F", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0 },
- { (char*) "getDoubleAt0", (char*) "(Ljava/lang/Object;I)D", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0 },
- { (char*) "getStringAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getStringAt0 },
- { (char*) "getUTF8At0", (char*) "(Ljava/lang/Object;I)Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0 },
-};
-
-
-/* _Jv_sun_reflect_ConstantPool_init ******************************************
-
- Register native functions.
-
-*******************************************************************************/
-
-// FIXME
-extern "C" {
-void _Jv_sun_reflect_ConstantPool_init(void)
-{
- native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT);
-}
-}
-
-
extern "C" {
/*
* Method: getSize0
* Signature: (Ljava/lang/Object;)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool)
+JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, jobject _this, jobject jcpool)
{
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
return cls->cpcount;
* Method: getClassAt0
* Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
*/
-JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_classref *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
return NULL;
}
- return LLNI_classinfo_wrap(resolve_classref_eager(ref));
+ return (jclass) LLNI_classinfo_wrap(resolve_classref_eager(ref));
}
* Method: getClassAtIfLoaded0
* Signature: (Ljava/lang/Object;I)Ljava/lang/Class;
*/
-JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_classref *ref;
classinfo *c = NULL;
return NULL;
}
- return LLNI_classinfo_wrap(c);
+ return (jclass) LLNI_classinfo_wrap(c);
}
* Method: getMethodAt0
* Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
*/
-JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_FMIref *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
}
/* XXX: is that right? or do I have to use resolve_method_*? */
- return (struct java_lang_reflect_Member*) reflect_method_new(ref->p.method);
+ java_lang_reflect_Method jlrm(ref->p.method);
+
+ return (jobject) jlrm.get_handle();
}
* Method: getMethodAtIfLoaded0
* Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member;
*/
-JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_FMIref *ref;
classinfo *c = NULL;
return NULL;
}
- return (struct java_lang_reflect_Member*) reflect_method_new(ref->p.method);
+ java_lang_reflect_Method jlrm(ref->p.method);
+
+ return (jobject) jlrm.get_handle();
}
* Method: getFieldAt0
* Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
*/
-JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_FMIref *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
- ref = (constant_FMIref*)class_getconstant(
- cls, index, CONSTANT_Fieldref);
+ ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref);
if (ref == NULL) {
exceptions_throw_illegalargumentexception();
return NULL;
}
- return (struct java_lang_reflect_Field*) reflect_field_new(ref->p.field);
+ // Create a new java.lang.reflect.Field Java object.
+ java_lang_reflect_Field jlrf(ref->p.field);
+
+ return (jobject) jlrf.get_handle();
}
* Method: getFieldAtIfLoaded0
* Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field;
*/
-JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_FMIref *ref;
classinfo *c;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
- ref = (constant_FMIref*)class_getconstant(
- cls, index, CONSTANT_Fieldref);
+ ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref);
if (ref == NULL) {
exceptions_throw_illegalargumentexception();
return NULL;
}
- return (struct java_lang_reflect_Field*) reflect_field_new(ref->p.field);
+ // Create a new java.lang.reflect.Field Java object.
+ java_lang_reflect_Field jlrf(ref->p.field);
+
+ return (jobject) jlrf.get_handle();
}
* Method: getMemberRefInfoAt0
* Signature: (Ljava/lang/Object;I)[Ljava/lang/String;
*/
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jobjectArray JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index);
return NULL;
* Method: getIntAt0
* Signature: (Ljava/lang/Object;I)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_integer *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
- ref = (constant_integer*)class_getconstant(
- cls, index, CONSTANT_Integer);
+ ref = (constant_integer*) class_getconstant(cls, index, CONSTANT_Integer);
if (ref == NULL) {
exceptions_throw_illegalargumentexception();
* Method: getLongAt0
* Signature: (Ljava/lang/Object;I)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jlong JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_long *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
* Method: getFloatAt0
* Signature: (Ljava/lang/Object;I)F
*/
-JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_float *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
* Method: getDoubleAt0
* Signature: (Ljava/lang/Object;I)D
*/
-JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
constant_double *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
* Method: getStringAt0
* Signature: (Ljava/lang/Object;I)Ljava/lang/String;
*/
-JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
utf *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
}
/* XXX: I hope literalstring_new is the right Function. */
- return (java_lang_String*)literalstring_new(ref);
+ return (jstring) literalstring_new(ref);
}
* Method: getUTF8At0
* Signature: (Ljava/lang/Object;I)Ljava/lang/String;
*/
-JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, struct sun_reflect_ConstantPool* _this, struct java_lang_Object* jcpool, int32_t index)
+JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, jobject _this, jobject jcpool, jint index)
{
utf *ref;
classinfo *cls = LLNI_classinfo_unwrap(jcpool);
}
/* XXX: I hope literalstring_new is the right Function. */
- return (java_lang_String*)literalstring_new(ref);
+ return (jstring) literalstring_new(ref);
}
} // extern "C"
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+ { (char*) "getSize0", (char*) "(Ljava/lang/Object;I)I", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getSize0 },
+ { (char*) "getClassAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAt0 },
+ { (char*) "getClassAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0 },
+ { (char*) "getMethodAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0 },
+ { (char*) "getMethodAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 },
+ { (char*) "getFieldAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0 },
+ { (char*) "getFieldAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0 },
+ { (char*) "getMemberRefInfoAt0", (char*) "(Ljava/lang/Object;I)[Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0 },
+ { (char*) "getIntAt0", (char*) "(Ljava/lang/Object;I)I", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getIntAt0 },
+ { (char*) "getLongAt0", (char*) "(Ljava/lang/Object;I)J", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getLongAt0 },
+ { (char*) "getFloatAt0", (char*) "(Ljava/lang/Object;I)F", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0 },
+ { (char*) "getDoubleAt0", (char*) "(Ljava/lang/Object;I)D", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0 },
+ { (char*) "getStringAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getStringAt0 },
+ { (char*) "getUTF8At0", (char*) "(Ljava/lang/Object;I)Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0 },
+};
+
+
+/* _Jv_sun_reflect_ConstantPool_init ******************************************
+
+ Register native functions.
+
+*******************************************************************************/
+
+// FIXME
+extern "C" {
+void _Jv_sun_reflect_ConstantPool_init(void)
+{
+ native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT);
+}
+}
+
+
/*
* 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
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_AssertionStatusDirectives.h"
-#include "native/include/java_lang_String.h" /* required by j.l.CL */
-#include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-#include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */
-#include "native/include/java_lang_StackTraceElement.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_security_ProtectionDomain.h"
-
-#if defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/vm/reflect.h"
+#include "native/vm/reflection.hpp"
#include "native/vm/openjdk/hpi.h"
#include "vmcore/classcache.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/options.h"
#include "vmcore/os.hpp"
void JVM_FillInStackTrace(JNIEnv *env, jobject receiver)
{
- java_lang_Throwable *o;
- java_handle_bytearray_t *ba;
-
TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver));
- o = (java_lang_Throwable *) receiver;
-
- ba = stacktrace_get_current();
+ java_handle_bytearray_t* ba = stacktrace_get_current();
if (ba == NULL)
return;
- LLNI_field_set_ref(o, backtrace, (java_lang_Object *) ba);
+ java_lang_Throwable jlt(receiver, ba);
}
jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable)
{
- java_lang_Throwable *to;
- java_lang_Object *o;
- java_handle_bytearray_t *ba;
- stacktrace_t *st;
- int32_t depth;
-
TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable));
- if (throwable == NULL) {
+ java_lang_Throwable jlt(throwable);
+
+ if (jlt.is_null()) {
exceptions_throw_nullpointerexception();
return 0;
}
- to = (java_lang_Throwable *) throwable;
-
- LLNI_field_get_ref(to, backtrace, o);
-
- ba = (java_handle_bytearray_t *) o;
+ java_handle_bytearray_t* ba = jlt.get_backtrace();
if (ba == NULL)
return 0;
- /* We need a critical section here as the stacktrace structure is
- mapped onto a Java byte-array. */
+ // We need a critical section here as the stacktrace structure is
+ // mapped onto a Java byte-array.
LLNI_CRITICAL_START;
- st = (stacktrace_t *) LLNI_array_data(ba);
+ stacktrace_t* st = (stacktrace_t *) LLNI_array_data(ba);
- depth = st->length;
+ int32_t depth = st->length;
LLNI_CRITICAL_END;
jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
{
- java_lang_Throwable *to;
- java_lang_Object *o;
- java_handle_bytearray_t *ba;
- stacktrace_t *st;
- stacktrace_entry_t *ste;
- codeinfo *code;
- methodinfo *m;
- classinfo *c;
- java_lang_StackTraceElement *steo;
- java_handle_t* declaringclass;
- java_lang_String *filename;
- int32_t linenumber;
-
TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index));
- to = (java_lang_Throwable *) throwable;
-
- LLNI_field_get_ref(to, backtrace, o);
+ java_lang_Throwable jlt(throwable);
+ java_handle_bytearray_t* ba = jlt.get_backtrace();
- ba = (java_handle_bytearray_t *) o;
-
- /* FIXME critical section */
+ // We need a critical section here as the stacktrace structure is
+ // mapped onto a Java byte-array.
+ LLNI_CRITICAL_START;
- st = (stacktrace_t *) LLNI_array_data(ba);
+ stacktrace_t* st = (stacktrace_t *) LLNI_array_data(ba);
if ((index < 0) || (index >= st->length)) {
/* XXX This should be an IndexOutOfBoundsException (check this
again). */
-
exceptions_throw_arrayindexoutofboundsexception();
return NULL;
}
- /* Get the stacktrace entry. */
-
- ste = &(st->entries[index]);
+ // Get the stacktrace entry.
+ stacktrace_entry_t* ste = &(st->entries[index]);
- /* Get the codeinfo, methodinfo and classinfo. */
+ // Get the codeinfo, methodinfo and classinfo.
+ codeinfo* code = ste->code;
+ methodinfo* m = code->m;
+ classinfo* c = m->clazz;
- code = ste->code;
- m = code->m;
- c = m->clazz;
-
- /* allocate a new StackTraceElement */
-
- steo = (java_lang_StackTraceElement *)
- builtin_new(class_java_lang_StackTraceElement);
-
- if (steo == NULL)
- return NULL;
-
- /* get filename */
+ // Get filename.
+ java_handle_t* filename;
if (!(m->flags & ACC_NATIVE)) {
if (c->sourcefile != NULL)
- filename = (java_lang_String *) javastring_new(c->sourcefile);
+ filename = javastring_new(c->sourcefile);
else
filename = NULL;
}
else
filename = NULL;
- /* get line number */
+ // Get line number.
+ int32_t linenumber;
if (m->flags & ACC_NATIVE) {
linenumber = -2;
linenumber = (linenumber == 0) ? -1 : linenumber;
}
- /* get declaring class name */
-
- declaringclass = class_get_classname(c);
+ LLNI_CRITICAL_END;
- /* fill the java.lang.StackTraceElement element */
+ // Get declaring class name.
+ java_handle_t* declaringclass = class_get_classname(c);
- /* FIXME critical section */
+ // Allocate a new StackTraceElement object.
+ java_lang_StackTraceElement jlste(declaringclass, javastring_new(m->name), filename, linenumber);
- steo->declaringClass = (java_lang_String*) declaringclass;
- steo->methodName = (java_lang_String*) javastring_new(m->name);
- steo->fileName = filename;
- steo->lineNumber = linenumber;
+ if (jlste.is_null())
+ return NULL;
- return (jobject) steo;
+ return (jobject) jlste.get_handle();
}
jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
{
- classinfo *c = NULL; /* classinfo for 'cls' */
- java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
-
- TRACEJVMCALLS(("JVM_GetClassAnnotations: cls=%p", cls));
+ TRACEJVMCALLS(("JVM_GetClassAnnotations(env=%p, cls=%p)", env, cls));
if (cls == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- c = LLNI_classinfo_unwrap(cls);
+ classinfo* c = LLNI_classinfo_unwrap(cls);
/* get annotations: */
- annotations = class_get_annotations(c);
+ java_handle_bytearray_t* annotations = class_get_annotations(c);
- return (jbyteArray)annotations;
+ return (jbyteArray) annotations;
}
jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
{
- java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */
- java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
+ TRACEJVMCALLS(("JVM_GetFieldAnnotations(env=%p, field=%p)", env, field));
- TRACEJVMCALLS(("JVM_GetFieldAnnotations: field=%p", field));
+ java_lang_reflect_Field jlrf(field);
- if (field == NULL) {
+ if (jlrf.is_null()) {
exceptions_throw_nullpointerexception();
return NULL;
}
- rf = (java_lang_reflect_Field*)field;
-
- LLNI_field_get_ref(rf, annotations, ba);
-
- return (jbyteArray)ba;
+ return (jbyteArray) jlrf.get_annotations();
}
jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
{
- java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
- java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
+ TRACEJVMCALLS(("JVM_GetMethodAnnotations(env=%p, method=%p)", env, method));
- TRACEJVMCALLS(("JVM_GetMethodAnnotations: method=%p", method));
+ java_lang_reflect_Method jlrm(method);
- if (method == NULL) {
+ if (jlrm.is_null()) {
exceptions_throw_nullpointerexception();
return NULL;
}
- rm = (java_lang_reflect_Method*)method;
-
- LLNI_field_get_ref(rm, annotations, ba);
-
- return (jbyteArray)ba;
+ return (jbyteArray) jlrm.get_annotations();
}
jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
{
- java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
- java_handle_bytearray_t *ba = NULL; /* unparsed annotation default value */
+ TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue(env=%p, method=%p)", env, method));
- TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue: method=%p", method));
+ java_lang_reflect_Method jlrm(method);
- if (method == NULL) {
+ if (jlrm.is_null()) {
exceptions_throw_nullpointerexception();
return NULL;
}
- rm = (java_lang_reflect_Method*)method;
-
- LLNI_field_get_ref(rm, annotationDefault, ba);
-
- return (jbyteArray)ba;
+ return (jbyteArray) jlrm.get_annotationDefault();
}
jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
{
- java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
- java_handle_bytearray_t *ba = NULL; /* unparsed parameter annotations */
+ TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations(env=%p, method=%p)", env, method));
- TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations: method=%p", method));
+ java_lang_reflect_Method jlrm(method);
- if (method == NULL) {
+ if (jlrm.is_null()) {
exceptions_throw_nullpointerexception();
return NULL;
}
- rm = (java_lang_reflect_Method*)method;
-
- LLNI_field_get_ref(rm, parameterAnnotations, ba);
-
- return (jbyteArray)ba;
+ return (jbyteArray) jlrm.get_parameterAnnotations();
}
jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
{
- classinfo *c;
- java_handle_objectarray_t *oa;
-
TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
- c = LLNI_classinfo_unwrap(ofClass);
+ classinfo* c = LLNI_classinfo_unwrap(ofClass);
- oa = class_get_declaredmethods(c, publicOnly);
+ java_handle_objectarray_t* oa = class_get_declaredmethods(c, publicOnly);
return (jobjectArray) oa;
}
jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
{
#if defined(ENABLE_ANNOTATIONS)
- sun_reflect_ConstantPool *constantPool = NULL;
- /* constant pool object for the class refered by 'cls' */
- java_lang_Object *constantPoolOop = (java_lang_Object*)cls;
- /* constantPoolOop field of the constant pool object */
-
TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls));
- constantPool =
- (sun_reflect_ConstantPool*)native_new_and_init(
- class_sun_reflect_ConstantPool);
+ java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+ sun_reflect_ConstantPool cp(h, cls);
- if (constantPool == NULL) {
- /* out of memory */
+ if (cp.is_null()) {
return NULL;
}
- LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
- return (jobject)constantPool;
+ return (jobject) cp.get_handle();
#else
log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls);
return NULL;
return NULL;
}
+ // Create a new java.lang.reflect.Method Java object.
/* XXX: is that right? or do I have to use resolve_method_*? */
- return (jobject)reflect_method_new(ref->p.method);
+ java_lang_reflect_Method jlrm(ref->p.method);
+
+ return (jobject) jlrm.get_handle();
}
return NULL;
}
- return (jobject)reflect_method_new(ref->p.method);
+ // Create a new java.lang.reflect.Method Java object.
+ java_lang_reflect_Method jlrm(ref->p.method);
+
+ return (jobject) jlrm.get_handle();
}
return NULL;
}
- return (jobject)reflect_field_new(ref->p.field);
+ // Create a new java.lang.reflect.Field Java object.
+ java_lang_reflect_Field jlrf(ref->p.field);
+
+ return (jobject) jlrf.get_handle();
}
return NULL;
}
- return (jobject)reflect_field_new(ref->p.field);
+ // Create a new java.lang.reflect.Field Java object.
+ java_lang_reflect_Field jlrf(ref->p.field);
+
+ return (jobject) jlrf.get_handle();
}
jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
{
- classinfo *c;
- java_lang_AssertionStatusDirectives *o;
java_handle_objectarray_t *classes;
java_handle_objectarray_t *packages;
java_booleanarray_t *classEnabled;
TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
- c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
-
- if (c == NULL)
- return NULL;
-
- o = (java_lang_AssertionStatusDirectives *) builtin_new(c);
-
- if (o == NULL)
- return NULL;
-
#if defined(ENABLE_ASSERTION)
classes = builtin_anewarray(assertion_class_count, class_java_lang_Object);
#else
/* set instance fields */
- o->classes = classes;
- o->packages = packages;
- o->classEnabled = classEnabled;
- o->packageEnabled = packageEnabled;
+ java_lang_AssertionStatusDirectives jlasd(classes, classEnabled, packages, packageEnabled);
- return (jobject) o;
+ return (jobject) jlasd.get_handle();
}
jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
{
- java_lang_reflect_Method *rm;
- classinfo *c;
- int32_t slot;
- int32_t override;
- methodinfo *m;
- java_handle_t *ro;
-
TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
- rm = (java_lang_reflect_Method *) method;
-
- LLNI_field_get_cls(rm, clazz, c);
- LLNI_field_get_val(rm, slot, slot);
- LLNI_field_get_val(rm, override, override);
-
- m = &(c->methods[slot]);
-
- ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override);
+ java_lang_reflect_Method jlrm(method);
+
+ java_handle_t* result = jlrm.invoke((java_handle_t*) obj, (java_handle_objectarray_t*) args0);
- return (jobject) ro;
+ return (jobject) result;
}
jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
{
- java_lang_reflect_Constructor *rc;
- classinfo *c;
- int32_t slot;
- int32_t override;
- methodinfo *m;
- java_handle_t *o;
-
TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
- rc = (java_lang_reflect_Constructor *) con;
-
- LLNI_field_get_cls(rc, clazz, c);
- LLNI_field_get_val(rc, slot, slot);
- LLNI_field_get_val(rc, override, override);
-
- m = &(c->methods[slot]);
-
- o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override);
+ java_lang_reflect_Constructor jlrc(con);
+ java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args0);
return (jobject) o;
}
+++ /dev/null
-/* src/native/vm/reflect.c - helper functions for java/lang/reflect
-
- Copyright (C) 2007, 2008
- CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
- 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 "native/jni.h"
-#include "native/llni.h"
-#include "native/native.h"
-
-/* keep this order of the native includes */
-
-#include "native/include/java_lang_String.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-#endif
-#include "native/include/java_lang_ClassLoader.h"
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_reflect_Constructor.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_reflect_Method.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_reflect_VMConstructor.h"
-# include "native/include/java_lang_reflect_VMField.h"
-# include "native/include/java_lang_reflect_VMMethod.h"
-#endif
-
-#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "vm/vm.hpp"
-# include "native/include/sun_reflect_ConstantPool.h"
-#endif
-
-#include "native/vm/reflect.h"
-
-#include "vm/access.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.hpp"
-#include "vm/global.h"
-#include "vm/initialize.h"
-#include "vm/string.hpp"
-
-#include "vmcore/globals.hpp"
-#include "vmcore/method.h"
-
-
-/* reflect_constructor_new *****************************************************
-
- Allocates a new java.lang.reflect.Constructor object and
- initializes the fields with the method passed.
-
-*******************************************************************************/
-
-java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
-{
- java_handle_t *o;
- java_lang_reflect_Constructor *rc;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMConstructor *rvmc;
-#endif
-
- /* Allocate a java.lang.reflect.Constructor object. */
-
- o = builtin_new(class_java_lang_reflect_Constructor);
-
- if (o == NULL)
- return NULL;
-
- /* Initialize instance fields. */
-
- rc = (java_lang_reflect_Constructor *) o;
-
- /* Calculate the slot. */
-
- slot = m - m->clazz->methods;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- /* Allocate a java.lang.reflect.VMConstructor object. */
-
- o = builtin_new(class_java_lang_reflect_VMConstructor);
-
- if (o == NULL)
- return NULL;
-
- rvmc = (java_lang_reflect_VMConstructor *) o;
-
- /* Link the two Java objects. */
-
- LLNI_field_set_ref(rc, cons, rvmc);
- LLNI_field_set_ref(rvmc, cons, rc);
-
- /* Set Java object instance fields. */
-
- LLNI_field_set_cls(rvmc, clazz, m->clazz);
- LLNI_field_set_val(rvmc, slot, slot);
- LLNI_field_set_ref(rvmc, annotations, method_get_annotations(m));
- LLNI_field_set_ref(rvmc, parameterAnnotations, method_get_parameterannotations(m));
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
- /* Set Java object instance fields. */
-
- LLNI_field_set_cls(rc, clazz , m->clazz);
- LLNI_field_set_ref(rc, parameterTypes , method_get_parametertypearray(m));
- LLNI_field_set_ref(rc, exceptionTypes , method_get_exceptionarray(m));
- LLNI_field_set_val(rc, modifiers , m->flags & ACC_CLASS_REFLECT_MASK);
- LLNI_field_set_val(rc, slot , slot);
- LLNI_field_set_ref(rc, signature , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
- LLNI_field_set_ref(rc, annotations , method_get_annotations(m));
- LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
-
-#else
-# error unknown classpath configuration
-#endif
-
- return rc;
-}
-
-
-/* reflect_field_new ***********************************************************
-
- Allocates a new java.lang.reflect.Field object and initializes the
- fields with the field passed.
-
-*******************************************************************************/
-
-java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
-{
- java_handle_t *o;
- java_lang_reflect_Field *rf;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMField *rvmf;
-#endif
-
- /* Allocate a java.lang.reflect.Field object. */
-
- o = builtin_new(class_java_lang_reflect_Field);
-
- if (o == NULL)
- return NULL;
-
- /* initialize instance fields */
-
- rf = (java_lang_reflect_Field *) o;
-
- /* Calculate the slot. */
-
- slot = f - f->clazz->fields;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- /* Allocate a java.lang.reflect.VMField object. */
-
- o = builtin_new(class_java_lang_reflect_VMField);
-
- if (o == NULL)
- return NULL;
-
- rvmf = (java_lang_reflect_VMField *) o;
-
- /* Link the two Java objects. */
-
- LLNI_field_set_ref(rf, f, rvmf);
- LLNI_field_set_ref(rvmf, f, rf);
-
- /* Set the Java object fields. */
-
- LLNI_field_set_cls(rvmf, clazz, f->clazz);
-
- /* The name needs to be interned */
- /* XXX implement me better! */
-
- LLNI_field_set_ref(rvmf, name, (java_lang_String *) javastring_intern(javastring_new(f->name)));
- LLNI_field_set_val(rvmf, slot, slot);
- LLNI_field_set_ref(rvmf, annotations, field_get_annotations(f));
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
- /* Set the Java object fields. */
-
- LLNI_field_set_cls(rf, clazz, f->clazz);
-
- /* The name needs to be interned */
- /* XXX implement me better! */
-
- LLNI_field_set_ref(rf, name, (java_lang_String *) javastring_intern(javastring_new(f->name)));
- LLNI_field_set_cls(rf, type, (java_lang_Class *) field_get_type(f));
- LLNI_field_set_val(rf, modifiers, f->flags);
- LLNI_field_set_val(rf, slot, slot);
- LLNI_field_set_ref(rf, signature, f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL);
- LLNI_field_set_ref(rf, annotations, field_get_annotations(f));
-
-#else
-# error unknown classpath configuration
-#endif
-
- return rf;
-}
-
-
-/* reflect_method_new **********************************************************
-
- Allocates a new java.lang.reflect.Method object and initializes the
- fields with the method passed.
-
-*******************************************************************************/
-
-java_lang_reflect_Method *reflect_method_new(methodinfo *m)
-{
- java_handle_t *o;
- java_lang_reflect_Method *rm;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMMethod *rvmm;
-#endif
-
- /* Allocate a java.lang.reflect.Method object. */
-
- o = builtin_new(class_java_lang_reflect_Method);
-
- if (o == NULL)
- return NULL;
-
- /* initialize instance fields */
-
- rm = (java_lang_reflect_Method *) o;
-
- /* Calculate the slot. */
-
- slot = m - m->clazz->methods;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- /* Allocate a java.lang.reflect.VMMethod object. */
-
- o = builtin_new(class_java_lang_reflect_VMMethod);
-
- if (o == NULL)
- return NULL;
-
- rvmm = (java_lang_reflect_VMMethod *) o;
-
- /* Link the two Java objects. */
-
- LLNI_field_set_ref(rm, m, rvmm);
- LLNI_field_set_ref(rvmm, m, rm);
-
- /* Set Java object instance fields. */
-
- LLNI_field_set_cls(rvmm, clazz, m->clazz);
-
- /* The name needs to be interned */
- /* XXX implement me better! */
-
- LLNI_field_set_ref(rvmm, name, (java_lang_String *) javastring_intern(javastring_new(m->name)));
- LLNI_field_set_val(rvmm, slot, slot);
- LLNI_field_set_ref(rvmm, annotations, method_get_annotations(m));
- LLNI_field_set_ref(rvmm, parameterAnnotations, method_get_parameterannotations(m));
- LLNI_field_set_ref(rvmm, annotationDefault, method_get_annotationdefault(m));
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
- LLNI_field_set_cls(rm, clazz, m->clazz);
-
- /* The name needs to be interned */
- /* XXX implement me better! */
-
- LLNI_field_set_ref(rm, name, (java_lang_String *) javastring_intern(javastring_new(m->name)));
- LLNI_field_set_ref(rm, parameterTypes, method_get_parametertypearray(m));
- LLNI_field_set_cls(rm, returnType, (java_lang_Class *) method_returntype_get(m));
- LLNI_field_set_ref(rm, exceptionTypes, method_get_exceptionarray(m));
- LLNI_field_set_val(rm, modifiers, m->flags & ACC_CLASS_REFLECT_MASK);
- LLNI_field_set_val(rm, slot, slot);
- LLNI_field_set_ref(rm, signature, m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
- LLNI_field_set_ref(rm, annotations, method_get_annotations(m));
- LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
- LLNI_field_set_ref(rm, annotationDefault, method_get_annotationdefault(m));
-
-#else
-# error unknown classpath configuration
-#endif
-
- return rm;
-}
-
-
-/* reflect_invoke **************************************************************
-
- Invoke a method on the given object with the given arguments.
-
- For instance methods OBJ must be != NULL and the method is looked up
- in the vftbl of the object.
-
- For static methods, OBJ is ignored.
-
-*******************************************************************************/
-
-static java_handle_t *reflect_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params)
-{
- methodinfo *resm;
- java_handle_t *ro;
- int argcount;
- int paramcount;
-
- /* Sanity check. */
-
- assert(m != NULL);
-
- argcount = m->parseddesc->paramcount;
- paramcount = argcount;
-
- /* If method is non-static, remove the `this' pointer. */
-
- if (!(m->flags & ACC_STATIC))
- paramcount--;
-
- /* For instance methods the object has to be an instance of the
- class the method belongs to. For static methods the obj
- parameter is ignored. */
-
- if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->clazz))) {
- exceptions_throw_illegalargumentexception();
- return NULL;
- }
-
- /* check if we got the right number of arguments */
-
- if (((params == NULL) && (paramcount != 0)) ||
- (params && (LLNI_array_size(params) != paramcount)))
- {
- exceptions_throw_illegalargumentexception();
- return NULL;
- }
-
- /* for instance methods we need an object */
-
- if (!(m->flags & ACC_STATIC) && (o == NULL)) {
- /* XXX not sure if that is the correct exception */
- exceptions_throw_nullpointerexception();
- return NULL;
- }
-
- /* for static methods, zero object to make subsequent code simpler */
- if (m->flags & ACC_STATIC)
- o = NULL;
-
- if (o != NULL) {
- /* for instance methods we must do a vftbl lookup */
- resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m);
- }
- else {
- /* for static methods, just for convenience */
- resm = m;
- }
-
- ro = vm_call_method_objectarray(resm, o, params);
-
- return ro;
-}
-
-
-/* reflect_constructor_newinstance ********************************************
-
- Creates an Java object instance of the given constructor.
-
- ARGUMENTS:
- m .......... methodinfo of the constructor
- args ....... constructor arguments
- override ... override security checks
-
- RETURN:
- constructed Java object
-
-*******************************************************************************/
-
-java_handle_t *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override)
-{
- java_handle_t *o;
-
- /* Should we bypass security the checks (AccessibleObject)? */
-
- if (override == false) {
- /* This method is always called like this:
- [0] java.lang.reflect.Constructor.constructNative (Native Method)
- [1] java.lang.reflect.Constructor.newInstance
- [2] <caller>
- */
-
- if (!access_check_method(m, 2))
- return NULL;
- }
-
- /* Create a Java object. */
-
- o = builtin_new(m->clazz);
-
- if (o == NULL)
- return NULL;
-
- /* Call initializer. */
-
- (void) reflect_invoke(m, o, args);
-
- return o;
-}
-
-
-/* reflect_method_invoke *******************************************************
-
- Invokes the given method.
-
- ARGUMENTS:
- m .......... methodinfo
- args ....... method arguments
- override ... override security checks
-
- RETURN:
- return value of the method
-
-*******************************************************************************/
-
-java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override)
-{
- java_handle_t *ro;
-
- /* Should we bypass security the checks (AccessibleObject)? */
-
- if (override == false) {
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- /* This method is always called like this:
- [0] java.lang.reflect.Method.invokeNative (Native Method)
- [1] java.lang.reflect.Method.invoke (Method.java:329)
- [2] <caller>
- */
-
- if (!access_check_method(m, 2))
- return NULL;
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- /* We only pass 1 here as stacktrace_get_caller_class, which
- is called from access_check_method, skips
- java.lang.reflect.Method.invoke(). */
-
- if (!access_check_method(m, 1))
- return NULL;
-#else
-# error unknown classpath configuration
-#endif
- }
-
- /* Check if method class is initialized. */
-
- if (!(m->clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(m->clazz))
- return NULL;
-
- /* Call the Java method. */
-
- ro = reflect_invoke(m, o, args);
-
- return ro;
-}
-
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
-/* reflect_get_declaredannotations *********************************************
-
- Calls the annotation parser with the unparsed annotations and returnes
- the parsed annotations as a map.
-
- IN:
- annotations........the unparsed annotations
- declaringClass.....the class in which the annotated element is declared
- referer............the calling class (for the 'referer' parameter of
- vm_call_method())
-
- RETURN VALUE:
- The parsed annotations as a
- java.util.Map<Class<? extends Annotation>, Annotation>.
-
-*******************************************************************************/
-
-struct java_util_Map* reflect_get_declaredannotations(
- java_handle_bytearray_t *annotations,
- classinfo *declaringClass,
- classinfo *referer)
-{
- static methodinfo *m_parseAnnotations = NULL;
- /* parser method (chached, therefore static) */
- utf *utf_parseAnnotations = NULL;
- /* parser method name */
- utf *utf_desc = NULL;
- /* parser method descriptor (signature) */
- sun_reflect_ConstantPool *constantPool = NULL;
- /* constant pool of the declaring class */
- java_lang_Object *constantPoolOop = (java_lang_Object*)declaringClass;
- /* constantPoolOop field of the constant pool */
- /* object (sun.reflect.ConstantPool) */
-
- constantPool =
- (sun_reflect_ConstantPool*)native_new_and_init(
- class_sun_reflect_ConstantPool);
-
- if(constantPool == NULL) {
- /* out of memory */
- return NULL;
- }
-
- LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
-
- /* only resolve the parser method the first time */
- if (m_parseAnnotations == NULL) {
- utf_parseAnnotations = utf_new_char("parseAnnotations");
- utf_desc = utf_new_char(
- "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)"
- "Ljava/util/Map;");
-
- if (utf_parseAnnotations == NULL || utf_desc == NULL) {
- /* out of memory */
- return NULL;
- }
-
- m_parseAnnotations = class_resolveclassmethod(
- class_sun_reflect_annotation_AnnotationParser,
- utf_parseAnnotations,
- utf_desc,
- referer,
- true);
-
- if (m_parseAnnotations == NULL) {
- /* method not found */
- return NULL;
- }
- }
-
- return (struct java_util_Map*)vm_call_method(
- m_parseAnnotations, NULL, annotations,
- constantPool, declaringClass);
-}
-
-
-/* reflect_get_parameterannotations *******************************************
-
- Calls the annotation parser with the unparsed parameter annotations of
- a method and returnes the parsed parameter annotations in a 2 dimensional
- array.
-
- IN:
- parameterAnnotations....the unparsed parameter annotations
- slot....................the slot of the method
- declaringClass..........the class in which the annotated element is
- declared
- referer.................the calling class (for the 'referer' parameter
- of vm_call_method())
-
- RETURN VALUE:
- The parsed parameter annotations in a 2 dimensional array.
-
-*******************************************************************************/
-
-java_handle_objectarray_t* reflect_get_parameterannotations(
- java_handle_t *parameterAnnotations,
- methodinfo *m,
- classinfo *referer)
-{
- /* This method in java would be basically the following.
- * We don't do it in java because we don't want to make a
- * public method with wich you can get a ConstantPool, because
- * with that you could read any kind of constants (even private
- * ones).
- *
- * ConstantPool constPool = new ConstantPool();
- * constPool.constantPoolOop = method.getDeclaringClass();
- * return sun.reflect.AnnotationParser.parseParameterAnnotations(
- * parameterAnnotations,
- * constPool,
- * method.getDeclaringClass(),
- * method.getParameterTypes().length);
- */
- static methodinfo *m_parseParameterAnnotations = NULL;
- /* parser method (cached, therefore static) */
- utf *utf_parseParameterAnnotations = NULL;
- /* parser method name */
- utf *utf_desc = NULL;
- /* parser method descriptor (signature) */
- sun_reflect_ConstantPool *constantPool = NULL;
- /* constant pool of the declaring class */
- int32_t numParameters = -1;
- /* parameter count of the annotated method */
-
- /* get parameter count */
-
- numParameters = method_get_parametercount(m);
-
- if (numParameters < 0) {
- /* error parsing descriptor */
- return NULL;
- }
-
- /* get ConstantPool */
-
- constantPool =
- (sun_reflect_ConstantPool*)native_new_and_init(
- class_sun_reflect_ConstantPool);
-
- if(constantPool == NULL) {
- /* out of memory */
- return NULL;
- }
-
- // XXX I'm not sure what the correct LLNI macro would be.
- LLNI_field_set_cls(constantPool, constantPoolOop, (java_lang_Object*) m->clazz);
-
- /* only resolve the parser method the first time */
- if (m_parseParameterAnnotations == NULL) {
- utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations");
- utf_desc = utf_new_char(
- "([BLsun/reflect/ConstantPool;Ljava/lang/Class;I)"
- "[[Ljava/lang/annotation/Annotation;");
-
- if (utf_parseParameterAnnotations == NULL || utf_desc == NULL) {
- /* out of memory */
- return NULL;
- }
-
- /* get parser method */
-
- m_parseParameterAnnotations = class_resolveclassmethod(
- class_sun_reflect_annotation_AnnotationParser,
- utf_parseParameterAnnotations,
- utf_desc,
- referer,
- true);
-
- if (m_parseParameterAnnotations == NULL)
- {
- /* method not found */
- return NULL;
- }
- }
-
- return (java_handle_objectarray_t*)vm_call_method(
- m_parseParameterAnnotations, NULL, parameterAnnotations,
- constantPool, m->clazz, numParameters);
-}
-#endif
-
-
-/*
- * 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/native/vm/reflect.h - helper functions for java/lang/reflect
-
- Copyright (C) 2007, 2008
- CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
- 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 _REFLECT_H
-#define _REFLECT_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "native/jni.h"
-#include "native/native.h"
-
-/* Keep this order of the native includes. */
-
-#include "native/include/java_lang_String.h"
-
-#if defined(ENABLE_JAVASE)
-# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-# endif
-# include "native/include/java_lang_ClassLoader.h"
-#endif
-
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
-
-#if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_reflect_Constructor.h"
-# include "native/include/java_lang_reflect_Field.h"
-# include "native/include/java_lang_reflect_Method.h"
-#endif
-
-#include "vmcore/field.h"
-#include "vmcore/method.h"
-
-
-/* function prototypes ********************************************************/
-
-java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m);
-java_lang_reflect_Field *reflect_field_new(fieldinfo *f);
-java_lang_reflect_Method *reflect_method_new(methodinfo *m);
-java_handle_t *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override);
-java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
-struct java_util_Map* reflect_get_declaredannotations(
- java_handle_bytearray_t *annotations,
- classinfo *declaringClass,
- classinfo *referer);
-
-java_handle_objectarray_t* reflect_get_parameterannotations(
- java_handle_t *parameterAnnotations,
- methodinfo *m,
- classinfo *referer);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _REFLECT_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:
- */
--- /dev/null
+/* src/native/vm/reflection.cpp - helper functions for java/lang/reflect
+
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+ 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 "native/jni.h"
+#include "native/llni.h"
+#include "native/native.h"
+
+#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+# include "vm/vm.hpp"
+#endif
+
+#include "native/vm/reflection.hpp"
+
+#include "vm/access.h"
+#include "vm/builtin.h"
+#include "vm/exceptions.hpp"
+#include "vm/global.h"
+#include "vm/initialize.h"
+#include "vm/string.hpp"
+
+#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
+#include "vmcore/method.h"
+
+
+/**
+ * Invoke a method on the given object with the given arguments.
+ *
+ * For instance methods OBJ must be != NULL and the method is looked up
+ * in the vftbl of the object.
+ *
+ * For static methods, OBJ is ignored.
+ */
+java_handle_t* Reflection::invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params)
+{
+ methodinfo *resm;
+ java_handle_t *ro;
+ int argcount;
+ int paramcount;
+
+ /* Sanity check. */
+
+ assert(m != NULL);
+
+ argcount = m->parseddesc->paramcount;
+ paramcount = argcount;
+
+ /* If method is non-static, remove the `this' pointer. */
+
+ if (!(m->flags & ACC_STATIC))
+ paramcount--;
+
+ /* For instance methods the object has to be an instance of the
+ class the method belongs to. For static methods the obj
+ parameter is ignored. */
+
+ if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->clazz))) {
+ exceptions_throw_illegalargumentexception();
+ return NULL;
+ }
+
+ /* check if we got the right number of arguments */
+
+ if (((params == NULL) && (paramcount != 0)) ||
+ (params && (LLNI_array_size(params) != paramcount)))
+ {
+ exceptions_throw_illegalargumentexception();
+ return NULL;
+ }
+
+ /* for instance methods we need an object */
+
+ if (!(m->flags & ACC_STATIC) && (o == NULL)) {
+ /* XXX not sure if that is the correct exception */
+ exceptions_throw_nullpointerexception();
+ return NULL;
+ }
+
+ /* for static methods, zero object to make subsequent code simpler */
+ if (m->flags & ACC_STATIC)
+ o = NULL;
+
+ if (o != NULL) {
+ /* for instance methods we must do a vftbl lookup */
+ resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m);
+ }
+ else {
+ /* for static methods, just for convenience */
+ resm = m;
+ }
+
+ ro = vm_call_method_objectarray(resm, o, params);
+
+ return ro;
+}
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
+/* reflect_get_declaredannotations *********************************************
+
+ Calls the annotation parser with the unparsed annotations and returnes
+ the parsed annotations as a map.
+
+ IN:
+ annotations........the unparsed annotations
+ declaringClass.....the class in which the annotated element is declared
+ referer............the calling class (for the 'referer' parameter of
+ vm_call_method())
+
+ RETURN VALUE:
+ The parsed annotations as a
+ java.util.Map<Class<? extends Annotation>, Annotation>.
+
+*******************************************************************************/
+
+java_handle_t* Reflection::get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer)
+{
+ static methodinfo* m_parseAnnotations = NULL;
+
+ java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+
+ if (h == NULL)
+ return NULL;
+
+ sun_reflect_ConstantPool cp(h);
+ cp.set_constantPoolOop(declaringClass);
+
+ /* only resolve the parser method the first time */
+ if (m_parseAnnotations == NULL) {
+ // FIXME Use globals.
+ utf* utf_parseAnnotations = utf_new_char("parseAnnotations");
+ utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;)Ljava/util/Map;");
+
+ if (utf_parseAnnotations == NULL || utf_desc == NULL)
+ return NULL;
+
+ m_parseAnnotations = class_resolveclassmethod(
+ class_sun_reflect_annotation_AnnotationParser,
+ utf_parseAnnotations,
+ utf_desc,
+ referer,
+ true);
+
+ if (m_parseAnnotations == NULL)
+ return NULL;
+ }
+
+ return (java_handle_t*) vm_call_method(m_parseAnnotations, NULL, annotations, cp.get_handle(), declaringClass);
+}
+
+
+/* reflect_get_parameterannotations *******************************************
+
+ Calls the annotation parser with the unparsed parameter annotations of
+ a method and returnes the parsed parameter annotations in a 2 dimensional
+ array.
+
+ IN:
+ parameterAnnotations....the unparsed parameter annotations
+ slot....................the slot of the method
+ declaringClass..........the class in which the annotated element is
+ declared
+ referer.................the calling class (for the 'referer' parameter
+ of vm_call_method())
+
+ RETURN VALUE:
+ The parsed parameter annotations in a 2 dimensional array.
+
+*******************************************************************************/
+
+java_handle_objectarray_t* Reflection::get_parameterannotations(java_handle_bytearray_t* parameterAnnotations, methodinfo* m, classinfo* referer)
+{
+ /* This method in java would be basically the following.
+ * We don't do it in java because we don't want to make a
+ * public method with wich you can get a ConstantPool, because
+ * with that you could read any kind of constants (even private
+ * ones).
+ *
+ * ConstantPool constPool = new ConstantPool();
+ * constPool.constantPoolOop = method.getDeclaringClass();
+ * return sun.reflect.AnnotationParser.parseParameterAnnotations(
+ * parameterAnnotations,
+ * constPool,
+ * method.getDeclaringClass(),
+ * method.getParameterTypes().length);
+ */
+
+ static methodinfo* m_parseParameterAnnotations = NULL;
+
+ /* get parameter count */
+
+ int32_t numParameters = method_get_parametercount(m);
+
+ if (numParameters < 0)
+ return NULL;
+
+ /* get ConstantPool */
+
+ java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool);
+
+ if (h == NULL)
+ return NULL;
+
+ sun_reflect_ConstantPool cp(h);
+ cp.set_constantPoolOop(m->clazz);
+
+ /* only resolve the parser method the first time */
+ if (m_parseParameterAnnotations == NULL) {
+ utf* utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations");
+ utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;I)[[Ljava/lang/annotation/Annotation;");
+
+ if (utf_parseParameterAnnotations == NULL || utf_desc == NULL)
+ return NULL;
+
+ /* get parser method */
+
+ m_parseParameterAnnotations = class_resolveclassmethod(
+ class_sun_reflect_annotation_AnnotationParser,
+ utf_parseParameterAnnotations,
+ utf_desc,
+ referer,
+ true);
+
+ if (m_parseParameterAnnotations == NULL)
+ return NULL;
+ }
+
+ return (java_handle_objectarray_t*) vm_call_method(m_parseParameterAnnotations, NULL, parameterAnnotations, cp.get_handle(), m->clazz, numParameters);
+}
+#endif
+
+
+/*
+ * 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/native/vm/reflection.hpp - helper functions for java/lang/reflect
+
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+ 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 _REFLECTION_HPP
+#define _REFLECTION_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/jni.h"
+#include "native/native.h"
+
+#include "vmcore/field.h"
+#include "vmcore/method.h"
+
+
+class Reflection {
+public:
+ static java_handle_t* invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
+ static java_handle_t* get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer);
+ static java_handle_objectarray_t* get_parameterannotations(java_handle_bytearray_t* parameterAnnotations, methodinfo* m, classinfo *referer);
+#endif
+};
+
+#endif // _REFLECTION_HPP
+
+
+/*
+ * 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 "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h" /* before c.l.C */
-#include "native/include/java_lang_String.h" /* required by j.l.CL */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-#endif
-
-#include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_Thread.h" /* required by s.m.U */
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_reflect_VMField.h"
+#if defined(ENABLE_JNI_HEADERS)
+# include "native/include/sun_misc_Unsafe.h"
#endif
-#include "native/include/java_security_ProtectionDomain.h" /* required by smU */
-
-// FIXME
-extern "C" {
-#include "native/include/sun_misc_Unsafe.h"
-}
-
#include "vm/builtin.h"
#include "vm/exceptions.hpp"
#include "vm/initialize.h"
#include "vm/string.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/os.hpp"
#include "vmcore/utf8.h"
* Method: getInt
* Signature: (Ljava/lang/Object;J)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
int32_t *p;
int32_t value;
* Method: putInt
* Signature: (Ljava/lang/Object;JI)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
{
int32_t *p;
* Method: getObject
* Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
void **p;
void *value;
value = *p;
- return (java_lang_Object*) value;
+ return (jobject) value;
}
* Method: putObject
* Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, java_lang_Object *x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
{
void **p;
* Method: getBoolean
* Signature: (Ljava/lang/Object;J)Z
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
int32_t *p;
int32_t value;
* Method: putBoolean
* Signature: (Ljava/lang/Object;JZ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset, jboolean x)
{
int32_t *p;
* Method: getByte
* Signature: (Ljava/lang/Object;J)B
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
int32_t *p;
int32_t value;
* Method: putByte
* Signature: (Ljava/lang/Object;JB)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, jobject _this, jobject o, jlong offset, jbyte x)
{
int32_t *p;
* Method: getShort
* Signature: (Ljava/lang/Object;J)S
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
int32_t *p;
int32_t value;
* Method: putShort
* Signature: (Ljava/lang/Object;JS)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, jobject _this, jobject o, jlong offset, jshort x)
{
int32_t *p;
* Method: getChar
* Signature: (Ljava/lang/Object;J)C
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
int32_t *p;
int32_t value;
* Method: putChar
* Signature: (Ljava/lang/Object;JC)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, jobject _this, jobject o, jlong offset, jchar x)
{
int32_t *p;
* Method: getLong
* Signature: (Ljava/lang/Object;J)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
int64_t *p;
int64_t value;
* Method: putLong
* Signature: (Ljava/lang/Object;JJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int64_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
{
int64_t *p;
* Method: getFloat
* Signature: (Ljava/lang/Object;J)F
*/
-JNIEXPORT float JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
float *p;
float value;
* Method: putFloat
* Signature: (Ljava/lang/Object;JF)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, float x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, jobject _this, jobject o, jlong offset, jfloat x)
{
float *p;
* Method: getDouble
* Signature: (Ljava/lang/Object;J)D
*/
-JNIEXPORT double JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
double *p;
double value;
* Method: putDouble
* Signature: (Ljava/lang/Object;JD)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, double x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, jobject _this, jobject o, jlong offset, jdouble x)
{
double *p;
* Method: getByte
* Signature: (J)B
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, jobject _this, jlong address)
{
int8_t *p;
int8_t value;
* Method: putByte
* Signature: (JB)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address, int32_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, jobject _this, jlong address, jbyte value)
{
int8_t *p;
* Method: getShort
* Signature: (J)S
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, jobject _this, jlong address)
{
int16_t *p;
int16_t value;
* Method: putShort
* Signature: (JS)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address, int32_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, jobject _this, jlong address, jshort value)
{
int16_t *p;
* Method: getChar
* Signature: (J)C
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, jobject _this, jlong address)
{
uint16_t *p;
uint16_t value;
* Method: putChar
* Signature: (JC)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address, int32_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, jobject _this, jlong address, jchar value)
{
uint16_t *p;
* Method: getInt
* Signature: (J)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, jobject _this, jlong address)
{
int32_t *p;
int32_t value;
* Method: putInt
* Signature: (JI)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, struct sun_misc_Unsafe* _this, int64_t address, int32_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, jobject _this, jlong address, jint value)
{
int32_t *p;
* Method: getLong
* Signature: (J)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, jobject _this, jlong address)
{
int64_t *p;
int64_t value;
* Method: putLong
* Signature: (JJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address, int64_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, jobject _this, jlong address, jlong value)
{
int64_t *p;
* Method: getFloat
* Signature: (J)F
*/
-JNIEXPORT float JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, jobject _this, jlong address)
{
float *p;
float value;
* Method: putFloat
* Signature: (JF)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__JF(JNIEnv *env, struct sun_misc_Unsafe* __this, int64_t address, float value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__JF(JNIEnv *env, jobject _this, jlong address, jfloat value)
{
float* p;
* Method: objectFieldOffset
* Signature: (Ljava/lang/reflect/Field;)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_reflect_Field *field)
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, jobject _this, jobject field)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMField *rvmf;
-#endif
-
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- LLNI_field_get_ref(field, f, rvmf);
- LLNI_field_get_cls(rvmf, clazz, c);
- LLNI_field_get_val(rvmf, slot , slot);
+ java_lang_reflect_Field rf(field);
+ java_lang_reflect_VMField rvmf(rf.get_f());
+ fieldinfo* f = rvmf.get_field();
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- LLNI_field_get_cls(field, clazz, c);
- LLNI_field_get_val(field, slot , slot);
+ java_lang_reflect_Field rf(field);
+ fieldinfo* f = rf.get_field();
#else
# error unknown configuration
#endif
- f = &(c->fields[slot]);
-
- return (int64_t) f->offset;
+ return (jlong) f->offset;
}
* Method: allocateMemory
* Signature: (J)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, sun_misc_Unsafe *_this, int64_t bytes)
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, jobject _this, jlong bytes)
{
size_t length;
void *p;
* Method: setMemory
* Signature: (Ljava/lang/Object;JJB)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int64_t bytes, int32_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong bytes, jbyte value)
{
size_t length;
void *p;
* Method: copyMemory
* Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *srcBase, int64_t srcOffset, java_lang_Object *destBase, int64_t destOffset, int64_t bytes)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jobject srcBase, jlong srcOffset, jobject destBase, jlong destOffset, jlong bytes)
{
size_t length;
void *src;
* Method: setMemory
* Signature: (JJB)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address, int64_t bytes, int32_t value)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jlong address, jlong bytes, jbyte value)
{
size_t length;
void *p;
* Method: copyMemory
* Signature: (JJJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, sun_misc_Unsafe *_this, int64_t srcAddress, int64_t destAddress, int64_t bytes)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jlong srcAddress, jlong destAddress, jlong bytes)
{
size_t length;
void *src;
* Method: freeMemory
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, sun_misc_Unsafe *_this, int64_t address)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, jobject _this, jlong address)
{
void *p;
* Method: staticFieldOffset
* Signature: (Ljava/lang/reflect/Field;)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_reflect_Field *f)
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, jobject _this, jobject f)
{
/* The offset of static fields is 0. */
* Method: staticFieldBase
* Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_reflect_Field *rf)
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, jobject _this, jobject field)
{
- classinfo *c;
- fieldinfo *f;
- int32_t slot;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_reflect_VMField *rvmf;
-#endif
-
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- LLNI_field_get_ref(rf, f, rvmf);
- LLNI_field_get_cls(rvmf, clazz, c);
- LLNI_field_get_val(rvmf, slot , slot);
+ java_lang_reflect_Field rf(field);
+ java_lang_reflect_VMField rvmf(rf.get_f());
+ fieldinfo* f = rvmf.get_field();
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- LLNI_field_get_cls(rf, clazz, c);
- LLNI_field_get_val(rf, slot , slot);
+ java_lang_reflect_Field rf(field);
+ fieldinfo* f = rf.get_field();
#else
# error unknown configuration
#endif
- f = &(c->fields[slot]);
-
- return (java_lang_Object *) (f->value);
+ return (jobject) (f->value);
}
* Method: ensureClassInitialized
* Signature: (Ljava/lang/Class;)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Class *clazz)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, jobject _this, jclass clazz)
{
classinfo *c;
* Method: arrayBaseOffset
* Signature: (Ljava/lang/Class;)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Class *arrayClass)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, jobject _this, jclass arrayClass)
{
classinfo *c;
arraydescriptor *ad;
* Method: arrayIndexScale
* Signature: (Ljava/lang/Class;)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Class *arrayClass)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, jobject _this, jclass arrayClass)
{
classinfo *c;
arraydescriptor *ad;
* Method: addressSize
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, sun_misc_Unsafe *_this)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, jobject _this)
{
return SIZEOF_VOID_P;
}
* Method: pageSize
* Signature: ()I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, sun_misc_Unsafe *_this)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, jobject _this)
{
int sz;
* Method: defineClass
* Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
*/
-JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_String *name, java_handle_bytearray_t *b, int32_t off, int32_t len, java_lang_ClassLoader *loader, java_security_ProtectionDomain *protectionDomain)
+JNIEXPORT jclass JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, jobject _this, jstring name, jbyteArray b, jint off, jint len, jobject loader, jobject protectionDomain)
{
classloader_t *cl;
utf *utfname;
classinfo *c;
- java_lang_Class *o;
cl = loader_hashtable_classloader_add((java_handle_t *) loader);
/* define the class */
- c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct(b, off)),
+ c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct((java_handle_bytearray_t*) b, off)),
(java_handle_t *) protectionDomain);
if (c == NULL)
return NULL;
- /* for convenience */
-
- o = LLNI_classinfo_wrap(c);
+ java_handle_t* h = LLNI_classinfo_wrap(c);
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- /* set ProtectionDomain */
-
- LLNI_field_set_ref(o, pd, protectionDomain);
+ // Set ProtectionDomain.
+ java_lang_Class jlc(h);
+ jlc.set_pd(protectionDomain);
#endif
- return o;
+ return (jclass) h;
}
* Method: allocateInstance
* Signature: (Ljava/lang/Class;)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Class *cls)
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, jobject _this, jclass cls)
{
classinfo *c;
java_handle_t *o;
o = builtin_new(c);
- return (java_lang_Object *) o;
+ return (jobject ) o;
}
* Method: throwException
* Signature: (Ljava/lang/Throwable;)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Throwable *ee)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, jobject _this, jobject ee)
{
java_handle_t *o;
* Method: compareAndSwapObject
* Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, java_lang_Object *expected, java_lang_Object *x)
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject expected, jobject x)
{
volatile void **p;
void *result;
* Method: compareAndSwapInt
* Signature: (Ljava/lang/Object;JII)Z
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* _this, java_lang_Object* o, int64_t offset, int32_t expected, int32_t x)
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint expected, jint x)
{
uint32_t *p;
uint32_t result;
* Method: compareAndSwapLong
* Signature: (Ljava/lang/Object;JJJ)Z
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int64_t expected, int64_t x)
+JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong expected, jlong x)
{
uint64_t *p;
uint64_t result;
* Method: getObjectVolatile
* Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
*/
-JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
volatile void **p;
volatile void *value;
value = *p;
- return (java_lang_Object *) value;
+ return (jobject ) value;
}
* Method: putObjectVolatile
* Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, java_lang_Object *x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
{
volatile void **p;
* Method: getIntVolatile
* Signature: (Ljava/lang/Object;J)I
*/
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
UNSAFE_GET_VOLATILE(int32_t);
}
* Method: putIntVolatile
* Signature: (Ljava/lang/Object;JI)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
{
UNSAFE_PUT_VOLATILE(int32_t);
}
* Method: getLongVolatile
* Signature: (Ljava/lang/Object;J)J
*/
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset)
+JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset)
{
UNSAFE_GET_VOLATILE(int64_t);
}
* Method: putLongVolatile
* Signature: (Ljava/lang/Object;JJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int64_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
{
UNSAFE_PUT_VOLATILE(int64_t);
}
* Method: getDoubleVolatile
* Signature: (Ljava/lang/Object;J)D
*/
-JNIEXPORT double JNICALL Java_sun_misc_Unsafe_getDoubleVolatile(JNIEnv *env, sun_misc_Unsafe* __this, java_lang_Object* o, int64_t offset)
+JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDoubleVolatile(JNIEnv *env, jobject __this, jobject o, jlong offset)
{
UNSAFE_GET_VOLATILE(double);
}
* Method: putOrderedObject
* Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, java_lang_Object *x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x)
{
java_handle_t *_h;
java_handle_t *_hx;
* Method: putOrderedInt
* Signature: (Ljava/lang/Object;JI)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int32_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x)
{
UNSAFE_PUT_VOLATILE(int32_t);
}
* Method: putOrderedLong
* Signature: (Ljava/lang/Object;JJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *o, int64_t offset, int64_t x)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x)
{
UNSAFE_PUT_VOLATILE(int64_t);
}
* Method: unpark
* Signature: (Ljava/lang/Object;)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, sun_misc_Unsafe *_this, java_lang_Object *thread)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, jobject _this, jobject thread)
{
/* XXX IMPLEMENT ME */
}
* Method: park
* Signature: (ZJ)V
*/
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, sun_misc_Unsafe *_this, int32_t isAbsolute, int64_t time)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, jobject _this, jboolean isAbsolute, jlong time)
{
/* XXX IMPLEMENT ME */
}
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_Thread.h"
-
-#if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_ThreadGroup.h"
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_VMThread.h"
-#endif
-
#include "threads/condition.hpp"
#include "threads/lock-common.h"
#include "threads/mutex.hpp"
#include "vm/jit/asmpart.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/options.h"
#if defined(ENABLE_STATISTICS)
static void *threads_startup_thread(void *arg)
{
- startupinfo *startup;
- threadobject *t;
- java_lang_Thread *object;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_VMThread *vmt;
-#endif
- sem_t *psem;
- classinfo *c;
- methodinfo *m;
- java_handle_t *o;
- functionptr function;
+ startupinfo *startup;
+ threadobject *t;
+ sem_t *psem;
+ classinfo *c;
+ methodinfo *m;
+ functionptr function;
#if defined(ENABLE_GC_BOEHM)
# if !defined(__DARWIN__)
# endif
#endif
- /* get the java.lang.Thread object for this thread */
-
- object = (java_lang_Thread *) thread_get_object(t);
+ // Get the java.lang.Thread object for this thread.
+ java_handle_t* object = thread_get_object(t);
+ java_lang_Thread jlt(object);
/* set our priority */
- threads_set_thread_priority(t->tid, LLNI_field_direct(object, priority));
+ threads_set_thread_priority(t->tid, jlt.get_priority());
/* Thread is completely initialized. */
#warning Move to C++
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- /* we need to start the run method of java.lang.VMThread */
- LLNI_field_get_ref(object, vmThread, vmt);
- o = (java_handle_t *) vmt;
+ // We need to start the run method of java.lang.VMThread.
+ java_lang_VMThread jlvmt(jlt.get_vmThread());
+ java_handle_t* h = jlvmt.get_handle();
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
- o = (java_handle_t *) object;
+
+ java_handle_t* h = jlt.get_handle();
+
#else
# error unknown classpath configuration
#endif
/* Run the thread. */
- (void) vm_call_method(m, o);
+ (void) vm_call_method(m, h);
}
else {
/* set ThreadMXBean variables */
*/
bool thread_detach_current_thread(void)
{
- threadobject *t;
- bool result;
- java_lang_Thread *object;
- java_handle_t *o;
-#if defined(ENABLE_JAVASE)
- java_lang_ThreadGroup *group;
- java_handle_t *e;
- void *handler;
- classinfo *c;
- methodinfo *m;
-#endif
-
- t = thread_get_current();
+ threadobject* t = thread_get_current();
/* Sanity check. */
/* If the given thread has already been detached, this operation
is a no-op. */
- result = thread_is_attached(t);
-
- if (result == false)
+ if (thread_is_attached(t) == false)
return true;
DEBUGTHREADS("detaching", t);
- object = (java_lang_Thread *) thread_get_object(t);
+ java_handle_t* object = thread_get_object(t);
+ java_lang_Thread jlt(object);
#if defined(ENABLE_JAVASE)
- LLNI_field_get_ref(object, group, group);
+ java_handle_t* group = jlt.get_group();
/* If there's an uncaught exception, call uncaughtException on the
thread's exception handler, or the thread's group if this is
unset. */
- e = exceptions_get_and_clear_exception();
+ java_handle_t* e = exceptions_get_and_clear_exception();
if (e != NULL) {
/* We use the type void* for handler here, as it's not trivial
header file with cacaoh. */
# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- LLNI_field_get_ref(object, exceptionHandler, handler);
+
+ java_handle_t* handler = jlt.get_exceptionHandler();
+
# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- LLNI_field_get_ref(object, uncaughtExceptionHandler, handler);
+
+ java_handle_t* handler = jlt.get_uncaughtExceptionHandler();
+
# endif
+ classinfo* c;
+ java_handle_t* h;
+
if (handler != NULL) {
LLNI_class_get(handler, c);
- o = (java_handle_t *) handler;
+ h = (java_handle_t *) handler;
}
else {
LLNI_class_get(group, c);
- o = (java_handle_t *) group;
+ h = (java_handle_t *) group;
}
- m = class_resolveclassmethod(c,
- utf_uncaughtException,
- utf_java_lang_Thread_java_lang_Throwable__V,
- NULL,
- true);
+ methodinfo* m = class_resolveclassmethod(c,
+ utf_uncaughtException,
+ utf_java_lang_Thread_java_lang_Throwable__V,
+ NULL,
+ true);
if (m == NULL)
return false;
- (void) vm_call_method(m, o, object, e);
+ (void) vm_call_method(m, h, object, e);
if (exceptions_get_exception())
return false;
/* Remove thread from the thread group. */
if (group != NULL) {
+ classinfo* c;
LLNI_class_get(group, c);
# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- m = class_resolveclassmethod(c,
- utf_removeThread,
- utf_java_lang_Thread__V,
- class_java_lang_ThreadGroup,
- true);
+ methodinfo* m = class_resolveclassmethod(c,
+ utf_removeThread,
+ utf_java_lang_Thread__V,
+ class_java_lang_ThreadGroup,
+ true);
# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- m = class_resolveclassmethod(c,
- utf_remove,
- utf_java_lang_Thread__V,
- class_java_lang_ThreadGroup,
- true);
+ methodinfo* m = class_resolveclassmethod(c,
+ utf_remove,
+ utf_java_lang_Thread__V,
+ class_java_lang_ThreadGroup,
+ true);
# else
# error unknown classpath configuration
# endif
if (m == NULL)
return false;
- o = (java_handle_t *) group;
-
- (void) vm_call_method(m, o, object);
+ (void) vm_call_method(m, group, object);
if (exceptions_get_exception())
return false;
- /* Reset the threadgroup in the Java thread object (Mauve
- test: gnu/testlet/java/lang/Thread/getThreadGroup). */
-
- LLNI_field_set_ref(object, group, NULL);
+ // Clear the ThreadGroup in the Java thread object (Mauve
+ // test: gnu/testlet/java/lang/Thread/getThreadGroup).
+ jlt.set_group(NULL);
}
#endif
/* Notify all threads waiting on this thread. These are joining
this thread. */
- o = (java_handle_t *) object;
-
/* XXX Care about exceptions? */
- (void) lock_monitor_enter(o);
+ (void) lock_monitor_enter(jlt.get_handle());
- lock_notify_all_object(o);
+ lock_notify_all_object(jlt.get_handle());
/* XXX Care about exceptions? */
- (void) lock_monitor_exit(o);
+ (void) lock_monitor_exit(jlt.get_handle());
/* Enter the join-mutex before calling thread_free, so
threads_join_all_threads gets the correct number of non-daemon
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Thread.h"
-
-#if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_ThreadGroup.h"
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/java_lang_VMThread.h"
-#endif
-
#include "threads/lock-common.h"
#include "threads/threadlist.h"
#include "threads/thread.hpp"
#include "vmcore/class.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/method.h"
#include "vmcore/options.h"
static bool thread_create_object(threadobject *t, java_handle_t *name, java_handle_t *group)
{
- java_handle_t *o;
- java_lang_Thread *to;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_VMThread *vmto;
- classinfo *c;
- methodinfo *m;
- bool isdaemon;
-#endif
-
/* Create a java.lang.Thread Java object. */
- o = builtin_new(class_java_lang_Thread);
+ java_handle_t* h = builtin_new(class_java_lang_Thread);
- if (o == NULL)
+ if (h == NULL)
return false;
- to = (java_lang_Thread *) o;
-
- /* Set the Java object in the thread data-structure. This
- indicates that the thread is attached to the VM. */
+ java_lang_Thread jlt(h);
- thread_set_object(t, (java_handle_t *) to);
+ // Set the Java object in the thread data-structure. This
+ // indicates that the thread is attached to the VM.
+ thread_set_object(t, jlt.get_handle());
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- /* Create a java.lang.VMThread Java object. */
+ h = builtin_new(class_java_lang_VMThread);
- vmto = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
-
- if (vmto == NULL)
+ if (h == NULL)
return false;
- /* Set the Java thread object in the Java VM-thread object. */
-
- LLNI_field_set_ref(vmto, thread, to);
-
- /* Set the thread data-structure in the Java VM-thread object. */
-
- LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t);
+ // Create and initialize a java.lang.VMThread object.
+ java_lang_VMThread jlvmt(h, jlt.get_handle(), t);
/* Call:
java.lang.Thread.<init>(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */
- isdaemon = thread_is_daemon(t);
+ bool isdaemon = thread_is_daemon(t);
- (void) vm_call_method(thread_method_init, o, vmto, name, NORM_PRIORITY,
- isdaemon);
+ (void) vm_call_method(thread_method_init, jlt.get_handle(), jlvmt.get_handle(),
+ name, NORM_PRIORITY, isdaemon);
if (exceptions_get_exception())
return false;
- /* Set the threadgroup in the Java thread object. */
-
- LLNI_field_set_ref(to, group, (java_lang_ThreadGroup *) group);
+ // Set the ThreadGroup in the Java thread object.
+ jlt.set_group(group);
/* Add thread to the threadgroup. */
+ classinfo* c;
LLNI_class_get(group, c);
- m = class_resolveclassmethod(c,
- utf_addThread,
- utf_java_lang_Thread__V,
- class_java_lang_ThreadGroup,
- true);
+ methodinfo* m = class_resolveclassmethod(c,
+ utf_addThread,
+ utf_java_lang_Thread__V,
+ class_java_lang_ThreadGroup,
+ true);
if (m == NULL)
return false;
- (void) vm_call_method(m, group, to);
+ (void) vm_call_method(m, group, jlt.get_handle());
if (exceptions_get_exception())
return false;
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- /* OpenJDK's java.lang.Thread does not have a VMThread field in
- the class. Nothing to do here. */
-
/* Set the priority. java.lang.Thread.<init> requires it because
it sets the priority of the current thread to the parent's one
(which is the current thread in this case). */
+ jlt.set_priority(NORM_PRIORITY);
- LLNI_field_set_val(to, priority, NORM_PRIORITY);
-
- /* Call:
- java.lang.Thread.<init>(Ljava/lang/ThreadGroup;Ljava/lang/String;)V */
+ // Call: java.lang.Thread.<init>(Ljava/lang/ThreadGroup;Ljava/lang/String;)V
- (void) vm_call_method(thread_method_init, o, group, name);
+ (void) vm_call_method(thread_method_init, jlt.get_handle(), group, name);
if (exceptions_get_exception())
return false;
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
- /* Set the thread data-structure in the Java thread object. */
-
- LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t);
-
- /* Call: public Thread(Ljava/lang/String;)V */
+ // Set the thread data-structure in the Java thread object.
+ jlt.set_vm_thread(t);
- (void) vm_call_method(thread_method_init, o, name);
+ // Call: public Thread(Ljava/lang/String;)V
+ (void) vm_call_method(thread_method_init, jlt.get_handle(), name);
if (exceptions_get_exception())
return false;
void threads_thread_start(java_handle_t *object)
{
- java_lang_Thread *to;
- threadobject *t;
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_VMThread *vmto;
-#endif
-
- to = (java_lang_Thread *) object;
+ java_lang_Thread jlt(object);
/* Enter the join-mutex, so if the main-thread is currently
waiting to join all threads, the number of non-daemon threads
/* Create internal thread data-structure. */
- t = thread_new();
+ threadobject* t = thread_new();
/* this is a normal Java thread */
#if defined(ENABLE_JAVASE)
/* Is this a daemon thread? */
- if (LLNI_field_direct(to, daemon) == true)
+ if (jlt.get_daemon() == true)
t->flags |= THREAD_FLAG_DAEMON;
#endif
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
/* Get the java.lang.VMThread object and do some sanity checks. */
+ java_lang_VMThread jlvmt(jlt.get_vmThread());
- LLNI_field_get_ref(to, vmThread, vmto);
-
- assert(vmto);
- assert(LLNI_field_direct(vmto, vmdata) == NULL);
+ assert(jlvmt.get_handle() != NULL);
+ assert(jlvmt.get_vmdata() == NULL);
- LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t);
+ jlvmt.set_vmdata(t);
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- /* Nothing to do. */
+ // Nothing to do.
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
- LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t);
+ jlt.set_vm_thread(t);
#else
# error unknown classpath configuration
void thread_fprint_name(threadobject *t, FILE *stream)
{
- java_lang_Thread *to;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_String *name;
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
- java_chararray_t *name;
-#endif
-
- to = (java_lang_Thread *) thread_get_object(t);
-
- if (to == NULL)
+ if (thread_get_object(t) == NULL)
vm_abort("");
- LLNI_field_get_ref(to, name, name);
+ java_lang_Thread jlt(thread_get_object(t));
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- javastring_fprint((java_handle_t *) name, stream);
+ java_handle_t* name = jlt.get_name();
+ javastring_fprint(name, stream);
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
/* FIXME: In OpenJDK and CLDC the name is a char[]. */
+ java_chararray_t *name;
+
/* FIXME This prints to stdout. */
utf_display_printable_ascii(utf_null);
void thread_print_info(threadobject *t)
{
- java_lang_Thread *to;
- int state;
-
- /* If the thread is currently in initalization, don't print it. */
-
- to = (java_lang_Thread *) thread_get_object(t);
+ java_lang_Thread jlt(thread_get_object(t));
/* Print as much as we can when we are in state NEW. */
- if (to != NULL) {
+ if (jlt.get_handle() != NULL) {
/* Print thread name. */
printf("\"");
if (thread_is_daemon(t))
printf(" daemon");
- if (to != NULL) {
- printf(" prio=%d", LLNI_field_direct(to, priority));
+ if (jlt.get_handle() != NULL) {
+ printf(" prio=%d", jlt.get_priority());
}
#if SIZEOF_VOID_P == 8
/* Print thread state. */
- state = cacaothread_get_state(t);
+ int state = cacaothread_get_state(t);
switch (state) {
case THREAD_STATE_NEW:
threadobject *thread_get_thread(java_handle_t *h)
{
- threadobject *t;
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_VMThread *vmto;
- java_lang_Object *to;
-#endif
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
- bool equal;
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
- vmto = (java_lang_VMThread *) h;
-
- LLNI_field_get_val(vmto, vmdata, to);
- t = (threadobject *) to;
+ java_lang_VMThread jlvmt(h);
+ threadobject* t = jlvmt.get_vmdata();
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
/* XXX This is just a quick hack. */
+ threadobject* t;
+ bool equal;
threadlist_lock();
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
log_println("threads_get_thread: IMPLEMENT ME!");
+ threadobject* t = NULL;
#else
# error unknown classpath configuration
-/* src/vm/exceptions.c - exception related functions
+/* src/vm/exceptions.cpp - exception related functions
Copyright (C) 1996-2005, 2006, 2007, 2008
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
#include "native/llni.h"
#include "native/native.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Thread.h"
-#include "native/include/java_lang_Throwable.h"
-
#include "threads/lock-common.h"
#include "threads/thread.hpp"
#include "vmcore/class.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/loader.h"
#include "vmcore/method.h"
#include "vmcore/options.h"
java_handle_t *cause)
{
classinfo *c;
- java_handle_t *o;
methodinfo *m;
- java_lang_Throwable *object;
if (vm->is_initializing())
exceptions_abort(classname, NULL);
- object = (java_lang_Throwable *) cause;
+ java_lang_Throwable jlt(cause);
c = load_class_bootstrap(classname);
/* create object */
- o = builtin_new(c);
-
- if (o == NULL)
+ java_handle_t* h = builtin_new(c);
+
+ if (h == NULL)
return;
/* call initializer */
if (m == NULL)
return;
- (void) vm_call_method(m, o, cause);
+ (void) vm_call_method(m, h, jlt.get_handle());
- exceptions_set_exception(o);
+ exceptions_set_exception(h);
}
static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause)
{
- classinfo *c;
- java_handle_t *o;
- methodinfo *m;
- java_lang_String *s;
- java_lang_Throwable *object;
-
if (vm->is_initializing())
exceptions_abort(classname, NULL);
- object = (java_lang_Throwable *) cause;
+ java_lang_Throwable jltcause(cause);
- c = load_class_bootstrap(classname);
+ classinfo* c = load_class_bootstrap(classname);
if (c == NULL)
return;
/* create object */
- o = builtin_new(c);
+ java_handle_t* h = builtin_new(c);
- if (o == NULL)
+ if (h == NULL)
return;
/* call initializer */
- m = class_resolveclassmethod(c,
- utf_init,
- utf_java_lang_String__void,
- NULL,
- true);
+ methodinfo* m = class_resolveclassmethod(c,
+ utf_init,
+ utf_java_lang_String__void,
+ NULL,
+ true);
if (m == NULL)
return;
- LLNI_field_get_ref(object, detailMessage, s);
-
- (void) vm_call_method(m, o, s);
+ (void) vm_call_method(m, h, jltcause.get_detailMessage());
/* call initCause */
if (m == NULL)
return;
- (void) vm_call_method(m, o, cause);
+ (void) vm_call_method(m, h, jltcause.get_handle());
- exceptions_set_exception(o);
+ exceptions_set_exception(h);
}
void exceptions_print_exception(java_handle_t *xptr)
{
- java_lang_Throwable *t;
-#if defined(ENABLE_JAVASE)
- java_lang_Throwable *cause;
-#endif
- java_lang_String *s;
- classinfo *c;
- utf *u;
-
- t = (java_lang_Throwable *) xptr;
+ java_lang_Throwable jlt(xptr);
- if (t == NULL) {
+ if (jlt.is_null()) {
puts("NULL\n");
return;
}
#if defined(ENABLE_JAVASE)
- LLNI_field_get_ref(t, cause, cause);
+ java_lang_Throwable jltcause(jlt.get_cause());
#endif
/* print the root exception */
- LLNI_class_get(t, c);
+ classinfo* c = jlt.get_Class();
utf_display_printable_ascii_classname(c->name);
- LLNI_field_get_ref(t, detailMessage, s);
+ java_lang_String jls(jlt.get_detailMessage());
- if (s != NULL) {
- u = javastring_toutf((java_handle_t *) s, false);
+ if (!jls.is_null()) {
+ utf* u = javastring_toutf(jls.get_handle(), false);
printf(": ");
utf_display_printable_ascii(u);
#if defined(ENABLE_JAVASE)
/* print the cause if available */
- if ((cause != NULL) && (cause != t)) {
+ // FIXME cause != t compare with operator override.
+ if ((!jltcause.is_null()) && (jltcause.get_handle() != jlt.get_handle())) {
printf("Caused by: ");
-
- LLNI_class_get(cause, c);
+
+ c = jltcause.get_Class();
utf_display_printable_ascii_classname(c->name);
- LLNI_field_get_ref(cause, detailMessage, s);
+ java_lang_String jlscause(jlt.get_detailMessage());
- if (s != NULL) {
- u = javastring_toutf((java_handle_t *) s, false);
+ if (jlscause.get_handle() != NULL) {
+ utf* u = javastring_toutf(jlscause.get_handle(), false);
printf(": ");
utf_display_printable_ascii(u);
#include "native/localref.h"
#include "native/native.h"
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_lang_Object.h"
-# include "native/include/java_lang_String.h" /* required by j.l.CL */
-# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-# include "native/include/java_lang_ClassLoader.h"
-#endif
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
-# include "native/include/java_lang_String.h"
-#endif
-
-#include "native/include/java_lang_Class.h"
-
#include "threads/thread.hpp"
#include "vm/builtin.h"
#include "native/jni.h"
#include "native/llni.h"
-#include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Throwable.h"
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-# include "native/include/gnu_classpath_Pointer.h"
-# include "native/include/java_lang_VMThrowable.h"
-#endif
-
#include "threads/thread.hpp"
#include "toolbox/logging.h"
#include "vmcore/class.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/loader.h"
#include "vmcore/method.h"
#include "vmcore/options.h"
void stacktrace_print_exception(java_handle_t *h)
{
- java_lang_Throwable *o;
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- java_lang_VMThrowable *vmt;
-#endif
-
- java_lang_Object *backtrace;
- java_handle_bytearray_t *ba;
- stacktrace_t *st;
-
- o = (java_lang_Throwable *) h;
-
- if (o == NULL)
+ if (h == NULL)
return;
+ java_lang_Throwable t(h);
+
/* now print the stacktrace */
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
- LLNI_field_get_ref(o, vmState, vmt);
- LLNI_field_get_ref(vmt, vmdata, backtrace);
+ java_lang_VMThrowable vmt(t.get_vmState());
+ java_handle_bytearray_t* backtrace = vmt.get_vmdata();
#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
- LLNI_field_get_ref(o, backtrace, backtrace);
+ java_handle_bytearray_t* backtrace = t.get_backtrace();
#else
# error unknown classpath configuration
#endif
- ba = (java_handle_bytearray_t *) backtrace;
-
- /* Sanity check. */
+ // Sanity check.
- assert(ba != NULL);
+ assert(backtrace != NULL);
/* We need a critical section here as we use the byte-array data
pointer directly. */
LLNI_CRITICAL_START;
- st = (stacktrace_t *) LLNI_array_data(ba);
+ stacktrace_t* st = (stacktrace_t*) LLNI_array_data(backtrace);
stacktrace_print(st);
*/
-// FIXME For now we export everything as C functions.
-extern "C" {
-
#include "config.h"
#include <stdio.h>
#include "native/jni.h"
#include "native/llni.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-
#include "threads/thread.hpp"
#include "toolbox/logging.h"
#include "vm/jit/show.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/options.h"
#include "vmcore/utf8.h"
#if !defined(NDEBUG)
+// FIXME For now we export everything as C functions.
+extern "C" {
/* global variables ***********************************************************/
*******************************************************************************/
-void trace_exception_builtin(java_object_t *xptr)
+void trace_exception_builtin(java_handle_t* h)
{
- java_lang_Throwable *t;
- java_lang_String *s;
char *logtext;
s4 logtextlen;
int32_t dumpmarker;
- t = (java_lang_Throwable *) xptr;
+ java_lang_Throwable jlt(h);
+
+ // Get detail message.
+ java_handle_t* s = NULL;
+
+ if (jlt.get_handle() != NULL)
+ s = jlt.get_detailMessage();
- /* get detail message */
- if (t)
- LLNI_field_get_ref(t, detailMessage, s);
+ java_lang_String jls(s);
/* calculate message length */
logtextlen = strlen("Builtin exception thrown: ") + strlen("0");
- if (t) {
- logtextlen +=
- utf_bytes(xptr->vftbl->clazz->name);
- if (s) {
+ if (jlt.get_handle() != NULL) {
+ logtextlen += utf_bytes(jlt.get_vftbl()->clazz->name);
+
+ if (jls.get_handle()) {
+ // FIXME This is not handle capable!
logtextlen += strlen(": ") +
- u2_utflength(LLNI_field_direct(s, value)->data
- + LLNI_field_direct(s, offset),
- LLNI_field_direct(s,count));
+ u2_utflength(jls.get_value()->data + jls.get_offset(), jls.get_count());
}
}
else {
strcpy(logtext, "Builtin exception thrown: ");
- if (t) {
- utf_cat_classname(logtext, xptr->vftbl->clazz->name);
+ if (jlt.get_handle()) {
+ utf_cat_classname(logtext, jlt.get_vftbl()->clazz->name);
if (s) {
char *buf;
- buf = javastring_tochar((java_handle_t *) s);
+ buf = javastring_tochar(jls.get_handle());
strcat(logtext, ": ");
strcat(logtext, buf);
MFREE(buf, char, strlen(buf) + 1);
DRELEASE;
}
-#endif /* !defined(NDEBUG) */
-
} // extern "C"
+#endif /* !defined(NDEBUG) */
+
/*
* These are local overrides for various environment variables in Emacs.
#ifndef _VM_JIT_TRACE_HPP
#define _VM_JIT_TRACE_HPP
-// FIXME For now we export everything as C functions.
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "config.h"
#include <stdint.h>
#if !defined(NDEBUG)
+// FIXME For now we export everything as C functions.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack);
void trace_java_call_exit(methodinfo *m, uint64_t *return_regs);
void trace_exception(java_object_t *xptr, methodinfo *m, void *pos);
void trace_exception_builtin(java_object_t *xptr);
-#endif /* !defined(NDEBUG) */
-
#ifdef __cplusplus
}
#endif
+#endif /* !defined(NDEBUG) */
+
#endif // _VM_JIT_TRACE_HPP
#include "native/jni.h"
-#include "native/include/java_lang_String.h"
-
#include "vm/package.hpp"
#include "vm/string.hpp"
#include "native/jni.h"
#include "native/llni.h"
-#include "native/include/java_lang_Boolean.h"
-#include "native/include/java_lang_Byte.h"
-#include "native/include/java_lang_Short.h"
-#include "native/include/java_lang_Character.h"
-#include "native/include/java_lang_Integer.h"
-#include "native/include/java_lang_Long.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Double.h"
-
#include "vm/builtin.h"
#include "vm/global.h"
#include "vm/primitive.hpp"
#include "vmcore/class.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/utf8.h"
}
-/* primitive_box_xxx ***********************************************************
-
- Box a primitive type.
-
-*******************************************************************************/
-
-#define PRIMITIVE_BOX_TYPE(name, object, type) \
-java_handle_t* Primitive::box(type value) \
-{ \
- java_handle_t *o; \
- java_lang_##object *jo; \
- \
- o = builtin_new(class_java_lang_##object); \
- \
- if (o == NULL) \
- return NULL; \
- \
- jo = (java_lang_##object *) o; \
- \
- LLNI_field_set_val(jo, value, value); \
- \
- return o; \
+/**
+ * Box a primitive type.
+ */
+java_handle_t* Primitive::box(uint8_t value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Boolean);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Boolean b(h);
+ b.set_value(value);
+
+ return h;
+}
+
+java_handle_t* Primitive::box(int8_t value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Byte);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Byte b(h);
+ b.set_value(value);
+
+ return h;
+}
+
+java_handle_t* Primitive::box(uint16_t value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Character);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Character c(h);
+ c.set_value(value);
+
+ return h;
+}
+
+java_handle_t* Primitive::box(int16_t value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Short);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Short s(h);
+ s.set_value(value);
+
+ return h;
+}
+
+java_handle_t* Primitive::box(int32_t value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Integer);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Integer i(h);
+ i.set_value(value);
+
+ return h;
+}
+
+java_handle_t* Primitive::box(int64_t value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Long);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Long l(h);
+ l.set_value(value);
+
+ return h;
}
-PRIMITIVE_BOX_TYPE(boolean, Boolean, uint8_t)
-PRIMITIVE_BOX_TYPE(byte, Byte, int8_t)
-PRIMITIVE_BOX_TYPE(char, Character, uint16_t)
-PRIMITIVE_BOX_TYPE(short, Short, int16_t)
-PRIMITIVE_BOX_TYPE(int, Integer, int32_t)
-PRIMITIVE_BOX_TYPE(long, Long, int64_t)
-PRIMITIVE_BOX_TYPE(float, Float, float)
-PRIMITIVE_BOX_TYPE(double, Double, double)
-
-
-/* primitive_unbox_xxx *********************************************************
-
- Unbox a primitive type.
-
-*******************************************************************************/
-
-#define PRIMITIVE_UNBOX_TYPE(name, object, type) \
-type Primitive::unbox_##name(java_handle_t *h) \
-{ \
- java_lang_##object *jo; \
- type value; \
- \
- jo = (java_lang_##object *) h; \
- \
- LLNI_field_get_val(jo, value, value); \
- \
- return value; \
+java_handle_t* Primitive::box(float value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Float);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Float f(h);
+ f.set_value(value);
+
+ return h;
+}
+
+java_handle_t* Primitive::box(double value)
+{
+ java_handle_t *h = builtin_new(class_java_lang_Double);
+
+ if (h == NULL)
+ return NULL;
+
+ java_lang_Double d(h);
+ d.set_value(value);
+
+ return h;
+}
+
+
+
+/**
+ * Unbox a primitive type.
+ */
+
+// template<class T> T Primitive::unbox(java_handle_t *h)
+// {
+// return java_lang_Boolean::get_value(h);
+// }
+
+inline uint8_t Primitive::unbox_boolean(java_handle_t *h)
+{
+ java_lang_Boolean b(h);
+ return b.get_value();
+}
+
+inline int8_t Primitive::unbox_byte(java_handle_t *h)
+{
+ java_lang_Byte b(h);
+ return b.get_value();
+}
+
+inline uint16_t Primitive::unbox_char(java_handle_t *h)
+{
+ java_lang_Character c(h);
+ return c.get_value();
+}
+
+inline int16_t Primitive::unbox_short(java_handle_t *h)
+{
+ java_lang_Short s(h);
+ return s.get_value();
+}
+
+inline int32_t Primitive::unbox_int(java_handle_t *h)
+{
+ java_lang_Integer i(h);
+ return i.get_value();
+}
+
+inline int64_t Primitive::unbox_long(java_handle_t *h)
+{
+ java_lang_Long l(h);
+ return l.get_value();
+}
+
+inline float Primitive::unbox_float(java_handle_t *h)
+{
+ java_lang_Float f(h);
+ return f.get_value();
+}
+
+inline double Primitive::unbox_double(java_handle_t *h)
+{
+ java_lang_Double d(h);
+ return d.get_value();
}
-PRIMITIVE_UNBOX_TYPE(boolean, Boolean, uint8_t)
-PRIMITIVE_UNBOX_TYPE(byte, Byte, int8_t)
-PRIMITIVE_UNBOX_TYPE(char, Character, uint16_t)
-PRIMITIVE_UNBOX_TYPE(short, Short, int16_t)
-PRIMITIVE_UNBOX_TYPE(int, Integer, int32_t)
-PRIMITIVE_UNBOX_TYPE(long, Long, int64_t)
-PRIMITIVE_UNBOX_TYPE(float, Float, float)
-PRIMITIVE_UNBOX_TYPE(double, Double, double)
// Legacy C interface.
#include "config.h"
+#include <stdint.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/utsname.h>
-#include "vm/types.h"
-
#include "mm/memory.h"
#include "native/jni.h"
#include "native/llni.h"
-#include "vm/global.h" /* required by java_lang_String.h */
-#include "native/include/java_lang_String.h"
-
#include "toolbox/list.h"
#include "toolbox/util.h"
+#include "vm/global.h"
#include "vm/properties.h"
#include "vm/string.hpp"
#include "vm/vm.hpp"
#include "native/jni.h"
#include "native/llni.h"
-#include "native/include/java_lang_String.h"
-
#include "threads/lock-common.h"
#include "vm/array.h"
#include "vm/vm.hpp"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/options.h"
#include "vmcore/statistics.h"
#include "vmcore/utf8.h"
#endif
-/* XXX preliminary typedef, will be removed once string.c and utf8.c are
- unified. */
-
-#if defined(ENABLE_HANDLES)
-typedef heap_java_lang_String heapstring_t;
-#else
-typedef java_lang_String heapstring_t;
-#endif
-
-
/* string_init *****************************************************************
Initialize the string hashtable lock.
void stringtable_update(void)
{
- heapstring_t *js;
java_chararray_t *a;
literalstring *s; /* hashtable entry */
if (s) {
while (s) {
- js = (heapstring_t *) s->string;
+ // FIXME
+ java_lang_String js(LLNI_WRAP(s->string));
- if ((js == NULL) || (js->value == NULL)) {
+ if (js.is_null() || (js.get_value() == NULL)) {
/* error in hashtable found */
vm_abort("stringtable_update: invalid literalstring in hashtable");
}
- a = js->value;
+ a = LLNI_UNWRAP(js.get_value());
- if (!js->header.vftbl)
- /* vftbl of javastring is NULL */
- js->header.vftbl = class_java_lang_String->vftbl;
+ if (js.get_vftbl() == NULL)
+ // FIXME
+ LLNI_UNWRAP(js.get_handle())->vftbl = class_java_lang_String->vftbl;
- if (!a->header.objheader.vftbl)
- /* vftbl of character-array is NULL */
+ if (a->header.objheader.vftbl == NULL)
a->header.objheader.vftbl = Primitive::get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl;
/* follow link in external hash chain */
*******************************************************************************/
-static java_handle_t *javastring_new_from_utf_buffer(const char *buffer,
- u4 blength)
+static java_handle_t *javastring_new_from_utf_buffer(const char *buffer, u4 blength)
{
const char *utf_ptr; /* current utf character in utf string */
- u4 utflength; /* length of utf-string if uncompressed */
- java_handle_t *o;
- java_lang_String *s; /* result-string */
- java_handle_chararray_t *a;
- u4 i;
assert(buffer);
- utflength = utf_get_number_of_u2s_for_buffer(buffer,blength);
+ int32_t utflength = utf_get_number_of_u2s_for_buffer(buffer, blength);
- o = builtin_new(class_java_lang_String);
- a = builtin_newarray_char(utflength);
+ java_handle_t* h = builtin_new(class_java_lang_String);
+ java_handle_chararray_t* ca = builtin_newarray_char(utflength);
/* javastring or character-array could not be created */
- if ((o == NULL) || (a == NULL))
+ if ((h == NULL) || (ca == NULL))
return NULL;
/* decompress utf-string */
utf_ptr = buffer;
- for (i = 0; i < utflength; i++)
- LLNI_array_direct(a, i) = utf_nextu2((char **) &utf_ptr);
+ for (int32_t i = 0; i < utflength; i++)
+ LLNI_array_direct(ca, i) = utf_nextu2((char **) &utf_ptr);
/* set fields of the javastring-object */
- s = (java_lang_String *) o;
-
- LLNI_field_set_ref(s, value , a);
- LLNI_field_set_val(s, offset, 0);
- LLNI_field_set_val(s, count , utflength);
+ java_lang_String jls(h, ca, utflength);
- return o;
+ return jls.get_handle();
}
java_handle_t *javastring_safe_new_from_utf8(const char *text)
{
- java_handle_t *o;
- java_handle_chararray_t *a;
- java_lang_String *s;
- s4 nbytes;
- s4 len;
-
if (text == NULL)
return NULL;
/* Get number of bytes. We need this to completely emulate the messy */
/* behaviour of the RI. :( */
- nbytes = strlen(text);
+ int32_t nbytes = strlen(text);
/* calculate number of Java characters */
- len = utf8_safe_number_of_u2s(text, nbytes);
+ int32_t len = utf8_safe_number_of_u2s(text, nbytes);
/* allocate the String object and the char array */
- o = builtin_new(class_java_lang_String);
- a = builtin_newarray_char(len);
+ java_handle_t* h = builtin_new(class_java_lang_String);
+ java_handle_chararray_t* ca = builtin_newarray_char(len);
/* javastring or character-array could not be created? */
- if ((o == NULL) || (a == NULL))
+ if ((h == NULL) || (ca == NULL))
return NULL;
/* decompress UTF-8 string */
- utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(a));
+ utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(ca));
/* set fields of the String object */
- s = (java_lang_String *) o;
-
- LLNI_field_set_ref(s, value , a);
- LLNI_field_set_val(s, offset, 0);
- LLNI_field_set_val(s, count , len);
+ java_lang_String jls(h, ca, len);
- return o;
+ return jls.get_handle();
}
java_handle_t *javastring_new(utf *u)
{
- char *utf_ptr; /* current utf character in utf string */
- int32_t utflength; /* length of utf-string if uncompressed */
- java_handle_t *o;
- java_handle_chararray_t *a;
- java_lang_String *s;
-
if (u == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- utf_ptr = u->text;
- utflength = utf_get_number_of_u2s(u);
+ char* utf_ptr = u->text;
+ int32_t utflength = utf_get_number_of_u2s(u);
- o = builtin_new(class_java_lang_String);
- a = builtin_newarray_char(utflength);
+ java_handle_t* h = builtin_new(class_java_lang_String);
+ java_handle_chararray_t* ca = builtin_newarray_char(utflength);
/* javastring or character-array could not be created */
- if ((o == NULL) || (a == NULL))
+ if ((h == NULL) || (ca == NULL))
return NULL;
/* decompress utf-string */
for (int32_t i = 0; i < utflength; i++)
- LLNI_array_direct(a, i) = utf_nextu2(&utf_ptr);
+ LLNI_array_direct(ca, i) = utf_nextu2(&utf_ptr);
/* set fields of the javastring-object */
- s = (java_lang_String *) o;
-
- LLNI_field_set_ref(s, value , a);
- LLNI_field_set_val(s, offset, 0);
- LLNI_field_set_val(s, count , utflength);
+ java_lang_String jls(h, ca, utflength);
- return o;
+ return jls.get_handle();
}
java_handle_t *javastring_new_slash_to_dot(utf *u)
{
- char *utf_ptr; /* current utf character in utf string */
- int32_t utflength; /* length of utf-string if uncompressed */
- java_handle_t *o;
- java_handle_chararray_t *a;
- java_lang_String *s;
- u2 ch;
-
if (u == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- utf_ptr = u->text;
- utflength = utf_get_number_of_u2s(u);
+ char* utf_ptr = u->text;
+ int32_t utflength = utf_get_number_of_u2s(u);
- o = builtin_new(class_java_lang_String);
- a = builtin_newarray_char(utflength);
+ java_handle_t* h = builtin_new(class_java_lang_String);
+ java_handle_chararray_t* ca = builtin_newarray_char(utflength);
/* javastring or character-array could not be created */
- if ((o == NULL) || (a == NULL))
+ if ((h == NULL) || (ca == NULL))
return NULL;
/* decompress utf-string */
for (int32_t i = 0; i < utflength; i++) {
- ch = utf_nextu2(&utf_ptr);
+ uint16_t ch = utf_nextu2(&utf_ptr);
+
if (ch == '/')
ch = '.';
- LLNI_array_direct(a, i) = ch;
+
+ LLNI_array_direct(ca, i) = ch;
}
/* set fields of the javastring-object */
- s = (java_lang_String *) o;
+ java_lang_String jls(h, ca, utflength);
- LLNI_field_set_ref(s, value , a);
- LLNI_field_set_val(s, offset, 0);
- LLNI_field_set_val(s, count , utflength);
-
- return o;
+ return jls.get_handle();
}
java_handle_t *javastring_new_from_ascii(const char *text)
{
- s4 i;
- s4 len; /* length of the string */
- java_handle_t *o;
- java_lang_String *s;
- java_handle_chararray_t *a;
-
if (text == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- len = strlen(text);
+ int32_t len = strlen(text);
- o = builtin_new(class_java_lang_String);
- a = builtin_newarray_char(len);
+ java_handle_t* h = builtin_new(class_java_lang_String);
+ java_handle_chararray_t* ca = builtin_newarray_char(len);
/* javastring or character-array could not be created */
- if ((o == NULL) || (a == NULL))
+ if ((h == NULL) || (ca == NULL))
return NULL;
/* copy text */
- for (i = 0; i < len; i++)
- LLNI_array_direct(a, i) = text[i];
+ for (int32_t i = 0; i < len; i++)
+ LLNI_array_direct(ca, i) = text[i];
/* set fields of the javastring-object */
- s = (java_lang_String *) o;
-
- LLNI_field_set_ref(s, value , a);
- LLNI_field_set_val(s, offset, 0);
- LLNI_field_set_val(s, count , len);
+ java_lang_String jls(h, ca, len);
- return o;
+ return jls.get_handle();
}
*******************************************************************************/
-char *javastring_tochar(java_handle_t *so)
+char* javastring_tochar(java_handle_t* h)
{
- java_lang_String *s = (java_lang_String *) so;
- java_handle_chararray_t *a;
- int32_t count;
- int32_t offset;
- char *buf;
- s4 i;
-
- if (!s)
+ java_lang_String jls(h);
+
+ if (jls.is_null())
return (char*) "";
- LLNI_field_get_ref(s, value, a);
+ java_handle_chararray_t* ca = jls.get_value();
- if (!a)
+ if (ca == NULL)
return (char*) "";
- LLNI_field_get_val(s, count, count);
- LLNI_field_get_val(s, offset, offset);
+ int32_t count = jls.get_count();
+ int32_t offset = jls.get_offset();
- buf = MNEW(char, count + 1);
+ char* buf = MNEW(char, count + 1);
+ int32_t i;
for (i = 0; i < count; i++)
- buf[i] = LLNI_array_direct(a, offset + i);
+ buf[i] = LLNI_array_direct(ca, offset + i);
buf[i] = '\0';
utf *javastring_toutf(java_handle_t *string, bool isclassname)
{
- java_lang_String *s;
- java_handle_chararray_t *value;
- int32_t count;
- int32_t offset;
+ java_lang_String jls(string);
- s = (java_lang_String *) string;
-
- if (s == NULL)
+ if (jls.is_null())
return utf_null;
- LLNI_field_get_ref(s, value, value);
+ java_handle_chararray_t* value = jls.get_value();
- if (value == NULL)
+ if (jls.get_value() == NULL)
return utf_null;
- LLNI_field_get_val(s, count, count);
- LLNI_field_get_val(s, offset, offset);
+ int32_t count = jls.get_count();
+ int32_t offset = jls.get_offset();
return utf_new_u2(LLNI_array_data(value) + offset, count, isclassname);
}
u4 offset, bool copymode)
{
literalstring *s; /* hashtable element */
- heapstring_t *js; /* u2-array wrapped in javastring */
java_chararray_t *ca; /* copy of u2-array */
u4 key;
u4 slot;
s = (literalstring*) hashtable_string.ptr[slot];
while (s) {
- js = (heapstring_t *) s->string;
+ // FIXME
+ java_lang_String js(LLNI_WRAP(s->string));
- if (length == js->count) {
+ if (length == js.get_count()) {
/* compare text */
for (i = 0; i < length; i++)
- if (a->data[offset + i] != js->value->data[i])
+ // FIXME This is not handle capable!
+
+ if (a->data[offset + i] != ((java_chararray_t*) LLNI_UNWRAP(js.get_value()))->data[i])
goto nomatch;
/* string already in hashtable, free memory */
LOCK_MONITOR_EXIT(lock_hashtable_string);
- return (java_object_t *) js;
+ return (java_object_t*) LLNI_UNWRAP(js.get_handle());
}
nomatch:
/* memcpy(ca, a, arraysize); */
memcpy(&(ca->header), &(a->header), sizeof(java_array_t));
memcpy(&(ca->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10);
-
- } else {
+ }
+ else {
ca = a;
}
assert(class_java_lang_String);
assert(class_java_lang_String->state & CLASS_LOADED);
- /* create new javastring */
-
- js = NEW(heapstring_t);
+ // Create a new java.lang.String object on the system heap.
+ java_object_t* o = (java_object_t*) MNEW(uint8_t, class_java_lang_String->instancesize);
+ // FIXME
+ java_handle_t* h = LLNI_WRAP(o);
#if defined(ENABLE_STATISTICS)
if (opt_stat)
- size_string += sizeof(heapstring_t);
+ size_string += sizeof(class_java_lang_String->instancesize);
#endif
#if defined(ENABLE_THREADS)
- lock_init_object_lock(&js->header);
+ lock_init_object_lock(o);
#endif
- js->header.vftbl = class_java_lang_String->vftbl;
- js->value = ca;
- js->offset = 0;
- js->count = length;
+ o->vftbl = class_java_lang_String->vftbl;
+
+ // FIXME
+ java_lang_String jls(h, LLNI_WRAP(ca), length);
/* create new literalstring */
#endif
s->hashlink = (literalstring*) hashtable_string.ptr[slot];
- s->string = (java_object_t *) js;
+ s->string = (java_object_t*) LLNI_UNWRAP(jls.get_handle());
hashtable_string.ptr[slot] = s;
/* update number of hashtable entries */
u4 i;
literalstring *s;
literalstring *nexts;
- heapstring_t *tmpjs;
hashtable newhash; /* the new hashtable */
/* create new hashtable, double the size */
while (s) {
nexts = s->hashlink;
- tmpjs = (heapstring_t *) s->string;
- slot = unicode_hashkey(tmpjs->value->data, tmpjs->count) & (newhash.size - 1);
+ java_lang_String tmpjls(LLNI_WRAP(s->string));
+ // FIXME This is not handle capable!
+ slot = unicode_hashkey(((java_chararray_t*) LLNI_UNWRAP(tmpjls.get_value()))->data, tmpjls.get_count()) & (newhash.size - 1);
s->hashlink = (literalstring*) newhash.ptr[slot];
newhash.ptr[slot] = s;
LOCK_MONITOR_EXIT(lock_hashtable_string);
- return (java_object_t *) js;
+ return (java_object_t*) LLNI_UNWRAP(jls.get_handle());
}
*******************************************************************************/
-java_handle_t *javastring_intern(java_handle_t *s)
+java_handle_t *javastring_intern(java_handle_t *string)
{
- java_lang_String *so;
- java_chararray_t *value;
- int32_t count;
- int32_t offset;
-/* java_lang_String *o; */
- java_object_t *o; /* XXX see note above */
+ java_lang_String jls(string);
- so = (java_lang_String *) s;
+ java_handle_chararray_t* value = jls.get_value();
+ // FIXME
+ java_chararray_t* ca = LLNI_UNWRAP(value); /* XXX see note above */
- value = LLNI_field_direct(so, value); /* XXX see note above */
- LLNI_field_get_val(so, count, count);
- LLNI_field_get_val(so, offset, offset);
+ int32_t count = jls.get_count();
+ int32_t offset = jls.get_offset();
- o = literalstring_u2(value, count, offset, true);
+ java_object_t* o = literalstring_u2(ca, count, offset, true); /* XXX see note above */
return LLNI_WRAP(o); /* XXX see note above */
}
void javastring_fprint(java_handle_t *s, FILE *stream)
{
- java_lang_String *so;
- java_handle_chararray_t *value;
- int32_t count;
- int32_t offset;
- uint16_t c;
- int i;
+ java_lang_String jls(s);
- so = (java_lang_String *) s;
+ java_handle_chararray_t* value = jls.get_value();
- LLNI_field_get_ref(so, value, value);
- LLNI_field_get_val(so, count, count);
- LLNI_field_get_val(so, offset, offset);
+ int32_t count = jls.get_count();
+ int32_t offset = jls.get_offset();
- for (i = offset; i < offset + count; i++) {
- c = LLNI_array_direct(value, i);
+ for (int32_t i = offset; i < offset + count; i++) {
+ uint16_t c = LLNI_array_direct(value, i);
fputc(c, stream);
}
}
#include "native/localref.h"
#include "native/native.h"
-#include "native/include/java_lang_Object.h" /* required by j.l.C */
-#include "native/include/java_lang_String.h" /* required by j.l.C */
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
-# include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */
-#endif
-
-#include "native/include/java_lang_Class.h"
-
#include "native/vm/nativevm.h"
#include "threads/lock-common.h"
is smaller or equal than the assumption made in
src/vmcore/class.h. */
- if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class))
- vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class));
+#warning FIXME We need to check the size of java.lang.Class!!!
+// if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class))
+// vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class));
/* set the VM starttime */
## src/vmcore/Makefile.am
##
-## 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
+## Copyright (C) 2007, 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
##
## This file is part of CACAO.
##
field.h \
globals.cpp \
globals.hpp \
+ javaobjects.hpp \
+ javaobjects.cpp \
linker.c \
linker.h \
loader.c \
#include "vmcore/class.h"
#include "vmcore/classcache.h"
#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
#include "vmcore/linker.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
#include "vmcore/utf8.h"
-#if defined(ENABLE_JAVASE)
-/* We need to define some reflection functions here since we cannot
- include native/vm/reflect.h as it includes generated header
- files. */
-
-java_object_t *reflect_constructor_new(methodinfo *m);
-java_object_t *reflect_field_new(fieldinfo *f);
-java_object_t *reflect_method_new(methodinfo *m);
-#endif
-
-
/* class_set_packagename *******************************************************
Derive the package name from the class name and store it in the
if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) &&
(m->name == utf_init)) {
- /* Create Constructor object. This is actualy a
- java_lang_reflect_Constructor pointer, but we use a
- java_handle_t here, because we don't have the header
- available when building vmcore. */
+ // Create a java.lang.reflect.Constructor object.
- rc = reflect_constructor_new(m);
+ rc = java_lang_reflect_Constructor_create(m);
/* Store object into array. */
f = &(c->fields[i]);
if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) {
- /* Create Field object. This is actualy a
- java_lang_reflect_Field pointer, but we use a
- java_handle_t here, because we don't have the header
- available when building vmcore. */
+ // Create a java.lang.reflect.Field object.
- h = reflect_field_new(f);
+ h = java_lang_reflect_Field_create(f);
/* Store object into array. */
if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) &&
((m->name != utf_init) && (m->name != utf_clinit)) &&
!(m->flags & ACC_MIRANDA)) {
- /* Create method object. This is actualy a
- java_lang_reflect_Method pointer, but we use a
- java_handle_t here, because we don't have the header
- available when building vmcore. */
+ // Create java.lang.reflect.Method object.
- h = reflect_method_new(m);
+ h = java_lang_reflect_Method_create(m);
/* Store object into array. */
if (m->name != utf_init)
return NULL;
- /* Create Constructor object. */
+ // Create a java.lang.reflect.Constructor object.
- rc = reflect_constructor_new(m);
+ rc = java_lang_reflect_Constructor_create(m);
return rc;
}
if (m->name == utf_init)
return NULL;
- /* create java.lang.reflect.Method object */
+ // Create a java.lang.reflect.Method object.
- rm = reflect_method_new(m);
+ rm = java_lang_reflect_Method_create(m);
return rm;
}
--- /dev/null
+/* src/vmcore/javaobjects.cpp - functions to create and access Java objects
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ 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>
+
+// REMOVEME
+#include "native/vm/reflection.hpp"
+
+#include "vm/access.h"
+#include "vm/builtin.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
+
+#include "vmcore/globals.hpp"
+#include "vmcore/javaobjects.hpp"
+
+
+#if defined(ENABLE_JAVASE)
+
+/**
+ * Constructs a Java object with the given
+ * java.lang.reflect.Constructor.
+ *
+ * @param args Constructor arguments.
+ *
+ * @return Handle to Java object.
+ */
+java_handle_t* java_lang_reflect_Constructor::new_instance(java_handle_objectarray_t* args)
+{
+ methodinfo* m = get_method();
+
+ // Should we bypass security the checks (AccessibleObject)?
+ if (get_override() == false) {
+ /* This method is always called like this:
+ [0] java.lang.reflect.Constructor.constructNative (Native Method)
+ [1] java.lang.reflect.Constructor.newInstance
+ [2] <caller>
+ */
+
+ if (!access_check_method(m, 2))
+ return NULL;
+ }
+
+ // Create a Java object.
+ java_handle_t* h = builtin_new(m->clazz);
+
+ if (h == NULL)
+ return NULL;
+
+ // Call initializer.
+ (void) Reflection::invoke(m, h, args);
+
+ return h;
+}
+
+
+/**
+ * Invokes the given method.
+ *
+ * @param args Method arguments.
+ *
+ * @return return value of the method
+ */
+java_handle_t* java_lang_reflect_Method::invoke(java_handle_t* o, java_handle_objectarray_t* args)
+{
+ methodinfo* m = get_method();
+
+ // Should we bypass security the checks (AccessibleObject)?
+ if (get_override() == false) {
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+ /* This method is always called like this:
+ [0] java.lang.reflect.Method.invokeNative (Native Method)
+ [1] java.lang.reflect.Method.invoke (Method.java:329)
+ [2] <caller>
+ */
+
+ if (!access_check_method(m, 2))
+ return NULL;
+#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+ /* We only pass 1 here as stacktrace_get_caller_class, which
+ is called from access_check_method, skips
+ java.lang.reflect.Method.invoke(). */
+
+ if (!access_check_method(m, 1))
+ return NULL;
+#else
+# error unknown classpath configuration
+#endif
+ }
+
+ // Check if method class is initialized.
+ if (!(m->clazz->state & CLASS_INITIALIZED))
+ if (!initialize_class(m->clazz))
+ return NULL;
+
+ // Call the Java method.
+ java_handle_t* result = Reflection::invoke(m, o, args);
+
+ return result;
+}
+
+
+// Legacy C interface.
+
+extern "C" {
+ java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m) { return java_lang_reflect_Constructor(m).get_handle(); }
+ java_handle_t* java_lang_reflect_Field_create(fieldinfo* f) { return java_lang_reflect_Field(f).get_handle(); }
+ java_handle_t* java_lang_reflect_Method_create(methodinfo* m) { return java_lang_reflect_Method(m).get_handle(); }
+}
+
+#endif // ENABLE_JAVASE
+
+
+/*
+ * 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:
+ */
--- /dev/null
+/* src/vmcore/javaobjects.hpp - functions to create and access Java objects
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ 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 _JAVAOBJECTS_HPP
+#define _JAVAOBJECTS_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
+#include "vm/global.h"
+
+#include "vmcore/class.h"
+#include "vmcore/field.h"
+#include "vmcore/globals.hpp"
+#include "vmcore/method.h"
+
+
+#ifdef __cplusplus
+
+/**
+ * This class provides low-level functions to access Java object
+ * instance fields.
+ *
+ * These functions do NOT take care about the GC critical section!
+ * Please use FieldAccess wherever possible.
+ */
+class RawFieldAccess {
+protected:
+ template<class T> static inline T raw_get(void* address, const off_t offset);
+ template<class T> static inline void raw_set(void* address, const off_t offset, T value);
+};
+
+
+template<class T> inline T RawFieldAccess::raw_get(void* address, const off_t offset)
+{
+ T* p = (T*) (((uintptr_t) address) + offset);
+ return *p;
+}
+
+
+template<class T> inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value)
+{
+ T* p = (T*) (((uintptr_t) address) + offset);
+ *p = value;
+}
+
+
+/**
+ * This classes provides functions to access Java object instance
+ * fields. These functions enter a critical GC section before
+ * accessing the Java object throught the handle and leave it
+ * afterwards.
+ */
+class FieldAccess : private RawFieldAccess {
+protected:
+ template<class T> static inline T get(java_handle_t* h, const off_t offset);
+ template<class T> static inline void set(java_handle_t* h, const off_t offset, T value);
+};
+
+template<class T> inline T FieldAccess::get(java_handle_t* h, const off_t offset)
+{
+ java_object_t* o;
+ T result;
+
+ // XXX Move this to a GC inline function, e.g.
+ // gc->enter_critical();
+ LLNI_CRITICAL_START;
+
+ // XXX This should be _handle->get_object();
+ o = LLNI_UNWRAP(h);
+
+ result = raw_get<T>(o, offset);
+
+ // XXX Move this to a GC inline function.
+ // gc->leave_critical();
+ LLNI_CRITICAL_END;
+
+ return result;
+}
+
+template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset)
+{
+ java_object_t* o;
+ java_object_t* result;
+ java_handle_t* hresult;
+
+ // XXX Move this to a GC inline function, e.g.
+ // gc->enter_critical();
+ LLNI_CRITICAL_START;
+
+ // XXX This should be _handle->get_object();
+ o = LLNI_UNWRAP(h);
+
+ result = raw_get<java_object_t*>(o, offset);
+
+ hresult = LLNI_WRAP(result);
+
+ // XXX Move this to a GC inline function.
+ // gc->leave_critical();
+ LLNI_CRITICAL_END;
+
+ return result;
+}
+
+
+template<class T> inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value)
+{
+ java_object_t* o;
+
+ // XXX Move this to a GC inline function, e.g.
+ // gc->enter_critical();
+ LLNI_CRITICAL_START;
+
+ // XXX This should be h->get_object();
+ o = LLNI_UNWRAP(h);
+
+ raw_set(o, offset, value);
+
+ // XXX Move this to a GC inline function.
+ // gc->leave_critical();
+ LLNI_CRITICAL_END;
+}
+
+template<> inline void FieldAccess::set<java_handle_t*>(java_handle_t* h, const off_t offset, java_handle_t* value)
+{
+ java_object_t* o;
+ java_object_t* ovalue;
+
+ // XXX Move this to a GC inline function, e.g.
+ // gc->enter_critical();
+ LLNI_CRITICAL_START;
+
+ // XXX This should be h->get_object();
+ o = LLNI_UNWRAP(h);
+ ovalue = LLNI_UNWRAP(value);
+
+ raw_set(o, offset, ovalue);
+
+ // XXX Move this to a GC inline function.
+ // gc->leave_critical();
+ LLNI_CRITICAL_END;
+}
+
+
+/**
+ * java/lang/Object
+ *
+ * Object layout:
+ *
+ * 0. object header
+ */
+class java_lang_Object {
+protected:
+ // Handle of Java object.
+ java_handle_t* _handle;
+
+protected:
+ java_lang_Object() : _handle(NULL) {}
+ java_lang_Object(java_handle_t* h) : _handle(h) {}
+ java_lang_Object(jobject h) : _handle((java_handle_t*) h) {}
+
+public:
+ // Getters.
+ virtual inline java_handle_t* get_handle() const { return _handle; }
+ inline vftbl_t* get_vftbl () const;
+ inline classinfo* get_Class () const;
+
+ inline bool is_null () const;
+ inline bool is_non_null() const;
+};
+
+
+inline vftbl_t* java_lang_Object::get_vftbl() const
+{
+ // XXX Move this to a GC inline function, e.g.
+ // gc->enter_critical();
+ LLNI_CRITICAL_START;
+
+ // XXX This should be h->get_object();
+ java_object_t* o = LLNI_UNWRAP(_handle);
+ vftbl_t* vftbl = o->vftbl;
+
+ // XXX Move this to a GC inline function.
+ // gc->leave_critical();
+ LLNI_CRITICAL_END;
+
+ return vftbl;
+}
+
+inline classinfo* java_lang_Object::get_Class() const
+{
+ return get_vftbl()->clazz;
+}
+
+
+inline bool java_lang_Object::is_null() const
+{
+ return (_handle == NULL);
+}
+
+inline bool java_lang_Object::is_non_null() const
+{
+ return (_handle != NULL);
+}
+
+
+/**
+ * java/lang/Boolean
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean value;
+ */
+class java_lang_Boolean : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+ java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline uint8_t get_value();
+ inline void set_value(uint8_t value);
+};
+
+inline uint8_t java_lang_Boolean::get_value()
+{
+ return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Boolean::set_value(uint8_t value)
+{
+ set(_handle, offset_value, (uint32_t) value);
+}
+
+
+/**
+ * java/lang/Byte
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. byte value;
+ */
+class java_lang_Byte : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+ java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline int8_t get_value();
+ inline void set_value(int8_t value);
+};
+
+inline int8_t java_lang_Byte::get_value()
+{
+ return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Byte::set_value(int8_t value)
+{
+ set(_handle, offset_value, (int32_t) value);
+}
+
+
+/**
+ * java/lang/Character
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char value;
+ */
+class java_lang_Character : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+ java_lang_Character(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline uint16_t get_value();
+ inline void set_value(uint16_t value);
+};
+
+inline uint16_t java_lang_Character::get_value()
+{
+ return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Character::set_value(uint16_t value)
+{
+ set(_handle, offset_value, (uint32_t) value);
+}
+
+
+/**
+ * java/lang/Short
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. short value;
+ */
+class java_lang_Short : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+ java_lang_Short(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline int16_t get_value();
+ inline void set_value(int16_t value);
+};
+
+inline int16_t java_lang_Short::get_value()
+{
+ return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Short::set_value(int16_t value)
+{
+ set(_handle, offset_value, (int32_t) value);
+}
+
+
+/**
+ * java/lang/Integer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int value;
+ */
+class java_lang_Integer : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+
+public:
+ java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline int32_t get_value();
+ inline void set_value(int32_t value);
+};
+
+inline int32_t java_lang_Integer::get_value()
+{
+ return get<int32_t>(_handle, offset_value);
+}
+
+inline void java_lang_Integer::set_value(int32_t value)
+{
+ set(_handle, offset_value, value);
+}
+
+
+/**
+ * java/lang/Long
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. long value;
+ */
+class java_lang_Long : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
+
+public:
+ java_lang_Long(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline int64_t get_value();
+ inline void set_value(int64_t value);
+};
+
+inline int64_t java_lang_Long::get_value()
+{
+ return get<int64_t>(_handle, offset_value);
+}
+
+inline void java_lang_Long::set_value(int64_t value)
+{
+ set(_handle, offset_value, value);
+}
+
+
+/**
+ * java/lang/Float
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. float value;
+ */
+class java_lang_Float : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float));
+
+public:
+ java_lang_Float(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline float get_value();
+ inline void set_value(float value);
+};
+
+inline float java_lang_Float::get_value()
+{
+ return get<float>(_handle, offset_value);
+}
+
+inline void java_lang_Float::set_value(float value)
+{
+ set(_handle, offset_value, value);
+}
+
+
+/**
+ * java/lang/Double
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. double value;
+ */
+class java_lang_Double : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double));
+
+public:
+ java_lang_Double(java_handle_t* h) : java_lang_Object(h) {}
+
+ inline double get_value();
+ inline void set_value(double value);
+};
+
+inline double java_lang_Double::get_value()
+{
+ return get<double>(_handle, offset_value);
+}
+
+inline void java_lang_Double::set_value(double value)
+{
+ set(_handle, offset_value, value);
+}
+
+
+#if defined(ENABLE_JAVASE)
+
+# if defined(ENABLE_ANNOTATIONS)
+/**
+ * OpenJDK sun/reflect/ConstantPool
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object constantPoolOop;
+ */
+class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+ sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
+ sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
+
+ // Setters.
+ inline void set_constantPoolOop(classinfo* value);
+ inline void set_constantPoolOop(jclass value);
+};
+
+
+inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
+{
+ set_constantPoolOop(constantPoolOop);
+}
+
+
+inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
+{
+ set(_handle, offset_constantPoolOop, value);
+}
+
+inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
+{
+ // XXX jclass is a boxed object.
+ set_constantPoolOop(LLNI_classinfo_unwrap(value));
+}
+# endif // ENABLE_ANNOTATIONS
+
+#endif // ENABLE_JAVASE
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+/**
+ * GNU Classpath java/lang/Class
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object[] signers;
+ * 2. java.security.ProtectionDomain pd;
+ * 3. java.lang.Object vmdata;
+ * 4. java.lang.reflect.Constructor constructor;
+ */
+class java_lang_Class : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_Class(java_handle_t* h) : java_lang_Object(h) {}
+
+ // Setters.
+ inline void set_pd(java_handle_t* value);
+ inline void set_pd(jobject value);
+};
+
+inline void java_lang_Class::set_pd(java_handle_t* value)
+{
+ set(_handle, offset_pd, value);
+}
+
+inline void java_lang_Class::set_pd(jobject value)
+{
+ set_pd((java_handle_t*) value);
+}
+
+
+/**
+ * GNU Classpath java/lang/StackTraceElement
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String fileName;
+ * 2. int lineNumber;
+ * 3. java.lang.String declaringClass;
+ * 4. java.lang.String methodName;
+ * 5. boolean isNative;
+ */
+class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative);
+};
+
+inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative) : java_lang_Object(h)
+{
+ java_lang_StackTraceElement((java_handle_t*) h);
+
+ set(_handle, offset_fileName, fileName);
+ set(_handle, offset_lineNumber, lineNumber);
+ set(_handle, offset_declaringClass, declaringClass);
+ set(_handle, offset_methodName, methodName);
+ set(_handle, offset_isNative, isNative);
+}
+
+
+/**
+ * GNU Classpath java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int count;
+ * 3. int cachedHashCode;
+ * 4. int offset;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t));
+
+public:
+ java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_String(jstring h);
+ java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+ // Getters.
+ inline java_handle_chararray_t* get_value () const;
+ inline int32_t get_count () const;
+ inline int32_t get_offset() const;
+
+ // Setters.
+ inline void set_value (java_handle_chararray_t* value);
+ inline void set_count (int32_t value);
+ inline void set_offset(int32_t value);
+};
+
+inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h)
+{
+ java_lang_String((java_handle_t*) h);
+}
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+ set_value(value);
+ set_count(count);
+ set_offset(offset);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+ return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+ return get<int32_t>(_handle, offset_count);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+ return get<int32_t>(_handle, offset_offset);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+ set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+ set(_handle, offset_count, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+ set(_handle, offset_offset, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/Thread
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.VMThread vmThread;
+ * 2. java.lang.ThreadGroup group;
+ * 3. java.lang.Runnable runnable;
+ * 4. java.lang.String name;
+ * 5. boolean daemon;
+ * 6. int priority;
+ * 7. long stacksize;
+ * 8. java.lang.Throwable stillborn;
+ * 9. java.lang.ClassLoader contextClassLoader;
+ * 10. boolean contextClassLoaderIsSystemClassLoader;
+ * 11. long threadId;
+ * 12. java.lang.Object parkBlocker;
+ * 13. gnu.java.util.WeakIdentityHashMap locals;
+ * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t));
+ static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P);
+ static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t));
+ static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P);
+ static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+// java_lang_Thread(threadobject* t);
+
+ // Getters.
+ inline java_handle_t* get_vmThread () const;
+ inline java_handle_t* get_group () const;
+ inline java_handle_t* get_name () const;
+ inline int32_t get_daemon () const;
+ inline int32_t get_priority () const;
+ inline java_handle_t* get_exceptionHandler() const;
+
+ // Setters.
+ inline void set_group(java_handle_t* value);
+};
+
+
+// inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
+// {
+// java_lang_Thread(thread_get_object(t));
+// }
+
+
+inline java_handle_t* java_lang_Thread::get_vmThread() const
+{
+ return get<java_handle_t*>(_handle, offset_vmThread);
+}
+
+inline java_handle_t* java_lang_Thread::get_group() const
+{
+ return get<java_handle_t*>(_handle, offset_group);
+}
+
+inline java_handle_t* java_lang_Thread::get_name() const
+{
+ return get<java_handle_t*>(_handle, offset_name);
+}
+
+inline int32_t java_lang_Thread::get_daemon() const
+{
+ return get<int32_t>(_handle, offset_daemon);
+}
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+ return get<int32_t>(_handle, offset_priority);
+}
+
+inline java_handle_t* java_lang_Thread::get_exceptionHandler() const
+{
+ return get<java_handle_t*>(_handle, offset_exceptionHandler);
+}
+
+
+inline void java_lang_Thread::set_group(java_handle_t* value)
+{
+ set(_handle, offset_group, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/VMThread
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Thread thread;
+ * 2. boolean running;
+ * 3. java.lang.VMThread vmdata;
+ */
+class java_lang_VMThread : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+ java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_VMThread(jobject h);
+ java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata);
+
+ // Getters.
+ inline java_handle_t* get_thread() const;
+ inline threadobject* get_vmdata() const;
+
+ // Setters.
+ inline void set_thread(java_handle_t* value);
+ inline void set_vmdata(threadobject* value);
+};
+
+
+inline java_lang_VMThread::java_lang_VMThread(jobject h) : java_lang_Object(h)
+{
+ java_lang_VMThread((java_handle_t*) h);
+}
+
+inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h)
+{
+ set_thread(thread);
+ set_vmdata(vmdata);
+}
+
+
+inline java_handle_t* java_lang_VMThread::get_thread() const
+{
+ return get<java_handle_t*>(_handle, offset_thread);
+}
+
+inline threadobject* java_lang_VMThread::get_vmdata() const
+{
+ return get<threadobject*>(_handle, offset_vmdata);
+}
+
+
+inline void java_lang_VMThread::set_thread(java_handle_t* value)
+{
+ set(_handle, offset_thread, value);
+}
+
+inline void java_lang_VMThread::set_vmdata(threadobject* value)
+{
+ set(_handle, offset_vmdata, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/Throwable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String detailMessage;
+ * 2. java.lang.Throwable cause;
+ * 3. java.lang.StackTraceElement[] stackTrace;
+ * 4. java.lang.VMThrowable vmState;
+ */
+class java_lang_Throwable : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
+
+ // Getters.
+ inline java_handle_t* get_detailMessage() const;
+ inline java_handle_t* get_cause () const;
+ inline java_handle_t* get_vmState () const;
+};
+
+
+inline java_handle_t* java_lang_Throwable::get_detailMessage() const
+{
+ return get<java_handle_t*>(_handle, offset_detailMessage);
+}
+
+inline java_handle_t* java_lang_Throwable::get_cause() const
+{
+ return get<java_handle_t*>(_handle, offset_cause);
+}
+
+inline java_handle_t* java_lang_Throwable::get_vmState() const
+{
+ return get<java_handle_t*>(_handle, offset_vmState);
+}
+
+
+/**
+ * GNU Classpath java/lang/VMThrowable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object vmdata;
+ */
+class java_lang_VMThrowable : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+ java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_VMThrowable(jobject h);
+
+ inline java_handle_bytearray_t* get_vmdata() const;
+ inline void set_vmdata(java_handle_bytearray_t* value);
+};
+
+inline java_lang_VMThrowable::java_lang_VMThrowable(jobject h) : java_lang_Object(h)
+{
+ java_lang_VMThrowable((java_handle_t*) h);
+}
+
+inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_vmdata);
+}
+
+inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_vmdata, value);
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/VMConstructor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Class clazz;
+ * 2. int slot;
+ * 3. byte[] annotations;
+ * 4. byte[] parameterAnnotations;
+ * 5. java.util.Map declaredAnnotations;
+ * 6. java.lang.reflect.Constructor cons;
+ */
+class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_VMConstructor(jobject h);
+ java_lang_reflect_VMConstructor(methodinfo* m);
+
+ // Getters.
+ inline classinfo* get_clazz () const;
+ inline int32_t get_slot () const;
+ inline java_handle_bytearray_t* get_annotations () const;
+ inline java_handle_bytearray_t* get_parameterAnnotations() const;
+ inline java_handle_t* get_declaredAnnotations () const;
+ inline java_handle_t* get_cons () const;
+
+ // Setters.
+ inline void set_clazz (classinfo* value);
+ inline void set_slot (int32_t value);
+ inline void set_annotations (java_handle_bytearray_t* value);
+ inline void set_parameterAnnotations(java_handle_bytearray_t* value);
+ inline void set_declaredAnnotations (java_handle_t* value);
+ inline void set_cons (java_handle_t* value);
+
+ // Convenience functions.
+ inline methodinfo* get_method();
+};
+
+
+inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_VMConstructor((java_handle_t*) h);
+}
+
+inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
+{
+ _handle = builtin_new(class_java_lang_reflect_VMConstructor);
+
+ if (is_null())
+ return;
+
+ int slot = m - m->clazz->methods;
+ java_handle_bytearray_t* annotations = method_get_annotations(m);
+ java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
+
+ set_clazz(m->clazz);
+ set_slot(slot);
+ set_annotations(annotations);
+ set_parameterAnnotations(parameterAnnotations);
+}
+
+
+inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
+{
+ return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_VMConstructor::get_slot() const
+{
+ return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
+{
+ return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
+{
+ return get<java_handle_t*>(_handle, offset_cons);
+}
+
+inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
+{
+ set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
+{
+ set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_parameterAnnotations, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
+{
+ set(_handle, offset_declaredAnnotations, value);
+}
+
+inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
+{
+ set(_handle, offset_cons, value);
+}
+
+inline methodinfo* java_lang_reflect_VMConstructor::get_method()
+{
+ classinfo* c = get_clazz();
+ int32_t slot = get_slot();
+ methodinfo* m = &(c->methods[slot]);
+ return m;
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/Constructor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean flag;
+ * 2. gnu.java.lang.reflect.MethodSignatureParser p;
+ * 3. java.lang.reflect.VMConstructor cons;
+ */
+class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_Constructor(jobject h);
+ java_lang_reflect_Constructor(methodinfo* m);
+
+ java_handle_t* new_instance(java_handle_objectarray_t* args);
+
+ // Getters.
+ inline int32_t get_flag() const;
+ inline java_handle_t* get_cons() const;
+
+ // Setters.
+ inline void set_cons(java_handle_t* value);
+
+ // Convenience functions.
+ inline methodinfo* get_method () const;
+ inline int32_t get_override() const;
+};
+
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_Constructor((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
+{
+ java_lang_reflect_VMConstructor jlrvmc(m);
+
+ if (jlrvmc.is_null())
+ return;
+
+ _handle = builtin_new(class_java_lang_reflect_Constructor);
+
+ if (is_null())
+ return;
+
+ // Link the two Java objects.
+ set_cons(jlrvmc.get_handle());
+ jlrvmc.set_cons(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Constructor::get_flag() const
+{
+ return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
+{
+ return get<java_handle_t*>(_handle, offset_cons);
+}
+
+
+inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
+{
+ set(_handle, offset_cons, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Constructor::get_method() const
+{
+ java_lang_reflect_VMConstructor jlrvmc(get_cons());
+ return jlrvmc.get_method();
+}
+
+inline int32_t java_lang_reflect_Constructor::get_override() const
+{
+ return get_flag();
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/VMField
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Class clazz;
+ * 2. java.lang.String name;
+ * 3. int slot;
+ * 4. byte[] annotations;
+ * 5. java.lang.Map declaredAnnotations;
+ * 6. java.lang.reflect.Field f;
+ */
+class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_VMField(jobject h);
+ java_lang_reflect_VMField(fieldinfo* f);
+
+ // Getters.
+ inline classinfo* get_clazz () const;
+ inline int32_t get_slot () const;
+ inline java_handle_bytearray_t* get_annotations () const;
+ inline java_handle_t* get_declaredAnnotations() const;
+ inline java_handle_t* get_f () const;
+
+ // Setters.
+ inline void set_clazz (classinfo* value);
+ inline void set_name (java_handle_t* value);
+ inline void set_slot (int32_t value);
+ inline void set_annotations (java_handle_bytearray_t* value);
+ inline void set_declaredAnnotations(java_handle_t* value);
+ inline void set_f (java_handle_t* value);
+
+ // Convenience functions.
+ inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_VMField::java_lang_reflect_VMField(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_VMField((java_handle_t*) h);
+}
+
+inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
+{
+ _handle = builtin_new(class_java_lang_reflect_VMField);
+
+ if (is_null())
+ return;
+
+ java_handle_t* name = javastring_intern(javastring_new(f->name));
+ int slot = f - f->clazz->fields;
+ java_handle_bytearray_t* annotations = field_get_annotations(f);
+
+ set_clazz(f->clazz);
+ set_name(name);
+ set_slot(slot);
+ set_annotations(annotations);
+}
+
+
+inline classinfo* java_lang_reflect_VMField::get_clazz() const
+{
+ return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_VMField::get_slot() const
+{
+ return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const
+{
+ return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMField::get_f() const
+{
+ return get<java_handle_t*>(_handle, offset_f);
+}
+
+
+inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
+{
+ set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_VMField::set_name(java_handle_t* value)
+{
+ set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_VMField::set_slot(int32_t value)
+{
+ set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value)
+{
+ set(_handle, offset_declaredAnnotations, value);
+}
+
+inline void java_lang_reflect_VMField::set_f(java_handle_t* value)
+{
+ set(_handle, offset_f, value);
+}
+
+inline fieldinfo* java_lang_reflect_VMField::get_field() const
+{
+ classinfo* c = get_clazz();
+ int32_t slot = get_slot();
+ fieldinfo* f = &(c->fields[slot]);
+ return f;
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/Field
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean flag;
+ * 2. gnu.java.lang.reflect.FieldSignatureParser p;
+ * 3. java.lang.reflect.VMField f;
+ */
+class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_Field(jobject h);
+ java_lang_reflect_Field(fieldinfo* f);
+
+ // Getters.
+ inline int32_t get_flag() const;
+ inline java_handle_t* get_f() const;
+
+ // Setters.
+ inline void set_f(java_handle_t* value);
+
+ // Convenience functions.
+ inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_Field((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
+{
+ java_lang_reflect_VMField jlrvmf(f);
+
+ if (jlrvmf.is_null())
+ return;
+
+ _handle = builtin_new(class_java_lang_reflect_Field);
+
+ if (is_null())
+ return;
+
+ // Link the two Java objects.
+ set_f(jlrvmf.get_handle());
+ jlrvmf.set_f(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Field::get_flag() const
+{
+ return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Field::get_f() const
+{
+ return get<java_handle_t*>(_handle, offset_f);
+}
+
+
+inline void java_lang_reflect_Field::set_f(java_handle_t* value)
+{
+ set(_handle, offset_f, value);
+}
+
+
+inline fieldinfo* java_lang_reflect_Field::get_field() const
+{
+ java_lang_reflect_VMField jlrvmf(get_f());
+ return jlrvmf.get_field();
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/VMMethod
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Class clazz;
+ * 2. java.lang.String name;
+ * 3. int slot;
+ * 4. byte[] annotations;
+ * 5. byte[] parameterAnnotations;
+ * 6. byte[] annotationDefault;
+ * 7. java.lang.Map declaredAnnotations;
+ * 8. java.lang.reflect.Method m;
+ */
+class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_VMMethod(jobject h);
+ java_lang_reflect_VMMethod(methodinfo* m);
+
+ // Getters.
+ inline classinfo* get_clazz () const;
+ inline int32_t get_slot () const;
+ inline java_handle_bytearray_t* get_annotations () const;
+ inline java_handle_bytearray_t* get_parameterAnnotations() const;
+ inline java_handle_bytearray_t* get_annotationDefault () const;
+ inline java_handle_t* get_declaredAnnotations () const;
+ inline java_handle_t* get_m () const;
+
+ // Setters.
+ inline void set_clazz (classinfo* value);
+ inline void set_name (java_handle_t* value);
+ inline void set_slot (int32_t value);
+ inline void set_annotations (java_handle_bytearray_t* value);
+ inline void set_parameterAnnotations(java_handle_bytearray_t* value);
+ inline void set_annotationDefault (java_handle_bytearray_t* value);
+ inline void set_declaredAnnotations (java_handle_t* value);
+ inline void set_m (java_handle_t* value);
+
+ // Convenience functions.
+ inline methodinfo* get_method() const;
+};
+
+inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_VMMethod((java_handle_t*) h);
+}
+
+inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
+{
+ _handle = builtin_new(class_java_lang_reflect_VMMethod);
+
+ if (is_null())
+ return;
+
+ java_handle_t* name = javastring_intern(javastring_new(m->name));
+ int slot = m - m->clazz->methods;
+ java_handle_bytearray_t* annotations = method_get_annotations(m);
+ java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
+ java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m);
+
+ set_clazz(m->clazz);
+ set_name(name);
+ set_slot(slot);
+ set_annotations(annotations);
+ set_parameterAnnotations(parameterAnnotations);
+ set_annotationDefault(annotationDefault);
+}
+
+inline classinfo* java_lang_reflect_VMMethod::get_clazz() const
+{
+ return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_VMMethod::get_slot() const
+{
+ return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
+}
+
+inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const
+{
+ return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+}
+
+inline java_handle_t* java_lang_reflect_VMMethod::get_m() const
+{
+ return get<java_handle_t*>(_handle, offset_m);
+}
+
+inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value)
+{
+ set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value)
+{
+ set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_slot(int32_t value)
+{
+ set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_parameterAnnotations, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_annotationDefault, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value)
+{
+ set(_handle, offset_declaredAnnotations, value);
+}
+
+inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value)
+{
+ set(_handle, offset_m, value);
+}
+
+inline methodinfo* java_lang_reflect_VMMethod::get_method() const
+{
+ classinfo* c = get_clazz();
+ int32_t slot = get_slot();
+ methodinfo* m = &(c->methods[slot]);
+ return m;
+}
+
+
+/**
+ * GNU Classpath java/lang/reflect/Method
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean flag;
+ * 2. gnu.java.lang.reflect.MethodSignatureParser p;
+ * 3. java.lang.reflect.VMMethod m;
+ */
+class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_Method(jobject h);
+ java_lang_reflect_Method(methodinfo* m);
+
+ java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
+
+ // Getters.
+ inline int32_t get_flag() const;
+ inline java_handle_t* get_m() const;
+
+ // Setters.
+ inline void set_m(java_handle_t* value);
+
+ // Convenience functions.
+ inline methodinfo* get_method () const;
+ inline int32_t get_override() const;
+};
+
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_Method((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
+{
+ java_lang_reflect_VMMethod jlrvmm(m);
+
+ if (jlrvmm.is_null())
+ return;
+
+ _handle = builtin_new(class_java_lang_reflect_Method);
+
+ if (is_null())
+ return;
+
+ // Link the two Java objects.
+ set_m(jlrvmm.get_handle());
+ jlrvmm.set_m(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Method::get_flag() const
+{
+ return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Method::get_m() const
+{
+ return get<java_handle_t*>(_handle, offset_m);
+}
+
+
+inline void java_lang_reflect_Method::set_m(java_handle_t* value)
+{
+ set(_handle, offset_m, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Method::get_method() const
+{
+ java_lang_reflect_VMMethod jlrvmm(get_m());
+ return jlrvmm.get_method();
+}
+
+inline int32_t java_lang_reflect_Method::get_override() const
+{
+ return get_flag();
+}
+
+
+/**
+ * GNU Classpath java/nio/Buffer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int cap;
+ * 2. int limit;
+ * 3. int pos;
+ * 4. int mark;
+ * 5. gnu.classpath.Pointer address;
+ */
+class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+ java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+
+ // Getters.
+ inline int32_t get_cap() const;
+};
+
+inline int32_t java_nio_Buffer::get_cap() const
+{
+ return get<int32_t>(_handle, offset_cap);
+}
+
+
+/**
+ * GNU Classpath java/nio/DirectByteBufferImpl
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int cap;
+ * 2. int limit;
+ * 3. int pos;
+ * 4. int mark;
+ * 5. gnu.classpath.Pointer address;
+ * 6. java.nio.ByteOrder endian;
+ * 7. byte[] backing_buffer;
+ * 8. int array_offset;
+ * 9. java.lang.Object owner;
+ */
+class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+ java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {}
+ java_nio_DirectByteBufferImpl(jobject h);
+
+ // Getters.
+ inline java_handle_t* get_address() const;
+};
+
+inline java_nio_DirectByteBufferImpl::java_nio_DirectByteBufferImpl(jobject h) : java_lang_Object(h)
+{
+ java_nio_DirectByteBufferImpl((java_handle_t*) h);
+}
+
+inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const
+{
+ return get<java_handle_t*>(_handle, offset_address);
+}
+
+
+/**
+ * GNU Classpath gnu/classpath/Pointer
+ *
+ * Actually there are two classes, gnu.classpath.Pointer32 and
+ * gnu.classpath.Pointer64, but we only define the abstract super
+ * class and use the int/long field as void* type.
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int/long data;
+ */
+class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+ gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {}
+ gnu_classpath_Pointer(java_handle_t* h, void* data);
+
+ // Setters.
+ inline void* get_data() const;
+
+ // Setters.
+ inline void set_data(void* value);
+};
+
+inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h)
+{
+ set_data(data);
+}
+
+inline void* gnu_classpath_Pointer::get_data() const
+{
+ return get<void*>(_handle, offset_data);
+}
+
+inline void gnu_classpath_Pointer::set_data(void* value)
+{
+ set(_handle, offset_data, value);
+}
+
+#endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+/**
+ * OpenJDK java/lang/AssertionStatusDirectives
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String[] classes;
+ * 2. boolean[] classEnabled;
+ * 3. java.lang.String[] packages;
+ * 4. boolean[] packageEnabled;
+ * 5. boolean deflt;
+ */
+class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
+
+public:
+ java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
+};
+
+inline java_lang_AssertionStatusDirectives::java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled)
+{
+ classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
+
+ // FIXME Load the class at VM startup.
+ if (c == NULL)
+ return;
+
+ _handle = builtin_new(c);
+
+ if (is_null())
+ return;
+
+ set(_handle, offset_classes, classes);
+ set(_handle, offset_classEnabled, classEnabled);
+ set(_handle, offset_packages, packages);
+ set(_handle, offset_packageEnabled, packageEnabled);
+}
+
+
+/**
+ * OpenJDK java/lang/StackTraceElement
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String declaringClass;
+ * 2. java.lang.String methodName;
+ * 3. java.lang.String fileName;
+ * 4. int lineNumber;
+ */
+class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t));
+
+public:
+ java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber);
+};
+
+inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber)
+{
+ _handle = builtin_new(class_java_lang_StackTraceElement);
+
+ if (is_null())
+ return;
+
+ set(_handle, offset_declaringClass, declaringClass);
+ set(_handle, offset_methodName, methodName);
+ set(_handle, offset_fileName, fileName);
+ set(_handle, offset_lineNumber, lineNumber);
+}
+
+
+/**
+ * OpenJDK java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int offset;
+ * 3. int count;
+ * 4. int hash;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t));
+
+public:
+ java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_String(jstring h);
+ java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+ // Getters.
+ inline java_handle_chararray_t* get_value () const;
+ inline int32_t get_offset() const;
+ inline int32_t get_count () const;
+
+ // Setters.
+ inline void set_value (java_handle_chararray_t* value);
+ inline void set_offset(int32_t value);
+ inline void set_count (int32_t value);
+};
+
+inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h)
+{
+ java_lang_String((java_handle_t*) h);
+}
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+ set_value(value);
+ set_offset(offset);
+ set_count(count);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+ return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+ return get<int32_t>(_handle, offset_offset);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+ return get<int32_t>(_handle, offset_count);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+ set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+ set(_handle, offset_offset, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+ set(_handle, offset_count, value);
+}
+
+
+/**
+ * OpenJDK java/lang/Thread
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] name;
+ * 2. int priority;
+ * 3. java_lang_Thread threadQ;
+ * 4. long eetop;
+ * 5. boolean single_step;
+ * 6. boolean daemon;
+ * 7. boolean stillborn;
+ * 8. java_lang_Runnable target;
+ * 9. java_lang_ThreadGroup group;
+ * 10. java_lang_ClassLoader contextClassLoader;
+ * 11. java_security_AccessControlContext inheritedAccessControlContext;
+ * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals;
+ * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals;
+ * 14. long stackSize;
+ * 15. long nativeParkEventPointer;
+ * 16. long tid;
+ * 17. int threadStatus;
+ * 18. java_lang_Object parkBlocker;
+ * 19. sun_nio_ch_Interruptible blocker;
+ * 20. java_lang_Object blockerLock;
+ * 21. boolean stopBeforeStart;
+ * 22. java_lang_Throwable throwableFromStop;
+ * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t));
+ static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t));
+ static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t));
+ static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t));
+ static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t));
+ static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t));
+ static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+// java_lang_Thread(threadobject* t);
+
+ // Getters.
+ inline int32_t get_priority () const;
+ inline int32_t get_daemon () const;
+ inline java_handle_t* get_group () const;
+ inline java_handle_t* get_uncaughtExceptionHandler() const;
+
+ // Setters.
+ inline void set_priority(int32_t value);
+ inline void set_group (java_handle_t* value);
+};
+
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+ return get<int32_t>(_handle, offset_priority);
+}
+
+inline int32_t java_lang_Thread::get_daemon() const
+{
+ return get<int32_t>(_handle, offset_daemon);
+}
+
+inline java_handle_t* java_lang_Thread::get_group() const
+{
+ return get<java_handle_t*>(_handle, offset_group);
+}
+
+inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
+{
+ return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
+}
+
+
+inline void java_lang_Thread::set_priority(int32_t value)
+{
+ set(_handle, offset_priority, value);
+}
+
+inline void java_lang_Thread::set_group(java_handle_t* value)
+{
+ set(_handle, offset_group, value);
+}
+
+
+
+/**
+ * OpenJDK java/lang/Throwable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object backtrace;
+ * 2. java.lang.String detailMessage;
+ * 3. java.lang.Throwable cause;
+ * 4. java.lang.StackTraceElement[] stackTrace;
+ */
+class java_lang_Throwable : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_Throwable(jobject h);
+ java_lang_Throwable(jobject h, java_handle_bytearray_t* backtrace);
+
+ // Getters.
+ inline java_handle_bytearray_t* get_backtrace () const;
+ inline java_handle_t* get_detailMessage() const;
+ inline java_handle_t* get_cause () const;
+
+ // Setters.
+ inline void set_backtrace(java_handle_bytearray_t* value);
+};
+
+
+inline java_lang_Throwable::java_lang_Throwable(jobject h) : java_lang_Object(h)
+{
+ java_lang_Throwable((java_handle_t*) h);
+}
+
+inline java_lang_Throwable::java_lang_Throwable(jobject h, java_handle_bytearray_t* backtrace) : java_lang_Object(h)
+{
+ java_lang_Throwable((java_handle_t*) h);
+ set_backtrace(backtrace);
+}
+
+
+inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
+}
+
+inline java_handle_t* java_lang_Throwable::get_detailMessage() const
+{
+ return get<java_handle_t*>(_handle, offset_detailMessage);
+}
+
+inline java_handle_t* java_lang_Throwable::get_cause() const
+{
+ return get<java_handle_t*>(_handle, offset_cause);
+}
+
+
+inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_backtrace, value);
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Constructor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean override;
+ * 2. java.lang.Class clazz;
+ * 3. int slot;
+ * 4. java.lang.Class[] parameterTypes;
+ * 5. java.lang.Class[] exceptionTypes;
+ * 6. int modifiers;
+ * 7. java.lang.String signature;
+ * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo;
+ * 9. byte[] annotations;
+ * 10. byte[] parameterAnnotations;
+ * 11. java.lang.Class securityCheckCache;
+ * 12. sun.reflect.ConstructorAccessor constructorAccessor;
+ * 13. java.lang.reflect.Constructor root;
+ * 14. java.util.Map declaredAnnotations;
+ */
+class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_Constructor(jobject h);
+ java_lang_reflect_Constructor(methodinfo* m);
+
+ java_handle_t* new_instance(java_handle_objectarray_t* args);
+
+ // Getters.
+ inline int32_t get_override () const;
+ inline classinfo* get_clazz () const;
+ inline int32_t get_slot () const;
+ inline java_handle_bytearray_t* get_annotations() const;
+
+ // Setters.
+ inline void set_clazz (classinfo* value);
+ inline void set_slot (int32_t value);
+ inline void set_parameterTypes (java_handle_objectarray_t* value);
+ inline void set_exceptionTypes (java_handle_objectarray_t* value);
+ inline void set_modifiers (int32_t value);
+ inline void set_signature (java_handle_t* value);
+ inline void set_annotations (java_handle_bytearray_t* value);
+ inline void set_parameterAnnotations(java_handle_bytearray_t* value);
+
+ // Convenience functions.
+ inline methodinfo* get_method();
+};
+
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_Constructor((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
+{
+ _handle = builtin_new(class_java_lang_reflect_Constructor);
+
+ if (is_null())
+ return;
+
+ int slot = m - m->clazz->methods;
+ java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m);
+ java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m);
+ java_handle_bytearray_t* annotations = method_get_annotations(m);
+ java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
+
+ set_clazz(m->clazz);
+ set_slot(slot);
+ set_parameterTypes(parameterTypes);
+ set_exceptionTypes(exceptionTypes);
+ set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
+ set_signature(m->signature ? javastring_new(m->signature) : NULL);
+ set_annotations(annotations);
+ set_parameterAnnotations(parameterAnnotations);
+}
+
+
+inline int32_t java_lang_reflect_Constructor::get_override() const
+{
+ return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Constructor::get_clazz() const
+{
+ return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Constructor::get_slot() const
+{
+ return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+
+inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
+{
+ set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_Constructor::set_slot(int32_t value)
+{
+ set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
+{
+ set(_handle, offset_parameterTypes, value);
+}
+
+inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
+{
+ set(_handle, offset_exceptionTypes, value);
+}
+
+inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
+{
+ set(_handle, offset_modifiers, value);
+}
+
+inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
+{
+ set(_handle, offset_signature, value);
+}
+
+inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_parameterAnnotations, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Constructor::get_method()
+{
+ classinfo* c = get_clazz();
+ int32_t slot = get_slot();
+ methodinfo* m = &(c->methods[slot]);
+ return m;
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Field
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean override;
+ * 2. java.lang.Class clazz;
+ * 3. int slot;
+ * 4. java.lang.String name;
+ * 5. java.lang.Class type;
+ * 6. int modifiers;
+ * 7. java.lang.String signature;
+ * 8. sun.reflect.generics.repository.FieldRepository genericInfo;
+ * 9. byte[] annotations;
+ * 10. sun.reflect.FieldAccessor fieldAccessor;
+ * 11. sun.reflect.FieldAccessor overrideFieldAccessor;
+ * 12. java.lang.reflect.Field root;
+ * 13. java.lang.Class securityCheckCache;
+ * 14. java.lang.Class securityCheckTargetClassCache;
+ * 15. java.util.Map declaredAnnotations;
+ */
+class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_Field(jobject h);
+ java_lang_reflect_Field(fieldinfo* f);
+
+ // Getters.
+ inline int32_t get_override () const;
+ inline classinfo* get_clazz () const;
+ inline int32_t get_slot () const;
+ inline java_handle_bytearray_t* get_annotations() const;
+
+ // Setters.
+ inline void set_clazz (classinfo* value);
+ inline void set_slot (int32_t value);
+ inline void set_name (java_handle_t* value);
+ inline void set_type (classinfo* value);
+ inline void set_modifiers (int32_t value);
+ inline void set_signature (java_handle_t* value);
+ inline void set_annotations(java_handle_bytearray_t* value);
+
+ // Convenience functions.
+ inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_Field((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
+{
+ _handle = builtin_new(class_java_lang_reflect_Field);
+
+ // OOME.
+ if (is_null())
+ return;
+
+ set_clazz(f->clazz);
+ set_slot(f - f->clazz->fields);
+ set_name(javastring_intern(javastring_new(f->name)));
+ set_type(field_get_type(f));
+ set_modifiers(f->flags);
+ set_signature(f->signature ? javastring_new(f->signature) : NULL);
+ set_annotations(field_get_annotations(f));
+}
+
+
+inline int32_t java_lang_reflect_Field::get_override() const
+{
+ return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Field::get_clazz() const
+{
+ return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Field::get_slot() const
+{
+ return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+
+inline void java_lang_reflect_Field::set_clazz(classinfo* value)
+{
+ set(_handle, offset_clazz, value);
+}
+
+inline void java_lang_reflect_Field::set_slot(int32_t value)
+{
+ set(_handle, offset_slot, value);
+}
+
+inline void java_lang_reflect_Field::set_name(java_handle_t* value)
+{
+ set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_Field::set_type(classinfo* value)
+{
+ set(_handle, offset_type, value);
+}
+
+inline void java_lang_reflect_Field::set_modifiers(int32_t value)
+{
+ set(_handle, offset_modifiers, value);
+}
+
+inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
+{
+ set(_handle, offset_signature, value);
+}
+
+inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_annotations, value);
+}
+
+
+inline fieldinfo* java_lang_reflect_Field::get_field() const
+{
+ classinfo* c = get_clazz();
+ int32_t slot = get_slot();
+ fieldinfo* f = &(c->fields[slot]);
+ return f;
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Method
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. boolean override;
+ * 2. java.lang.Class clazz;
+ * 3. int slot;
+ * 4. java.lang.String name;
+ * 5. java.lang.Class returnType;
+ * 6. java.lang.Class[] parameterTypes;
+ * 7. java.lang.Class[] exceptionTypes;
+ * 8. int modifiers;
+ * 9. java.lang.String signature;
+ * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo;
+ * 11. byte[] annotations;
+ * 12. byte[] parameterAnnotations;
+ * 13. byte[] annotationDefault;
+ * 14. sun.reflect.MethodAccessor methodAccessor;
+ * 15. java.lang.reflect.Method root;
+ * 16. java.lang.Class securityCheckCache;
+ * 17. java.lang.Class securityCheckTargetClassCache;
+ * 18. java.util.Map declaredAnnotations;
+ */
+class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_reflect_Method(jobject h);
+ java_lang_reflect_Method(methodinfo* m);
+
+ java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
+
+ // Getters.
+ inline int32_t get_override () const;
+ inline classinfo* get_clazz () const;
+ inline int32_t get_slot () const;
+ inline java_handle_bytearray_t* get_annotations () const;
+ inline java_handle_bytearray_t* get_parameterAnnotations() const;
+ inline java_handle_bytearray_t* get_annotationDefault () const;
+
+ // Setters.
+
+ // Convenience functions.
+ inline methodinfo* get_method() const;
+};
+
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h)
+{
+ java_lang_reflect_Method((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
+{
+ _handle = builtin_new(class_java_lang_reflect_Method);
+
+ if (is_null())
+ return;
+
+ set(_handle, offset_clazz, m->clazz);
+ set(_handle, offset_slot, m - m->clazz->methods);
+ set(_handle, offset_name, javastring_intern(javastring_new(m->name)));
+ set(_handle, offset_returnType, method_returntype_get(m));
+ set(_handle, offset_parameterTypes, method_get_parametertypearray(m));
+ set(_handle, offset_exceptionTypes, method_get_exceptionarray(m));
+ set(_handle, offset_modifiers, m->flags & ACC_CLASS_REFLECT_MASK);
+ set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL);
+ set(_handle, offset_annotations, method_get_annotations(m));
+ set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
+ set(_handle, offset_annotationDefault, method_get_annotationdefault(m));
+}
+
+
+inline int32_t java_lang_reflect_Method::get_override() const
+{
+ return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Method::get_clazz() const
+{
+ return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Method::get_slot() const
+{
+ return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
+}
+
+
+inline methodinfo* java_lang_reflect_Method::get_method() const
+{
+ classinfo* c = get_clazz();
+ int32_t slot = get_slot();
+ methodinfo* m = &(c->methods[slot]);
+ return m;
+}
+
+
+/**
+ * OpenJDK java/nio/Buffer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int mark;
+ * 2. int position;
+ * 3. int limit;
+ * 4. int capacity;
+ * 5. long address;
+ */
+class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
+
+public:
+ java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+ java_nio_Buffer(jobject h) : java_lang_Object(h) {}
+
+ // Getters.
+ inline void* get_address() const;
+};
+
+
+inline void* java_nio_Buffer::get_address() const
+{
+ return get<void*>(_handle, offset_address);
+}
+
+#endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
+
+/**
+ * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. long pointer;
+ * 2. int position;
+ * 3. int length;
+ */
+class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t));
+ static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t));
+ static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
+
+public:
+ com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {}
+ com_sun_cldchi_jvm_FileDescriptor(jobject h);
+ com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length);
+ com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd);
+
+ // Getters.
+ inline int64_t get_pointer () const;
+ inline int32_t get_position() const;
+ inline int32_t get_length () const;
+
+ // Setters.
+ inline void set_pointer (int64_t value);
+ inline void set_position(int32_t value);
+ inline void set_length (int32_t value);
+};
+
+
+inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(jobject h) : java_lang_Object(h)
+{
+ com_sun_cldchi_jvm_FileDescriptor((java_handle_t*) h);
+}
+
+inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length) : java_lang_Object(h)
+{
+ set_pointer(pointer);
+ set_position(position);
+ set_length(length);
+}
+
+inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd) : java_lang_Object(h)
+{
+ com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length());
+}
+
+
+inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const
+{
+ return get<int64_t>(_handle, offset_pointer);
+}
+
+inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const
+{
+ return get<int32_t>(_handle, offset_position);
+}
+
+inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const
+{
+ return get<int32_t>(_handle, offset_length);
+}
+
+
+inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value)
+{
+ set(_handle, offset_pointer, value);
+}
+
+inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value)
+{
+ set(_handle, offset_position, value);
+}
+
+inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value)
+{
+ set(_handle, offset_length, value);
+}
+
+
+/**
+ * CLDC 1.1 java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int offset;
+ * 3. int count;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
+
+public:
+ java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_String(jstring h);
+ java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+ // Getters.
+ inline java_handle_chararray_t* get_value () const;
+ inline int32_t get_offset() const;
+ inline int32_t get_count () const;
+
+ // Setters.
+ inline void set_value (java_handle_chararray_t* value);
+ inline void set_offset(int32_t value);
+ inline void set_count (int32_t value);
+};
+
+inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h)
+{
+ java_lang_String((java_handle_t*) h);
+}
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+ set_value(value);
+ set_offset(offset);
+ set_count(count);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+ return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+ return get<int32_t>(_handle, offset_offset);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+ return get<int32_t>(_handle, offset_count);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+ set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+ set(_handle, offset_offset, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+ set(_handle, offset_count, value);
+}
+
+
+/**
+ * CLDC 1.1 java/lang/Thread
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int priority;
+ * 2. java.lang.Runnable runnable;
+ * 3. java.lang.Object vm_thread;
+ * 4. int is_terminated;
+ * 5. int is_stillborn;
+ * 6. char[] name;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t));
+ static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P);
+ static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P);
+ static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t));
+ static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t));
+ static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+ java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_Thread(jobject h);
+// java_lang_Thread(threadobject* t);
+
+ // Getters.
+ inline int32_t get_priority () const;
+ inline threadobject* get_vm_thread() const;
+ inline java_handle_chararray_t* get_name () const;
+
+ // Setters.
+ inline void set_vm_thread(threadobject* value);
+};
+
+
+inline java_lang_Thread::java_lang_Thread(jobject h) : java_lang_Object(h)
+{
+ java_lang_Thread((java_handle_t*) h);
+}
+
+// inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h)
+// {
+// java_lang_Thread(thread_get_object(t));
+// }
+
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+ return get<int32_t>(_handle, offset_priority);
+}
+
+inline threadobject* java_lang_Thread::get_vm_thread() const
+{
+ return get<threadobject*>(_handle, offset_vm_thread);
+}
+
+inline java_handle_chararray_t* java_lang_Thread::get_name() const
+{
+ return get<java_handle_chararray_t*>(_handle, offset_name);
+}
+
+
+inline void java_lang_Thread::set_vm_thread(threadobject* value)
+{
+ set(_handle, offset_vm_thread, value);
+}
+
+
+/**
+ * CLDC 1.1 java/lang/Throwable
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.String detailMessage;
+ * 2. java.lang.Object backtrace;
+ */
+class java_lang_Throwable : public java_lang_Object, private FieldAccess {
+private:
+ // Static offsets of the object's instance fields.
+ // TODO These offsets need to be checked on VM startup.
+ static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+ static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P);
+
+public:
+ java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {}
+ java_lang_Throwable(jobject h);
+
+ // Getters.
+ inline java_handle_t* get_detailMessage() const;
+ inline java_handle_bytearray_t* get_backtrace () const;
+
+ // Setters.
+ inline void set_backtrace(java_handle_bytearray_t* value);
+};
+
+
+inline java_lang_Throwable::java_lang_Throwable(jobject h) : java_lang_Object(h)
+{
+ java_lang_Throwable((java_handle_t*) h);
+}
+
+
+inline java_handle_t* java_lang_Throwable::get_detailMessage() const
+{
+ return get<java_handle_t*>(_handle, offset_detailMessage);
+}
+
+inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const
+{
+ return get<java_handle_bytearray_t*>(_handle, offset_backtrace);
+}
+
+
+inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
+{
+ set(_handle, offset_backtrace, value);
+}
+
+#endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1
+
+#else
+
+// Legacy C interface.
+java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m);
+java_handle_t* java_lang_reflect_Field_create(fieldinfo* f);
+java_handle_t* java_lang_reflect_Method_create(methodinfo* m);
+
+#endif
+
+#endif // _JAVAOBJECTS_HPP
+
+
+/*
+ * 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:
+ */
static s4 class_highestinterface(classinfo *c);
-/* dummy structures for alinment checks ***************************************/
-
-typedef struct dummy_alignment_long_t dummy_alignment_long_t;
-typedef struct dummy_alignment_double_t dummy_alignment_double_t;
-
-struct dummy_alignment_long_t {
- int32_t i;
- int64_t l;
-};
-
-struct dummy_alignment_double_t {
- int32_t i;
- double d;
-};
-
-
/* linker_init *****************************************************************
Initializes the linker subsystem and links classes required for the
{
TRACESUBSYSTEMINITIALIZATION("linker_preinit");
- /* Check for if alignment for long and double matches what we
- assume for the current architecture. */
-
-#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) || defined(__M68K__)
- /* Define a define here which is later checked when we use this
- offset. */
-
-# define LINKER_ALIGNMENT_LONG_DOUBLE 4
-
- if (OFFSET(dummy_alignment_long_t, l) != 4)
- vm_abort("linker_preinit: long alignment is different from what assumed: %d != %d",
- OFFSET(dummy_alignment_long_t, l), 4);
-
- if (OFFSET(dummy_alignment_double_t, d) != 4)
- vm_abort("linker_preinit: double alignment is different from what assumed: %d != %d",
- OFFSET(dummy_alignment_double_t, d), 4);
-#else
-
-# define LINKER_ALIGNMENT_LONG_DOUBLE 8
-
- if (OFFSET(dummy_alignment_long_t, l) != 8)
- vm_abort("linker_preinit: long alignment is different from what assumed: %d != %d",
- OFFSET(dummy_alignment_long_t, l), 8);
-
- if (OFFSET(dummy_alignment_double_t, d) != 8)
- vm_abort("linker_preinit: double alignment is different from what assumed: %d != %d",
- OFFSET(dummy_alignment_double_t, d), 8);
-#endif
-
/* Reset interface index. */
interfaceindex = 0;
if (!(f->flags & ACC_STATIC)) {
dsize = descriptor_typesize(f->parseddesc);
-
-#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) || defined(__M68K__)
- /* On some architectures and configurations we need to
- align long (int64_t) and double fields to 4-bytes to
- match what GCC does for struct members. We must do the
- same as GCC here because the offsets in native header
- structs like java_lang_Double must match the offsets of
- the Java fields (eg. java.lang.Double.value). */
-
-# if LINKER_ALIGNMENT_LONG_DOUBLE != 4
-# error alignment of long and double is not 4
-# endif
-
- c->instancesize = MEMORY_ALIGN(c->instancesize, 4);
-#else
-
-# if LINKER_ALIGNMENT_LONG_DOUBLE != 8
-# error alignment of long and double is not 8
-# endif
-
c->instancesize = MEMORY_ALIGN(c->instancesize, dsize);
-#endif
-
f->offset = c->instancesize;
c->instancesize += dsize;
}