Mercurial > hg > truffle
diff src/share/vm/prims/jni.cpp @ 14297:febc6428bc79
8028275: Metaspace ShrinkGrowTest causes fatal error if run with JFR
Summary: Clean up initialization from Threads::create_vm() so that exceptions cause vm_exit_during_initialzation without an exception mark.
Reviewed-by: dholmes, hseigel
author | coleenp |
---|---|
date | Mon, 27 Jan 2014 23:12:13 -0500 |
parents | d050fbf914d8 |
children | 2c95095271e9 |
line wrap: on
line diff
--- a/src/share/vm/prims/jni.cpp Tue Jan 21 16:45:10 2014 -0600 +++ b/src/share/vm/prims/jni.cpp Mon Jan 27 23:12:13 2014 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -5053,6 +5053,7 @@ result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again); if (result == JNI_OK) { JavaThread *thread = JavaThread::current(); + assert(!thread->has_pending_exception(), "should have returned not OK"); /* thread is thread_in_vm here */ *vm = (JavaVM *)(&main_vm); *(JNIEnv**)penv = thread->jni_environment(); @@ -5089,6 +5090,19 @@ // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); } else { + // If create_vm exits because of a pending exception, exit with that + // exception. In the future when we figure out how to reclaim memory, + // we may be able to exit with JNI_ERR and allow the calling application + // to continue. + if (Universe::is_fully_initialized()) { + // otherwise no pending exception possible - VM will already have aborted + JavaThread* THREAD = JavaThread::current(); + if (HAS_PENDING_EXCEPTION) { + HandleMark hm; + vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); + } + } + if (can_try_again) { // reset safe_to_recreate_vm to 1 so that retrial would be possible safe_to_recreate_vm = 1;