Index: build/make/setup.xml
===================================================================
109c109
<
---
>
Index: build/make/targets/cunit.test.xml
===================================================================
131c131
<
---
>
136a137
>
142a144
>
Index: build/make/targets/common_vm.xml
===================================================================
100c100
<
---
>
Index: build/make/targets/smoke.test.xml
===================================================================
122c122
<
---
>
131c131
<
---
>
Index: build/make/targets/test.xml
===================================================================
21c21
<
---
>
Index: vm/include/open/thread_externals.h
===================================================================
25c25,27
< #include
---
> #include "open/hythread_ext.h"
>
> #include "jni.h"
73,75c75,81
< * registtrate thread in VM, so it could execute Java
< */
< VMEXPORT int vm_attach();
---
> * Registrates current thread in VM, so it could execute Java
> *
> * @param[in] java_vm current thread will be attached to the specified VM
> * @param[out] p_jni_env will point to JNI environment assocciated with the thread
> */
> VMEXPORT IDATA vm_jthread_attach(JavaVM * java_vm, JNIEnv ** p_jni_env);
>
77,79c83,85
< * free java related resources before thread exit
< */
< VMEXPORT int vm_detach();
---
> * Frees java related resources before thread exit.
> */
> VMEXPORT IDATA vm_jthread_detach(jthread java_thread);
81a88,103
> * Creates new j.l.Thread object
> *
> * @param[out] thread_object pointer to created thread object
> * @param[in] jni_env JNI environment assocciated with the current thread
> * @param[in] group thread group where new thread should be placed in
> * @param[in] name thread's name
> * @param[in] daemon JNI_TRUE if new thread is a daemon, JNI_FALSE overwise
> */
> VMEXPORT IDATA vm_create_jthread(jthread * thread_object,
> JNIEnv * jni_env,
> jobject group,
> char * name,
> jboolean daemon);
>
> /* throw exception
> /**
117,118c139,141
< * get JNIEnv *
< * @return JNIEnv *
---
> * Returns thread library associated with the VM.
> *
> * @param[in] java_vm VM
120,121c143
< VMEXPORT JNIEnv * get_jnienv(void);
<
---
> VMEXPORT hythread_library_t vm_get_thread_library(JavaVM * java_vm);
Index: vm/include/open/vm_util.h
===================================================================
48,49d47
< VMEXPORT void vm_exit(int exit_code);
<
61c59
< extern struct JNIEnv_Internal *jni_native_intf;
---
> extern JNIEnv * jni_native_intf;
164,174d161
< class StaticInitializer {
< public:
< StaticInitializer() {
< apr_initialize();
< }
< ~StaticInitializer() {
< apr_terminate2();
< }
< };
<
<
Index: vm/include/open/jthread.h
===================================================================
83,85c83,85
< IDATA jthread_create(JNIEnv *env, jthread thread, jthread_threadattr_t *attrs);
< IDATA jthread_create_with_function(JNIEnv *env, jthread thread, jthread_threadattr_t *attrs, jvmtiStartFunction proc, const void* arg);
< IDATA jthread_attach(JNIEnv* env, jthread thread);
---
> IDATA jthread_create(JavaVM * java_vm, jthread thread, jthread_threadattr_t *attrs);
> IDATA jthread_create_with_function(JavaVM * java_vm, jthread thread, jthread_threadattr_t *attrs, jvmtiStartFunction proc, const void* arg);
> IDATA jthread_attach(JNIEnv ** p_jni_env, JavaVM * java_vm, jobject group, char * name, jboolean daemon);
124,142d123
< /**
< * Sets the daemon attribute for the thread.
< *
< * JVM exits when the only threads running are all daemon threads.
< *
< * @param[in] thread those attribute is set
< * @param[in] on daemon off or on
< * @sa java.lang.Thread.setDaemon()
< */
< IDATA jthread_set_daemon(jthread thread, jboolean on);
<
< /**
< * Returns true if the threadis daemon.
< *
< * @param[in] thread those attribute is read
< * @sa java.lang.Thread.isDaemon()
< */
< jboolean jthread_is_daemon(jthread thread);
<
Index: vm/include/open/vm.h
===================================================================
718,720d717
< // Exit and perform the necessary cleanup.
< VMEXPORT void vm_exit(int exit_code);
<
Index: vm/include/open/hythread_ext.h
===================================================================
149c149,152
< void VMCALL hythread_init (hythread_library_t lib);
---
> void VMCALL hythread_init(hythread_library_t lib);
> void VMCALL hythread_shutdown();
> IDATA VMCALL hythread_lib_create(hythread_library_t * lib);
> void VMCALL hythread_lib_destroy(hythread_library_t lib);
156,157c159,162
< IDATA VMCALL hythread_attach_to_group(hythread_t *handle, hythread_group_t group);
< IDATA hythread_create_with_group(hythread_t *ret_thread, hythread_group_t group, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data);
---
> IDATA VMCALL hythread_create_ex(hythread_t *ret_thread, UDATA stacksize, UDATA priority, UDATA suspend, UDATA daemon, hythread_entrypoint_t func, void *data);
> IDATA VMCALL hythread_attach_ex(hythread_t *handle, hythread_library_t lib);
> IDATA VMCALL hythread_attach_to_group(hythread_t *handle, hythread_library_t lib, hythread_group_t group);
> IDATA hythread_create_with_group(hythread_t *ret_thread, hythread_group_t group, UDATA stacksize, UDATA priority, UDATA suspend, UDATA daemon, hythread_entrypoint_t func, void *data);
165c170
< IDATA VMCALL hythread_struct_init(hythread_t *ret_thread, hythread_group_t group);
---
> IDATA VMCALL hythread_struct_init(hythread_t *ret_thread);
192,196c197,201
< IDATA hythread_is_suspend_enabled();
< void hythread_suspend_enable();
< void hythread_suspend_disable();
< void hythread_safe_point();
< IDATA VMCALL hythread_suspend_other(hythread_t thread);
---
> IDATA hythread_is_suspend_enabled();
> void hythread_suspend_enable();
> void hythread_suspend_disable();
> void hythread_safe_point();
> IDATA VMCALL hythread_suspend_other(hythread_t thread);
234c239
< IDATA hysem_create(hysem_t *sem, UDATA initial_count, UDATA max_count);
---
> IDATA hysem_create(hysem_t *sem, UDATA initial_count, UDATA max_count);
238c243
< IDATA hysem_set(hysem_t sem, IDATA count);
---
> IDATA hysem_set(hysem_t sem, IDATA count);
245,249c250,254
< IDATA hymutex_create (hymutex_t *mutex, UDATA flags);
< IDATA hymutex_lock(hymutex_t mutex);
< IDATA hymutex_trylock (hymutex_t mutex);
< IDATA hymutex_unlock (hymutex_t mutex);
< IDATA hymutex_destroy (hymutex_t mutex);
---
> IDATA hymutex_create (hymutex_t *mutex, UDATA flags);
> IDATA hymutex_lock(hymutex_t mutex);
> IDATA hymutex_trylock (hymutex_t mutex);
> IDATA hymutex_unlock (hymutex_t mutex);
> IDATA hymutex_destroy (hymutex_t mutex);
285,290d289
<
< /**
< * Returns non-zero if thread is interrupted.
< *
< * @param[in] thread those attribute is read
< */
292a292
> int VMCALL hythread_is_daemon(hythread_t thread) ;
Index: vm/include/jni.h
===================================================================
1c1
< /*
---
> /*
1689a1689,1694
> typedef struct JavaVMAttachArgs {
> jint version;
> char *name;
> jobject group;
> } JavaVMAttachArgs;
>
1695c1700
< jint (JNICALL *DestroyVM)(JavaVM*);
---
> jint (JNICALL *DestroyJavaVM)(JavaVM*);
1709,1710c1714,1715
< jint DestroyVM() {
< return functions->DestroyVM(this);
---
> jint DestroyJavaVM() {
> return functions->DestroyJavaVM(this);
1735c1741,1748
< JNIEXPORT jint JNICALL JNI_CreateJavaVM(JavaVM **p_vm, JNIEnv **p_env, void *vm_args);
---
> JNIEXPORT jint JNICALL JNI_GetDefaultJavaVMInitArgs(void * vm_args);
>
> JNIEXPORT jint JNICALL JNI_GetCreatedJavaVMs(JavaVM ** vmBuf,
> jsize bufLen,
> jsize * nVMs);
>
> JNIEXPORT jint JNICALL JNI_CreateJavaVM(JavaVM ** p_vm, JNIEnv ** p_env,
> void * vm_args);
Index: vm/include/interpreter_imports.h
===================================================================
33c33
< VMEXPORT struct JNIEnv_Internal* get_jni_native_intf();
---
> VMEXPORT JNIEnv * get_jni_native_intf();
Index: vm/port/src/lil/em64t/pim/stack_iterator_em64t.cpp
===================================================================
217a218
> Global_Env *env = VM_Global_State::loader_env;
219c220
< si->cci = vm_methods->find((NativeCodePtr)regs->rip, is_ip_past);
---
> si->cci = env->vm_methods->find((NativeCodePtr)regs->rip, is_ip_past);
259c260,262
< si->cci = vm_methods->find(si_get_ip(si), true);
---
>
> Global_Env *env = VM_Global_State::loader_env;
> si->cci = env->vm_methods->find(si_get_ip(si), true);
Index: vm/port/src/lil/lil.cpp
===================================================================
1311c1311
< for(j=0; jnum_locals; j++) c->std_place_types[j] = LT_Void;
---
> for(j=0; jnum_std_places; j++) c->std_place_types[j] = LT_Void;
Index: vm/port/src/lil/ia32/pim/stack_iterator_ia32.cpp
===================================================================
22c22
<
---
> #include "environment.h"
251c251,252
< res->cci = vm_methods->find((NativeCodePtr)regs->eip, is_ip_past);
---
> Global_Env *env = VM_Global_State::loader_env;
> res->cci = env->vm_methods->find((NativeCodePtr)regs->eip, is_ip_past);
297c298,299
< si->cci = vm_methods->find(si_get_ip(si), true);
---
> Global_Env *env = VM_Global_State::loader_env;
> si->cci = env->vm_methods->find(si_get_ip(si), true);
Index: vm/port/src/lil/ipf/pim/lil_code_generator_ipf.cpp
===================================================================
2091c2091
< static StaticInitializer lil_initializer;
---
> // TODO: we have to get rid of memory pool in static area due to initialization problems
Index: vm/port/src/lil/ipf/pim/stack_iterator_ipf.cpp
===================================================================
512a513
> Global_Env *env = VM_Global_State::loader_env;
514c515
< si->cci = vm_methods->find(si_get_ip(si));
---
> si->cci = env->vm_methods->find(si_get_ip(si));
Index: vm/vmi/src/vmi.cpp
===================================================================
202c203
< (PropertiesHandle)&VM_Global_State::loader_env->properties, key));
---
> (PropertiesHandle)VM_Global_State::loader_env->properties, key));
213c214
< add_pair_to_properties(VM_Global_State::loader_env->properties, key, value);
---
> add_pair_to_properties(*VM_Global_State::loader_env->properties, key, value);
219,220c220,221
< Properties &p = VM_Global_State::loader_env->properties;
< Properties::Iterator *iter = p.getIterator();
---
> Properties *p = VM_Global_State::loader_env->properties;
> Properties::Iterator *iter = p->getIterator();
234,235c235,236
< Properties &p = VM_Global_State::loader_env->properties;
< Properties::Iterator *iter = p.getIterator();
---
> Properties *p = VM_Global_State::loader_env->properties;
> Properties::Iterator *iter = p->getIterator();
Index: vm/vmcore/include/properties.h
===================================================================
281,295d280
< #ifdef USE_MEM_MANAGER_FOR_ALLOCATION
< public:
< void *operator new(size_t sz, tl::MemoryPool& m) {
< return m.alloc(sz);
< }
< void operator delete(void *obj, tl::MemoryPool& m){
< //do nothing
< };
< void *operator new(size_t sz) {
< return m_malloc(sz);
< }
< void operator delete(void *obj){
< m_free(obj);
< };
< #endif
Index: vm/vmcore/include/jni_utils.h
===================================================================
24a25
> #include "environment.h"
41d41
< VMEXPORT void class_loader_set_system_class_loader(ClassLoaderHandle);
96a97,99
> JavaVM * jni_get_java_vm(JNIEnv * jni_env);
> Global_Env * jni_get_vm_env(JNIEnv * jni_env);
>
Index: vm/vmcore/include/init.h
===================================================================
27,29c27,30
< bool vm_init(Global_Env *env);
< int run_java_main(char *classname, char **j_argv, int j_argc, Global_Env *p_env);
< int run_main_platform_specific(char *classname, char **j_argv, int j_argc, Global_Env *p_env);
---
> jint vm_init1(JavaVM_Internal * java_vm, JavaVMInitArgs * vm_arguments);
> jint vm_init2(JNIEnv_Internal * jni_env);
> jint vm_destroy(JavaVM_Internal * java_vm, jthread java_thread);
> void vm_exit(int exit_code);
31,32d31
< JavaVMInitArgs* parse_cmd_arguments(int argc, char *argv[], char **class_name, char **jar_file, int *p_java_arg_num);
< void clear_vm_arguments(JavaVMInitArgs* vm_args);
39,42d37
< void create_vm(Global_Env *p_env, JavaVMInitArgs* vm_arguments);
< void destroy_vm(Global_Env *p_env);
< extern Global_Env env;
<
Index: vm/vmcore/include/version_svn_tag.h
===================================================================
20c20
< #define VERSION_SVN_TAG "449396"
---
> #define VERSION_SVN_TAG "449887"
Index: vm/vmcore/include/vm_threads.h
===================================================================
32a33,34
> #include
>
40a44
> #include "jni_direct.h"
68,70c72,81
< // FIXME: workaround for strange bug. If this line is removed Visual Stidio
< // has corrupted list of modules and no debug info at all.
< void* system_private_data;
---
> /**
> * Memory pool where this structure is allocated.
> * This pool should be used by current thread for memory allocations.
> */
> apr_pool_t * pool;
>
> /**
> * JNI environment associated with this thread.
> */
> JNIEnv_Internal * jni_env;
Index: vm/vmcore/include/thread_manager.h
===================================================================
30,36d29
<
< void vm_thread_shutdown();
< void vm_thread_init(Global_Env *p_env);
<
< void vm_thread_attach();
< void vm_thread_detach();
<
38c31
< VM_thread * get_a_thread_block();
---
> VM_thread * get_a_thread_block(JavaVM_Internal * java_vm);
Index: vm/vmcore/include/environment.h
===================================================================
24c24,30
< #include "tl/memory_pool.h"
---
> #include
> #include
>
> #include "open/hythread.h"
> #include "open/compmgr.h"
> #include "open/em_vm.h"
>
29,30c35
< #include "open/compmgr.h"
< #include "open/em_vm.h"
---
> #include "method_lookup.h"
37,39c42,43
< public:
< tl::MemoryPool& mem_pool; // memory pool
< String_Pool string_pool; // string table
---
> public:
> apr_pool_t* mem_pool; // memory pool
41d44
< JavaVMInitArgs vm_arguments;
43c46
< Properties& properties;
---
> Properties* properties;
48a52,57
> Method_Lookup_Table* vm_methods;
> hythread_library_t hythread_lib;
> String_Pool string_pool; // string table
> JavaVMInitArgs vm_arguments;
>
>
128a138
> Class* java_lang_ThreadDeathError_Class;
139c149
<
---
> ObjectHandle java_lang_ThreadDeathError;
164a175,177
> // Keeps uncaught exception for the thread which is destroying VM.
> jthrowable uncaught_exception;
>
174c188
<
---
>
182,187c196,205
< //
< // constructor
< //
< Global_Env(tl::MemoryPool& mm, Properties& prop);
< // function is used instead of destructor to uninitialize manually
< void EnvClearInternals();
---
> Global_Env(apr_pool_t * pool);
> ~Global_Env();
>
> void * operator new(size_t size, apr_pool_t * pool) {
> return apr_palloc(pool, sizeof(Global_Env));
> }
>
> void operator delete(void *) {}
>
> void operator delete(void * mem, apr_pool_t * pool) {};
Index: vm/vmcore/include/natives_support.h
===================================================================
62c62
< * @return Returns true if initialized successfully.
---
> * @return Returns JNI_OK if initialized successfully.
64c64
< bool
---
> jint
Index: vm/vmcore/include/method_lookup.h
===================================================================
88,90d87
< VMEXPORT extern Method_Lookup_Table *vm_methods;
<
<
Index: vm/vmcore/include/jni_direct.h
===================================================================
28c25,27
< #include "jni.h"
---
> #include
> #include
>
30d28
< #include "Class.h"
32,33c30,31
< struct _jfieldID : public Field {
< };
---
> #include "jni.h"
> #include "Class.h"
35c33,34
< VMEXPORT jint JNICALL GetVersion(JNIEnv *env);
---
> typedef struct JavaVM_Internal JavaVM_Internal;
> typedef struct JNIEnv_Internal JNIEnv_Internal;
38,44c37,39
< JavaVM_Internal(const JNIInvokeInterface_ *_functions,
< Global_Env *_vm_env,
< void *_reserved) : vm_env(_vm_env), reserved(_reserved)
< {
< functions = _functions;
< }
< Global_Env* vm_env;
---
> apr_pool_t * pool;
> Global_Env * vm_env;
> APR_RING_ENTRY(JavaVM_Internal) link;
49,54d43
< JNIEnv_Internal(const JNINativeInterface_ *_functions,
< JavaVM_Internal *_vm,
< void *_reserved0) : vm(_vm), reserved0(_reserved0)
< {
< functions = _functions;
< }
59c48,49
< void jni_init();
---
> struct _jfieldID : public Field {
> };
608c598
< VMEXPORT jint JNICALL DestroyVM(JavaVM*);
---
> VMEXPORT jint JNICALL DestroyJavaVM(JavaVM*);
Index: vm/vmcore/src/jni/jni.cpp
===================================================================
24a24,32
> #include
> #include
> #include
>
> #include "open/types.h"
> #include "open/hythread.h"
> #include "open/jthread.h"
> #include "open/vm_util.h"
>
31,32d38
< #include "open/types.h"
< #include "open/vm_util.h"
34,35d39
< #include "open/jthread.h"
<
59a60
> jint JNICALL GetVersion(JNIEnv *);
66a68
>
335c337
< DestroyVM,
---
> DestroyJavaVM,
342,343c344
< AttachCurrentThreadAsDaemon,
<
---
> AttachCurrentThreadAsDaemon
346c347,391
< static JavaVM_Internal java_vm = JavaVM_Internal(&java_vm_vtable, NULL, (void *)0x1234abcd);
---
> /**
> * List of all running in the current process.
> */
> APR_RING_HEAD(JavaVM_Internal_T, JavaVM_Internal) GLOBAL_VMS;
>
> /**
> * Memory pool to keep global data.
> */
> apr_pool_t * GLOBAL_POOL = NULL;
>
> /**
> * Used to synchronize VM creation and destruction.
> */
> apr_thread_mutex_t * GLOBAL_LOCK = NULL;
>
> static jboolean & get_init_status() {
> static jboolean init_status = JNI_FALSE;
> return init_status;
> }
> /**
> * Initializes JNI module.
> * Should be called before creating first VM.
> */
> static jint jni_init()
> {
> jint status;
>
> if (get_init_status() == JNI_FALSE) {
> status = apr_initialize();
> if (status != APR_SUCCESS) return JNI_ERR;
>
> if (apr_atomic_cas32((volatile apr_uint32_t *)&get_init_status(), JNI_TRUE, JNI_FALSE) == JNI_FALSE) {
> APR_RING_INIT(&GLOBAL_VMS, JavaVM_Internal, link);
> status = apr_pool_create(&GLOBAL_POOL, 0);
> if (status != APR_SUCCESS) return JNI_ERR;
>
> status = apr_thread_mutex_create(&GLOBAL_LOCK, APR_THREAD_MUTEX_DEFAULT, GLOBAL_POOL);
> if (status != APR_SUCCESS) {
> apr_pool_destroy(GLOBAL_POOL);
> return JNI_ERR;
> }
> }
> }
> return JNI_OK;
> }
348c393
< static JNIEnv_Internal jni_env = JNIEnv_Internal(&jni_vtable, &java_vm, (void *)0x1234abcd);
---
> /* BEGIN: List of directly exported functions. */
350c395,403
< struct JNIEnv_Internal *jni_native_intf = &jni_env;
---
> JNIEXPORT jint JNICALL JNI_GetDefaultJavaVMInitArgs(void * args)
> {
> // TODO: current implementation doesn't support JDK1_1InitArgs.
> if (((JavaVMInitArgs *)args)->version == JNI_VERSION_1_1) {
> return JNI_EVERSION;
> }
> ((JavaVMInitArgs *)args)->version = JNI_VERSION_1_4;
> return JNI_OK;
> }
352c405,407
< void jni_init()
---
> JNIEXPORT jint JNICALL JNI_GetCreatedJavaVMs(JavaVM ** vmBuf,
> jsize bufLen,
> jsize * nVMs)
354,355d408
< java_vm.vm_env = VM_Global_State::loader_env;
< } //jni_init
356a410,528
> jint status = jni_init();
> if (status != JNI_OK) {
> return status;
> }
>
> apr_thread_mutex_lock(GLOBAL_LOCK);
>
> *nVMs = 0;
> if (!APR_RING_EMPTY(&GLOBAL_VMS, JavaVM_Internal, link)) {
> JavaVM_Internal * current_vm = APR_RING_FIRST(&GLOBAL_VMS);
> while (current_vm) {
> if (*nVMs < bufLen) {
> vmBuf[*nVMs] = (JavaVM *)current_vm;
> }
> ++(*nVMs);
> current_vm = APR_RING_NEXT(current_vm, link);
> }
>
> }
> apr_thread_mutex_unlock(GLOBAL_LOCK);
> return JNI_OK;
> }
>
>
> JNIEXPORT jint JNICALL JNI_CreateJavaVM(JavaVM ** p_vm, JNIEnv ** p_jni_env,
> void * args) {
> JavaVMInitArgs * vm_args;
> apr_pool_t * vm_global_pool;
> JNIEnv_Internal * jni_env;
> JavaVM_Internal * java_vm;
> Global_Env * vm_env;
> jint status;
>
>
> status = jni_init();
> if (status != JNI_OK) return status;
>
> apr_thread_mutex_lock(GLOBAL_LOCK);
>
> // TODO: only one VM instance can be created in the process address space.
> if (!APR_RING_EMPTY(&GLOBAL_VMS, JavaVM_Internal, link)) {
> status = JNI_ERR;
> goto done;
> }
>
> // Create global memory pool.
> status = apr_pool_create(&vm_global_pool, NULL);
> if (status != APR_SUCCESS) {
> TRACE2("jni", "Unable to create memory pool for VM");
> status = JNI_ENOMEM;
> goto done;
> }
>
> // TODO: current implementation doesn't support JDK1_1InitArgs.
> if (((JavaVMInitArgs *)args)->version == JNI_VERSION_1_1) {
> status = JNI_EVERSION;
> goto done;
> }
>
> vm_args = (JavaVMInitArgs *)args;
> // Create JavaVM_Internal.
> java_vm = (JavaVM_Internal *) apr_palloc(vm_global_pool, sizeof(JavaVM_Internal));
> if (java_vm == NULL) {
> status = JNI_ENOMEM;
> goto done;
> }
>
> // Create Global_Env.
> vm_env = new(vm_global_pool) Global_Env(vm_global_pool);
> if (vm_env == NULL) {
> status = JNI_ENOMEM;
> goto done;
> }
>
> java_vm->functions = &java_vm_vtable;
> java_vm->pool = vm_global_pool;
> java_vm->vm_env = vm_env;
> java_vm->reserved = (void *)0x1234abcd;
> *p_vm = java_vm;
>
> status = vm_init1(java_vm, vm_args);
> if (status != JNI_OK) {
> goto done;
> }
>
> // Attaches main thread.
> status = jthread_attach((JNIEnv **)&jni_env, java_vm, NULL, "main", JNI_FALSE);
> if (status != TM_ERROR_NONE) {
> status = JNI_ERR;
> goto done;
> }
> assert(jthread_self() != NULL);
> *p_jni_env = jni_env;
>
> // Send VM start event. JNI services are available now.
> // JVMTI services permited in the start phase are available as well.
> jvmti_send_vm_start_event(vm_env, jni_env);
>
> status = vm_init2(jni_env);
> if (status != JNI_OK) {
> goto done;
> }
>
> // Send VM init event.
> jvmti_send_vm_init_event(vm_env);
>
> // Thread start event for the main thread should be sent after VMInit callback has finished.
> jvmti_send_thread_start_end_event(1);
>
> // Register created VM.
> APR_RING_INSERT_TAIL(&GLOBAL_VMS, java_vm, JavaVM_Internal, link);
>
> status = JNI_OK;
> done:
> apr_thread_mutex_unlock(GLOBAL_LOCK);
> return status;
> }
>
> /* END: List of directly exported functions. */
616,617d787
< // tmn_suspend_disable(); //---------------------------------v
< fprintf(stderr, "JNI.ExceptionDescribe: %s:\n", exn_get_name());
619d788
< // tmn_suspend_enable(); //---------------------------------^
646,647c815
< fprintf(stderr, "\nFATAL error occurred in a JNI native method:\n\t%s\n", msg);
< vm_exit(109);
---
> DIE("\nFATAL error occurred in a JNI native method:\n\t" << msg);
1257a1426,1433
> /* BEGIN: Invocation API functions. */
>
> VMEXPORT jint JNICALL DestroyJavaVM(JavaVM * vm)
> {
> jthread java_thread;
> JavaVM_Internal * java_vm;
> JNIEnv * jni_env;
> jint status;
1259,1260c1435
< VMEXPORT jint JNICALL JNI_CreateJavaVM(JavaVM **p_vm, JNIEnv **p_env, void *vm_args) {
< static int called = 0; // this function can only be called once for now;
---
> TRACE2("jni", "DestroyJavaVM called");
1262,1271c1437,1480
< init_log_system();
< TRACE2("jni", "CreateJavaVM called");
< if (called) {
< WARN("Java Invoke :: multiple VM instances are not implemented");
< ASSERT(0, "Not implemented");
< return JNI_ERR;
< } else {
< create_vm(&env, (JavaVMInitArgs *)vm_args);
< *p_env = &jni_env;
< *p_vm = jni_env.vm;
---
> java_vm = (JavaVM_Internal *) vm;
>
> java_thread = jthread_self();
> if (java_thread == NULL) {
> status = jthread_attach((JNIEnv **)&jni_env, java_vm, NULL, "destroy", JNI_FALSE);
> if (status != TM_ERROR_NONE) return JNI_ERR;
> java_thread = jthread_self();
> }
> assert(java_thread != NULL);
>
> apr_thread_mutex_lock(GLOBAL_LOCK);
>
> status = vm_destroy(java_vm, java_thread);
> if (status != JNI_OK) return status;
>
> APR_RING_REMOVE(java_vm, link);
>
> // Destroy VM environment.
> delete java_vm->vm_env;
>
> // Destroy VM pool.
> apr_pool_destroy(java_vm->pool);
>
> // TODO: Destroy globals if it is last VM.
>
> apr_thread_mutex_unlock(GLOBAL_LOCK);
>
> // TODO: error code should be returned until
> // VM cleanups its internals properly.
> return JNI_ERR;
> }
>
> VMEXPORT jint JNICALL AttachCurrentThread(JavaVM * vm, void ** p_jni_env, void * args)
> {
> char * name;
> jobject group;
> JNIEnv * jni_env;
> JavaVMAttachArgs * jni_1_2_args;
> IDATA status;
>
> TRACE2("jni", "AttachCurrentThread called");
>
> if (jthread_self()) {
> *p_jni_env = jthread_get_JNI_env(jthread_self());
1274d1482
< }
1275a1484,1485
> name = NULL;
> group = NULL;
1277,1281c1487,1505
< VMEXPORT jint JNICALL DestroyVM(JavaVM*)
< {
< TRACE2("jni", "DestroyVM called");
< destroy_vm(&env);
< return JNI_OK;
---
> if (args != NULL) {
> jni_1_2_args = (JavaVMAttachArgs *) args;
> if (jni_1_2_args->version != JNI_VERSION_1_2) {
> return JNI_EVERSION;
> }
> name = jni_1_2_args->name;
> group = jni_1_2_args->group;
> }
>
> // Attach current thread as non-daemon.
> status = jthread_attach(&jni_env, vm, group, name, JNI_FALSE);
> assert(jthread_self() != NULL);
> *p_jni_env = jni_env;
>
> // Send thread start event.
> // TODO: Thread start event should be sent before its initial method executes.
> jvmti_send_thread_start_end_event(1);
>
> return status == TM_ERROR_NONE ? JNI_OK : JNI_ERR;
1284c1508
< VMEXPORT jint JNICALL AttachCurrentThread(JavaVM* vm, void** penv, void* UNREF args)
---
> VMEXPORT jint JNICALL AttachCurrentThreadAsDaemon(JavaVM * vm, void ** p_jni_env, void * args)
1286,1290c1510,1544
< TRACE2("jni", "AttachCurrentThread called");
< if (NULL == p_TLS_vmthread)
< WARN("WARNING!! Attaching deattached thread is not implemented!!\n");
< GetEnv(vm, penv, JNI_VERSION_1_4);
< return JNI_ERR;
---
> char * name;
> jobject group;
> JNIEnv * jni_env;
> JavaVMAttachArgs * jni_1_2_args;
> IDATA status;
>
> TRACE2("jni", "AttachCurrentThreadAsDaemon called");
>
> if (jthread_self()) {
> *p_jni_env = jthread_get_JNI_env(jthread_self());
> return JNI_OK;
> }
>
> name = NULL;
> group = NULL;
>
> if (args != NULL) {
> jni_1_2_args = (JavaVMAttachArgs *) args;
> if (jni_1_2_args->version != JNI_VERSION_1_2) {
> return JNI_EVERSION;
> }
> name = jni_1_2_args->name;
> group = jni_1_2_args->group;
> }
>
> // Attach current thread as non-daemon.
> status = jthread_attach(&jni_env, vm, group, name, JNI_TRUE);
> assert(jthread_self() != NULL);
> *p_jni_env = jni_env;
>
> // Send thread start event.
> // TODO: Thread start event should be sent before its initial method executes.
> jvmti_send_thread_start_end_event(1);
>
> return status == TM_ERROR_NONE ? JNI_OK : JNI_ERR;
1293c1547
< VMEXPORT jint JNICALL DetachCurrentThread(JavaVM*)
---
> VMEXPORT jint JNICALL DetachCurrentThread(JavaVM * vm)
1295,1297c1549,1559
< WARN("Java Invoke :: DetachCurrentThread not implemented");
< ASSERT(0, "Not implemented");
< return JNI_ERR;
---
> jthread java_thread;
> IDATA status;
>
> java_thread = jthread_self();
> if (java_thread == NULL) return JNI_EDETACHED;
>
> status = jthread_detach(java_thread);
>
> // Send thread end event.
> jvmti_send_thread_start_end_event(0);
> return status == TM_ERROR_NONE ? JNI_OK : JNI_ERR;
1300c1562
< VMEXPORT jint JNICALL GetEnv(JavaVM* vm, void** penv, jint ver)
---
> VMEXPORT jint JNICALL GetEnv(JavaVM * vm, void ** penv, jint ver)
1301a1564,1565
> VM_thread * vm_thread;
>
1305,1306c1569,1570
< if (p_TLS_vmthread == NULL)
< return JNI_EDETACHED;
---
> vm_thread = p_TLS_vmthread;
> if (vm_thread == NULL) return JNI_EDETACHED;
1308,1310c1572,1573
< if ((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == JVMTI_VERSION_INTERFACE_JNI)
< switch (ver)
< {
---
> if ((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == JVMTI_VERSION_INTERFACE_JNI) {
> switch (ver) {
1314c1577
< *penv = (void*)jni_native_intf;
---
> *penv = (void*)vm_thread->jni_env;
1317c1580
< else if((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == JVMTI_VERSION_INTERFACE_JVMTI)
---
> } else if((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == JVMTI_VERSION_INTERFACE_JVMTI) {
1319,1320c1582
< else if((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == 0x10000000)
< {
---
> } else if((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == 0x10000000) {
1322,1324c1584
< }
< else if((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == 0x20000000)
< {
---
> } else if((ver & JVMTI_VERSION_MASK_INTERFACE_TYPE) == 0x20000000) {
1326,1328c1586
< }
< else
< {
---
> } else {
1336,1341c1594
< VMEXPORT jint JNICALL AttachCurrentThreadAsDaemon(JavaVM*, void** UNREF penv, void* UNREF args)
< {
< WARN("Java Invoke :: AttachCurrentThreadAsDaemon not implemented");
< ASSERT(0, "Not implemented");
< return JNI_ERR;
< }
---
> /* END: Invocation API functions. */
1386c1639
<
---
> // TODO: should return error code instead of exiting.
1390,1391d1642
< fprintf(stderr, "Error initializing java machine\n");
< fprintf(stderr, "Uncaught and unexpected exception\n");
1393c1644
< vm_exit(1);
---
> DIE("Error initializing java machine\n");
1397,1399c1648,1650
< void global_object_handles_init(){
< Global_Env *env = VM_Global_State::loader_env;
< JNIEnv_Internal *jenv = jni_native_intf;
---
> void global_object_handles_init(JNIEnv_Internal * jni_env) {
>
> Global_Env * vm_env = jni_get_vm_env(jni_env);
1424,1434c1675,1685
< gh_jlc->object = struct_Class_to_java_lang_Class(env->JavaLangClass_Class);
< gh_jls->object = struct_Class_to_java_lang_Class(env->JavaLangString_Class);
< gh_jlcloneable->object = struct_Class_to_java_lang_Class(env->java_lang_Cloneable_Class);
< gh_aoboolean->object = struct_Class_to_java_lang_Class(env->ArrayOfBoolean_Class);
< gh_aobyte->object = struct_Class_to_java_lang_Class(env->ArrayOfByte_Class);
< gh_aochar->object = struct_Class_to_java_lang_Class(env->ArrayOfChar_Class);
< gh_aoshort->object = struct_Class_to_java_lang_Class(env->ArrayOfShort_Class);
< gh_aoint->object = struct_Class_to_java_lang_Class(env->ArrayOfInt_Class);
< gh_aolong->object = struct_Class_to_java_lang_Class(env->ArrayOfLong_Class);
< gh_aofloat->object = struct_Class_to_java_lang_Class(env->ArrayOfFloat_Class);
< gh_aodouble->object = struct_Class_to_java_lang_Class(env->ArrayOfDouble_Class);
---
> gh_jlc->object = struct_Class_to_java_lang_Class(vm_env->JavaLangClass_Class);
> gh_jls->object = struct_Class_to_java_lang_Class(vm_env->JavaLangString_Class);
> gh_jlcloneable->object = struct_Class_to_java_lang_Class(vm_env->java_lang_Cloneable_Class);
> gh_aoboolean->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfBoolean_Class);
> gh_aobyte->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfByte_Class);
> gh_aochar->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfChar_Class);
> gh_aoshort->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfShort_Class);
> gh_aoint->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfInt_Class);
> gh_aolong->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfLong_Class);
> gh_aofloat->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfFloat_Class);
> gh_aodouble->object = struct_Class_to_java_lang_Class(vm_env->ArrayOfDouble_Class);
1436,1444c1687,1695
< Class *preload_class(Global_Env* env, const char *classname);
< Class* jlboolean = preload_class(env, "java/lang/Boolean");
< Class* jlbyte = preload_class(env, "java/lang/Byte");
< Class* jlchar = preload_class(env, "java/lang/Character");
< Class* jlshort = preload_class(env, "java/lang/Short");
< Class* jlint = preload_class(env, "java/lang/Integer");
< Class* jllong = preload_class(env, "java/lang/Long");
< Class* jlfloat = preload_class(env, "java/lang/Float");
< Class* jldouble = preload_class(env, "java/lang/Double");
---
> Class *preload_class(Global_Env* vm_env, const char *classname);
> Class* jlboolean = preload_class(vm_env, "java/lang/Boolean");
> Class* jlbyte = preload_class(vm_env, "java/lang/Byte");
> Class* jlchar = preload_class(vm_env, "java/lang/Character");
> Class* jlshort = preload_class(vm_env, "java/lang/Short");
> Class* jlint = preload_class(vm_env, "java/lang/Integer");
> Class* jllong = preload_class(vm_env, "java/lang/Long");
> Class* jlfloat = preload_class(vm_env, "java/lang/Float");
> Class* jldouble = preload_class(vm_env, "java/lang/Double");
1455c1706
< h_jlt->object= struct_Class_to_java_lang_Class(env->java_lang_Throwable_Class);
---
> h_jlt->object= struct_Class_to_java_lang_Class(vm_env->java_lang_Throwable_Class);
1459c1710
< gid_throwable_traceinfo = jenv->GetFieldID((jclass)h_jlt, "vm_stacktrace", "[J");
---
> gid_throwable_traceinfo = jni_env->GetFieldID((jclass)h_jlt, "vm_stacktrace", "[J");
1462,1469c1713,1720
< gid_boolean_value = jenv->GetFieldID((jclass)gh_jlboolean, "value", "Z");
< gid_byte_value = jenv->GetFieldID((jclass)gh_jlbyte, "value", "B");
< gid_char_value = jenv->GetFieldID((jclass)gh_jlchar, "value", "C");
< gid_short_value = jenv->GetFieldID((jclass)gh_jlshort, "value", "S");
< gid_int_value = jenv->GetFieldID((jclass)gh_jlint, "value", "I");
< gid_long_value = jenv->GetFieldID((jclass)gh_jllong, "value", "J");
< gid_float_value = jenv->GetFieldID((jclass)gh_jlfloat, "value", "F");
< gid_double_value = jenv->GetFieldID((jclass)gh_jldouble, "value", "D");
---
> gid_boolean_value = jni_env->GetFieldID((jclass)gh_jlboolean, "value", "Z");
> gid_byte_value = jni_env->GetFieldID((jclass)gh_jlbyte, "value", "B");
> gid_char_value = jni_env->GetFieldID((jclass)gh_jlchar, "value", "C");
> gid_short_value = jni_env->GetFieldID((jclass)gh_jlshort, "value", "S");
> gid_int_value = jni_env->GetFieldID((jclass)gh_jlint, "value", "I");
> gid_long_value = jni_env->GetFieldID((jclass)gh_jllong, "value", "J");
> gid_float_value = jni_env->GetFieldID((jclass)gh_jlfloat, "value", "F");
> gid_double_value = jni_env->GetFieldID((jclass)gh_jldouble, "value", "D");
1472c1723
< gid_doubleisNaN = jenv->GetStaticMethodID((jclass)gh_jldouble, "isNaN", "(D)Z");
---
> gid_doubleisNaN = jni_env->GetStaticMethodID((jclass)gh_jldouble, "isNaN", "(D)Z");
1474,1478c1725,1730
< gid_stringinit = jenv->GetMethodID((jclass)gh_jls, "", "([C)V");
< gid_string_field_value = jenv->GetFieldID((jclass)gh_jls, "value", "[C");
< if(env->strings_are_compressed)
< gid_string_field_bvalue = jenv->GetFieldID((jclass)gh_jls, "bvalue", "[B");
< assert(hythread_is_suspend_enabled());
---
> gid_stringinit = jni_env->GetMethodID((jclass)gh_jls, "", "([C)V");
> gid_string_field_value = jni_env->GetFieldID((jclass)gh_jls, "value", "[C");
>
> if (vm_env->strings_are_compressed) {
> gid_string_field_bvalue = jni_env->GetFieldID((jclass)gh_jls, "bvalue", "[B");
> }
1480,1481c1732,1733
< gid_string_field_offset = jenv->GetFieldID((jclass)gh_jls, "offset", "I");
< gid_string_field_count = jenv->GetFieldID((jclass)gh_jls, "count", "I");
---
> gid_string_field_offset = jni_env->GetFieldID((jclass)gh_jls, "offset", "I");
> gid_string_field_count = jni_env->GetFieldID((jclass)gh_jls, "count", "I");
1495c1747
< void unsafe_global_object_handles_init(){
---
> void unsafe_global_object_handles_init(JNIEnv_Internal * jni_env) {
1498d1749
< JNIEnv_Internal *jenv = jni_native_intf;
1500,1501c1751,1752
< jfieldID POSITIVE_INFINITY_id = jenv->GetStaticFieldID((jclass)gh_jldouble, "POSITIVE_INFINITY", "D");
< gc_double_POSITIVE_INFINITY = jenv->GetStaticDoubleField((jclass)gh_jldouble, POSITIVE_INFINITY_id);
---
> jfieldID POSITIVE_INFINITY_id = jni_env->GetStaticFieldID((jclass)gh_jldouble, "POSITIVE_INFINITY", "D");
> gc_double_POSITIVE_INFINITY = jni_env->GetStaticDoubleField((jclass)gh_jldouble, POSITIVE_INFINITY_id);
1505,1506c1756,1757
< jfieldID NEGATIVE_INFINITY_id = jenv->GetStaticFieldID((jclass)gh_jldouble, "NEGATIVE_INFINITY", "D");
< gc_double_NEGATIVE_INFINITY = jenv->GetStaticDoubleField((jclass)gh_jldouble, NEGATIVE_INFINITY_id);
---
> jfieldID NEGATIVE_INFINITY_id = jni_env->GetStaticFieldID((jclass)gh_jldouble, "NEGATIVE_INFINITY", "D");
> gc_double_NEGATIVE_INFINITY = jni_env->GetStaticDoubleField((jclass)gh_jldouble, NEGATIVE_INFINITY_id);
Index: vm/vmcore/src/jni/jni_utils.cpp
===================================================================
86c86
< void class_loader_load_native_lib( const char* lib,
---
> void class_loader_load_native_lib(const char* lib,
89c89
< cl->LoadNativeLibrary( lib );
---
> cl->LoadNativeLibrary(lib);
104,109d103
<
< void class_loader_set_system_class_loader(ClassLoaderHandle cl)
< {
< VM_Global_State::loader_env->system_class_loader = (UserDefinedClassLoader*) cl;
< }
<
455d448
< JNIEnv_Internal *env = (JNIEnv_Internal *)env_ext;
465c458
< Global_Env *ge = env->vm->vm_env;
---
> Global_Env *ge = jni_get_vm_env(env_ext);
501c494
< return jni_class_from_handle(env, clss);
---
> return jni_class_from_handle(env_ext, clss);
724,725c717
< jint UNUSED ok = Throw(env, exn);
< assert(ok == 0);
---
> Throw(env, exn);
818a811,818
>
> JavaVM * jni_get_java_vm(JNIEnv * jni_env) {
> return ((JNIEnv_Internal *)jni_env)->vm;
> }
>
> Global_Env * jni_get_vm_env(JNIEnv * jni_env) {
> return ((JNIEnv_Internal *)jni_env)->vm->vm_env;
> }
Index: vm/vmcore/src/jit/compile.cpp
===================================================================
905c905,906
< CodeChunkInfo *caller = vm_methods->find(ret_ip);
---
> Global_Env *env = VM_Global_State::loader_env;
> CodeChunkInfo *caller = env->vm_methods->find(ret_ip);
Index: vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp
===================================================================
55c55
< vm_enumerate_the_current_thread()
---
> vm_enumerate_the_current_thread(VM_thread * vm_thread)
56a57
> assert(p_TLS_vmthread == vm_thread);
60c61
< vm_enumerate_thread(p_TLS_vmthread);
---
> vm_enumerate_thread(vm_thread);
80a82,83
> VM_thread * current_vm_thread;
>
87,88c90,91
<
< hythread_iterator_t iterator;
---
>
> hythread_iterator_t iterator;
95a99
> current_vm_thread = p_TLS_vmthread;
97,100c101,102
< hythread_t tm_thread = hythread_iterator_next(&iterator);
<
< //VM_thread *thread = get_vm_thread (hythread_iterator_next(&iterator));
< while(tm_thread) {
---
> hythread_t tm_thread = hythread_iterator_next(&iterator);
> while (tm_thread) {
102c104,105
< if (thread && thread != p_TLS_vmthread) {
---
> //assert(thread);
> if (thread && thread != current_vm_thread) {
112c115
< vm_enumerate_the_current_thread();
---
> vm_enumerate_the_current_thread(current_vm_thread);
Index: vm/vmcore/src/gc/dll_gc.cpp
===================================================================
399,400c399
< printf("Fatal GC error: compressed references are not supported\n");
< vm_exit(1);
---
> DIE("Fatal GC error: compressed references are not supported\n");
408,409c407
< printf("Fatal GC error: managed pointers are not supported\n");
< vm_exit(1);
---
> DIE("Fatal GC error: managed pointers are not supported\n");
Index: vm/vmcore/src/jvmti/jvmti_thread.cpp
===================================================================
27a28
> #include "jni_utils.h"
649a651,652
> JavaVM * java_vm;
>
674a678,679
>
> java_vm = jni_get_java_vm(jthread_get_JNI_env(jthread_self()));
683c688
< jthread_create_with_function(jvmti_test_jenv, thread, &attrs, proc, arg);
---
> jthread_create_with_function(java_vm, thread, &attrs, proc, arg);
Index: vm/vmcore/src/jvmti/jvmti_step.cpp
===================================================================
32a33
> #include "jni_utils.h"
480c481,482
< CodeChunkInfo *cci = vm_methods->find(ip);
---
> Global_Env * vm_env = jni_get_vm_env(vm_thread->jni_env);
> CodeChunkInfo *cci = vm_env->vm_methods->find(ip);
Index: vm/vmcore/src/jvmti/jvmti.cpp
===================================================================
291c291
< add_pair_to_properties(p_env->properties, "vm.jvmti.enabled", "true");
---
> add_pair_to_properties(*p_env->properties, "vm.jvmti.enabled", "true");
473c473
< const char *vm_libs = vm->vm_env->properties.get("vm.boot.library.path")->as_string();
---
> const char *vm_libs = vm->vm_env->properties->get("vm.boot.library.path")->as_string();
Index: vm/vmcore/src/jvmti/jvmti_event.cpp
===================================================================
80d79
< //JNIEnv *jni_env = jni_native_intf;
107d105
< // JNIEnv *jni_env = jni_native_intf;
416c414
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
649c647
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
700c698
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
757c755
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
803c801
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
882c880
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
957c955
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
988c986
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1142c1140
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1259c1257
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1316c1314
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1375c1373
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1460c1458
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1558c1556
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
1666c1664
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
Index: vm/vmcore/src/jvmti/jvmti_thread_group.cpp
===================================================================
32c32
< static JNIEnv_Internal * jvmti_test_jenv = jni_native_intf;
---
> static JNIEnv * jvmti_test_jenv = jni_native_intf;
Index: vm/vmcore/src/jvmti/jvmti_property.cpp
===================================================================
77c77
< Properties *properties = &g_env->properties;
---
> Properties *properties = g_env->properties;
133c133
< Properties::Iterator *iterator = ((TIEnv*)env)->vm->vm_env->properties.getIterator();
---
> Properties::Iterator *iterator = ((TIEnv*)env)->vm->vm_env->properties->getIterator();
144c144
< iterator = ((TIEnv*)env)->vm->vm_env->properties.getIterator();
---
> iterator = ((TIEnv*)env)->vm->vm_env->properties->getIterator();
190c190
< Prop_Value *prop_value = ((TIEnv*)env)->vm->vm_env->properties.get(property);
---
> Prop_Value *prop_value = ((TIEnv*)env)->vm->vm_env->properties->get(property);
242c242
< Prop_entry *pe = vm_env->properties.get_entry(property);
---
> Prop_entry *pe = vm_env->properties->get_entry(property);
244c244
< vm_env->properties.add(e);
---
> vm_env->properties->add(e);
Index: vm/vmcore/src/jvmti/jvmti_break.cpp
===================================================================
66c66
< JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
---
> JNIEnv *jni_env = jni_native_intf;
Index: vm/vmcore/src/reflection/annotations.cpp
===================================================================
42c42
< static Class* antn_class = ((JNIEnv_Internal*)jenv)->vm->vm_env->LoadCoreClass(
---
> static Class* antn_class = jni_get_vm_env(jenv)->LoadCoreClass(
124c124
< static Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
---
> static Global_Env* genv = jni_get_vm_env(jenv);
186c186
< static Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
---
> static Global_Env* genv = jni_get_vm_env(jenv);
212c212
< Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
---
> Global_Env* genv = jni_get_vm_env(jenv);
Index: vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
===================================================================
93c93
< (JNIEnv *jenv_ext, jclass, jstring name, jobject cl)
---
> (JNIEnv *jenv, jclass, jstring name, jobject cl)
99c99
< ThrowNew_Quick(jenv_ext, "java/lang/NullPointerException", "null class name value.");
---
> ThrowNew_Quick(jenv, "java/lang/NullPointerException", "null class name value.");
104d103
< JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
118c117
< Global_Env *ge = jenv->vm->vm_env;
---
> Global_Env *ge = jni_get_vm_env(jenv);
187c186
< JNIEXPORT jobject JNICALL Java_java_lang_VMClassRegistry_getClassLoader
---
> JNIEXPORT jobject JNICALL Java_java_lang_VMClassRegistry_getClassLoader0
558c557
< loader = class_loader_lookup( classLoader );
---
> loader = class_loader_lookup(classLoader);
562c561
< ((JNIEnv_Internal*)jenv)->vm->vm_env->bootstrap_class_loader;
---
> jni_get_vm_env(jenv)->bootstrap_class_loader;
564c563
< class_loader_load_native_lib( str_filename, loader );
---
> class_loader_load_native_lib(str_filename, loader);
Index: vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp
===================================================================
78c78
< static Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
---
> static Global_Env* genv = jni_get_vm_env(jenv);
93c93
< static Class* antn_class = ((JNIEnv_Internal*)jenv)->vm->vm_env->LoadCoreClass(
---
> static Class* antn_class = jni_get_vm_env(jenv)->LoadCoreClass(
Index: vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
===================================================================
108c108
< (JNIEnv *jenv_ext, jclass, jint signedMaxSize, jboolean considerPrivileged)
---
> (JNIEnv *jenv, jclass, jint signedMaxSize, jboolean considerPrivileged)
110d109
< JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
125c124
< Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
---
> Global_Env* genv = jni_get_vm_env(jenv);
216c215
< (JNIEnv * jenv_ext, jclass, jobject state)
---
> (JNIEnv * jenv, jclass, jobject state)
222c221
< Global_Env* genv = VM_Global_State::loader_env;
---
> Global_Env* genv = jni_get_vm_env(jenv);
224d222
< JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
257c255
< VM_Global_State::loader_env->java_lang_Throwable_Class) {
---
> genv->java_lang_Throwable_Class) {
274,292d271
<
< // skip the VMStart$MainThread.runImpl() if it exists from the bottom
< // of the stack along with 2 reflection frames used to invoke method main
< static String* starter_String = genv->string_pool.lookup("java/lang/VMStart$MainThread");
< Method_Handle method = frames[size - 1].method;
< assert(method);
<
< if (!strcmp(method_get_name(method), "runImpl")
< && method->get_class()->name == starter_String) {
< for (; --size;) {
< method = frames[size - 1].method;
< assert(method);
< if ((strstr(method->get_class()->name->bytes, "java/lang/reflect"))
< == NULL) {
< break;
< }
< }
< }
<
337,338c316
< String* className = class_get_java_name(method->get_class(),
< VM_Global_State::loader_env);
---
> String* className = class_get_java_name(method->get_class(), genv);
378c356
< return Java_java_lang_VMClassRegistry_getClassLoader(jenv, NULL, clazz);
---
> return Java_java_lang_VMClassRegistry_getClassLoader0(jenv, NULL, clazz);
Index: vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp
===================================================================
41c41
< return Java_java_lang_VMClassRegistry_getClassLoader(jenv, NULL, clazz);
---
> return Java_java_lang_VMClassRegistry_getClassLoader0(jenv, NULL, clazz);
Index: vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp
===================================================================
46a47
> #include "init.h"
86c87
< Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
---
> Global_Env* genv = jni_get_vm_env(jenv);
175c176
< reinterpret_cast(&((JNIEnv_Internal*)jenv)->vm->vm_env->properties),
---
> reinterpret_cast(jni_get_vm_env(jenv)->properties),
201c202
< Properties::Iterator *iterator = VM_Global_State::loader_env->properties.getIterator();
---
> Properties::Iterator *iterator = VM_Global_State::loader_env->properties->getIterator();
Index: vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
===================================================================
29a30
> #include "jni_utils.h"
161c162
<
---
>
165c166
< return (jint)jthread_create(jenv, thread, &attrs);
---
> return (jint)jthread_create(jni_get_java_vm(jenv), thread, &attrs);
198a200
> // TODO: need to evaluate return code properly
215,225d216
< * Method: attach
< * Signature: ()V
< */
< JNIEXPORT void JNICALL Java_java_lang_VMThreadManager_attach
< (JNIEnv * UNREF jenv, jclass clazz, jobject java_thread)
< {
< jthread_attach(jenv, java_thread);
< }
<
< /*
< * Class: java_lang_VMThreadManager
Index: vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.h
===================================================================
69c69
< Java_java_lang_VMClassRegistry_getClassLoader(JNIEnv *, jclass,
---
> Java_java_lang_VMClassRegistry_getClassLoader0(JNIEnv *, jclass,
Index: vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.h
===================================================================
74c74
< Java_org_apache_harmony_vm_VMStack_getClassLoader(JNIEnv *, jclass,
---
> Java_org_apache_harmony_vm_VMStack_getClassLoader0(JNIEnv *, jclass,
Index: vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java
===================================================================
39c39
< static int exitCode = 0;
---
>
49,72d48
< public static void start (String mainClassName, String args[]) {
< try {
< // create main thread in new thread group
< MainThread mainThread = new MainThread(mainClassName, args);
< mainThread.start();
< //startHelperThreads();
< //System.out.println("Join Group " + Thread.currentThread().getThreadGroup());
< } catch (Throwable e) {
< e.printStackTrace(System.err);
< System.exit(-1);
< }
< }
<
< public static void shutdown() {
< try {
< joinAllNonDaemonThreads();
< //System.out.println("Joined all ");
< System.exit(exitCode);
< } catch (Throwable e) {
< e.printStackTrace(System.err);
< System.exit(-1);
< }
< }
<
89,99d64
< public void run() {
< FinalizerThread.shutdown();
< EMThreadSupport.shutdown();
< }
< }
<
< // main thread
< static class MainThread extends Thread {
< String mainClass;
< String args[];
< public boolean started = false;
101,105c66,67
< MainThread (String mainClass, String args[]) {
< super(new ThreadGroup("main"), "main");
< this.mainClass = mainClass;
< this.args = args;
<
---
> public DefaultShutDownHook() {
> super("Thread-shutdown");
107a71,72
> FinalizerThread.shutdown();
> EMThreadSupport.shutdown();
109,155d73
<
< void runImpl() {
< // prevent access from user classes to run() method
< if(started) {
< return;
< }
< started = true;
<
< try {
< // load and start main class
< ClassLoader loader = ClassLoader.getSystemClassLoader();
< Class cl = Class.forName(mainClass, true, loader);
< final Method mainMethod = cl.getMethod("main",
< new Class[]{String[].class});
< int expectedModifiers = (Modifier.PUBLIC | Modifier.STATIC);
< if ((mainMethod.getModifiers() & expectedModifiers) != expectedModifiers
< || mainMethod.getReturnType() != Void.TYPE) {
< throw new NoSuchMethodError(
< "The method main must be declared public, static, and void.");
< }
< // the class itself may be non-public
< AccessController.doPrivileged(new PrivilegedAction