1 /* src/native/vm/nativevm.cpp - Register native VM interface functions.
3 Copyright (C) 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 #include "native/vm/nativevm.hpp"
32 #include "vm/class.hpp"
33 #include "vm/exceptions.hpp"
34 #include "vm/initialize.hpp"
35 #include "vm/method.hpp"
36 #include "vm/options.h"
39 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
40 # include "mm/memory.hpp"
42 # include "native/native.hpp"
44 # include "native/vm/openjdk/hpi.hpp"
46 # include "toolbox/sequence.hpp"
48 # include "vm/globals.hpp"
49 # include "vm/properties.hpp"
55 /* nativevm_preinit ************************************************************
57 Pre-initialize the implementation specific native stuff.
59 *******************************************************************************/
61 void nativevm_preinit(void)
63 TRACESUBSYSTEMINITIALIZATION("nativevm_preinit");
65 /* Register native methods of all classes implemented. */
67 #if defined(ENABLE_JAVASE)
68 # if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
70 _Jv_gnu_classpath_VMStackWalker_init();
71 _Jv_gnu_classpath_VMSystemProperties_init();
72 _Jv_gnu_java_lang_VMCPStringBuilder_init();
73 _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init();
74 _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init();
75 _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init();
76 _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init();
77 _Jv_java_lang_VMClass_init();
78 _Jv_java_lang_VMClassLoader_init();
79 _Jv_java_lang_VMObject_init();
80 _Jv_java_lang_VMRuntime_init();
81 _Jv_java_lang_VMSystem_init();
82 _Jv_java_lang_VMString_init();
83 _Jv_java_lang_VMThread_init();
84 _Jv_java_lang_VMThrowable_init();
85 _Jv_java_lang_management_VMManagementFactory_init();
86 _Jv_java_lang_reflect_VMConstructor_init();
87 _Jv_java_lang_reflect_VMField_init();
88 _Jv_java_lang_reflect_VMMethod_init();
89 //_Jv_java_lang_reflect_VMProxy_init();
90 _Jv_java_security_VMAccessController_init();
91 _Jv_java_util_concurrent_atomic_AtomicLong_init();
92 _Jv_sun_misc_Unsafe_init();
94 #if defined(ENABLE_ANNOTATIONS)
95 _Jv_sun_reflect_ConstantPool_init();
98 # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
101 VM* vm = VM::get_current();
102 Properties& properties = vm->get_properties();
103 const char* boot_library_path = properties.get("sun.boot.library.path");
105 // Use sequence builder to assemble library path.
108 sb.cat(boot_library_path);
109 sb.cat("/libjava.so");
111 // XXX This should actually be sb.export_symbol()
112 utf* u = utf_new_char(sb.c_str());
115 void* handle = nl.open();
118 os::abort("nativevm_init: failed to open libjava.so at: %s", sb.c_str());
120 NativeLibraries& nls = vm->get_nativelibraries();
123 // Initialize the HPI.
124 HPI& hpi = vm->get_hpi();
127 _Jv_sun_misc_Perf_init();
128 _Jv_sun_misc_Unsafe_init();
131 # error unknown classpath configuration
134 #elif defined(ENABLE_JAVAME_CLDC1_1)
136 _Jv_com_sun_cldc_io_ResourceInputStream_init();
137 _Jv_com_sun_cldc_io_j2me_socket_Protocol_init();
138 _Jv_com_sun_cldchi_io_ConsoleOutputStream_init();
139 _Jv_com_sun_cldchi_jvm_JVM_init();
140 _Jv_java_lang_Class_init();
141 _Jv_java_lang_Double_init();
142 _Jv_java_lang_Float_init();
143 _Jv_java_lang_Math_init();
144 _Jv_java_lang_Object_init();
145 _Jv_java_lang_Runtime_init();
146 _Jv_java_lang_String_init();
147 _Jv_java_lang_System_init();
148 _Jv_java_lang_Thread_init();
149 _Jv_java_lang_Throwable_init();
152 # error unknown Java configuration
157 /* nativevm_init ***************************************************************
159 Initialize the implementation specific native stuff.
161 *******************************************************************************/
163 bool nativevm_init(void)
165 TRACESUBSYSTEMINITIALIZATION("nativevm_init");
167 #if defined(ENABLE_JAVASE)
169 # if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
173 # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
175 methodinfo* m = class_resolveclassmethod(class_java_lang_System,
176 utf_new_char("initializeSystemClass"),
178 class_java_lang_Object,
184 (void) vm_call_method(m, NULL);
186 if (exceptions_get_exception() != NULL)
190 # error unknown classpath configuration
193 #elif defined(ENABLE_JAVAME_CLDC1_1)
198 # error unknown Java configuration
206 * These are local overrides for various environment variables in Emacs.
207 * Please do not remove this and leave it at the end of the file, where
208 * Emacs will automagically detect them.
209 * ---------------------------------------------------------------------
212 * indent-tabs-mode: t
216 * vim:noexpandtab:sw=4:ts=4: