From: Tom Tromey Date: Thu, 19 Jan 2006 00:57:00 +0000 (+0000) Subject: jni.cc (_Jv_JNI_AttachCurrentThread): Return environment if it already exists. X-Git-Tag: releases/gcc-4.2.0~4756 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec5dd52b373735f93077aece00864c48c7a8bae4;p=thirdparty%2Fgcc.git jni.cc (_Jv_JNI_AttachCurrentThread): Return environment if it already exists. * jni.cc (_Jv_JNI_AttachCurrentThread): Return environment if it already exists. From-SVN: r109936 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 032a98db4ceb..31f66e6a04da 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2006-01-18 Tom Tromey + + * jni.cc (_Jv_JNI_AttachCurrentThread): Return environment if it + already exists. + 2006-01-18 Keith Seitz * include/java-interp.h (_Jv_CompileMethod): Add declaration. diff --git a/libjava/jni.cc b/libjava/jni.cc index fd8270657188..5a93753f006d 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -1,6 +1,6 @@ // jni.cc - JNI implementation, including the jump table. -/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation This file is part of libgcj. @@ -2352,10 +2352,14 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, } // Attaching an already-attached thread is a no-op. - if (_Jv_GetCurrentJNIEnv () != NULL) - return 0; + JNIEnv *env = _Jv_GetCurrentJNIEnv (); + if (env != NULL) + { + *penv = reinterpret_cast (env); + return 0; + } - JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv)); + env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv)); if (env == NULL) return JNI_ERR; env->p = &_Jv_JNIFunctions;