equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright (c) 2012 Red Hat, Inc. |
3 * Copyright (c) 2012 Red Hat, Inc. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * |
5 * |
6 * This code is free software; you can redistribute it and/or modify it |
6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as |
7 * under the terms of the GNU General Public License version 2 only, as |
5051 bool can_try_again = true; |
5051 bool can_try_again = true; |
5052 |
5052 |
5053 result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again); |
5053 result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again); |
5054 if (result == JNI_OK) { |
5054 if (result == JNI_OK) { |
5055 JavaThread *thread = JavaThread::current(); |
5055 JavaThread *thread = JavaThread::current(); |
|
5056 assert(!thread->has_pending_exception(), "should have returned not OK"); |
5056 /* thread is thread_in_vm here */ |
5057 /* thread is thread_in_vm here */ |
5057 *vm = (JavaVM *)(&main_vm); |
5058 *vm = (JavaVM *)(&main_vm); |
5058 *(JNIEnv**)penv = thread->jni_environment(); |
5059 *(JNIEnv**)penv = thread->jni_environment(); |
5059 |
5060 |
5060 // Tracks the time application was running before GC |
5061 // Tracks the time application was running before GC |
5087 #endif |
5088 #endif |
5088 |
5089 |
5089 // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. |
5090 // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. |
5090 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); |
5091 ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); |
5091 } else { |
5092 } else { |
|
5093 // If create_vm exits because of a pending exception, exit with that |
|
5094 // exception. In the future when we figure out how to reclaim memory, |
|
5095 // we may be able to exit with JNI_ERR and allow the calling application |
|
5096 // to continue. |
|
5097 if (Universe::is_fully_initialized()) { |
|
5098 // otherwise no pending exception possible - VM will already have aborted |
|
5099 JavaThread* THREAD = JavaThread::current(); |
|
5100 if (HAS_PENDING_EXCEPTION) { |
|
5101 HandleMark hm; |
|
5102 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); |
|
5103 } |
|
5104 } |
|
5105 |
5092 if (can_try_again) { |
5106 if (can_try_again) { |
5093 // reset safe_to_recreate_vm to 1 so that retrial would be possible |
5107 // reset safe_to_recreate_vm to 1 so that retrial would be possible |
5094 safe_to_recreate_vm = 1; |
5108 safe_to_recreate_vm = 1; |
5095 } |
5109 } |
5096 |
5110 |