summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bridges/prj/build.lst2
-rw-r--r--bridges/prj/d.lst2
-rw-r--r--bridges/source/jni_uno/jni_base.h145
-rw-r--r--bridges/source/jni_uno/jni_bridge.cxx276
-rw-r--r--bridges/source/jni_uno/jni_bridge.h62
-rw-r--r--bridges/source/jni_uno/jni_data.cxx756
-rw-r--r--bridges/source/jni_uno/jni_helper.h88
-rw-r--r--bridges/source/jni_uno/jni_info.cxx407
-rw-r--r--bridges/source/jni_uno/jni_info.h72
-rw-r--r--bridges/source/jni_uno/jni_java2uno.cxx118
-rw-r--r--bridges/source/jni_uno/jni_uno2java.cxx242
-rw-r--r--bridges/source/jni_uno/makefile.mk5
12 files changed, 1084 insertions, 1091 deletions
diff --git a/bridges/prj/build.lst b/bridges/prj/build.lst
index e5a342d87abf..ade4ceb8127b 100644
--- a/bridges/prj/build.lst
+++ b/bridges/prj/build.lst
@@ -19,6 +19,6 @@ br bridges\source\cpp_uno\gcc2_netbsd_intel nmake - u br_gccni br_unotypes NULL
br bridges\source\cpp_uno\gcc2_netbsd_sparc nmake - u br_gccns br_unotypes NULL
br bridges\source\cpp_uno\gcc2_netbsd_powerpc nmake - u br_gccnp br_unotypes NULL
br bridges\source\prot_uno nmake - all br_pruno br_unotypes NULL
-br bridges\source\java_uno nmake - all br_java_uno br_rcon NULL
+#br bridges\source\java_uno nmake - all br_java_uno br_rcon NULL
br bridges\source\jni_uno nmake - all br_jni_uno br_unotypes NULL
br bridges\source\jni_uno\java nmake - all br_jni_uno_java br_unotypes NULL
diff --git a/bridges/prj/d.lst b/bridges/prj/d.lst
index 1eba7955cc0c..06218226ec07 100644
--- a/bridges/prj/d.lst
+++ b/bridges/prj/d.lst
@@ -6,8 +6,6 @@ mkdir: %_DEST%\inc%_EXT%\bridges\java
..\inc\bridges\remote\context.h %_DEST%\inc%_EXT%\bridges\remote\context.h
..\inc\bridges\remote\remote.h %_DEST%\inc%_EXT%\bridges\remote\remote.h
-..\inc\bridges\java\jvmcontext.hxx %_DEST%\inc%_EXT%\bridges\java\jvmcontext.hxx
-
..\%__SRC%\lib\irmcxt* %_DEST%\lib%_EXT%\*
..\%__SRC%\lib\librmcxt* %_DEST%\lib%_EXT%\*
..\%__SRC%\bin\rmcxt* %_DEST%\bin%_EXT%\*
diff --git a/bridges/source/jni_uno/jni_base.h b/bridges/source/jni_uno/jni_base.h
index 8fb49ee00898..c98101b4af15 100644
--- a/bridges/source/jni_uno/jni_base.h
+++ b/bridges/source/jni_uno/jni_base.h
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_base.h,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dbo $ $Date: 2002-11-20 09:57:28 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,31 +58,33 @@
*
*
************************************************************************/
-#ifndef _JNI_BASE_H_
-#define _JNI_BASE_H_
+#if ! defined INCLUDED_JNI_BASE_H
+#define INCLUDED_JNI_BASE_H
#if defined (__SUNPRO_CC) || defined (__SUNPRO_C)
+// workaround solaris include trouble on jumbo
#include <stdarg.h>
namespace std
{
typedef __va_list va_list;
}
#endif
-#include <jni.h>
#include <memory>
-#include <rtl/alloc.h>
-#include <rtl/ustring.hxx>
+#include "jvmaccess/virtualmachine.hxx"
-#include <uno/environment.h>
-#include <typelib/typedescription.h>
+#include "osl/diagnose.h"
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+#include "rtl/alloc.h"
+#include "rtl/ustring.hxx"
+
+#include "uno/environment.h"
+#include "typelib/typedescription.h"
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-struct JavaVMContext;
-namespace jni_bridge
+namespace jni_uno
{
class JNI_info;
@@ -101,13 +103,13 @@ struct BridgeRuntimeError
//==================================================================================================
struct rtl_mem
{
- inline static void * operator new ( size_t nSize ) SAL_THROW( () )
+ inline static void * operator new ( size_t nSize )
{ return rtl_allocateMemory( nSize ); }
- inline static void operator delete ( void * mem ) SAL_THROW( () )
+ inline static void operator delete ( void * mem )
{ if (mem) rtl_freeMemory( mem ); }
- inline static void * operator new ( size_t, void * mem ) SAL_THROW( () )
+ inline static void * operator new ( size_t, void * mem )
{ return mem; }
- inline static void operator delete ( void *, void * ) SAL_THROW( () )
+ inline static void operator delete ( void *, void * )
{}
static inline ::std::auto_ptr< rtl_mem > allocate( ::std::size_t bytes );
@@ -128,15 +130,15 @@ class TypeDescr
{
typelib_TypeDescription * m_td;
- inline TypeDescr( TypeDescr const & );
- inline TypeDescr & operator = ( TypeDescr const & );
+ TypeDescr( TypeDescr & ); // not impl
+ void operator = ( TypeDescr ); // not impl
public:
- inline TypeDescr( typelib_TypeDescriptionReference * td_ref );
+ inline explicit TypeDescr( typelib_TypeDescriptionReference * td_ref );
inline ~TypeDescr() SAL_THROW( () )
{ TYPELIB_DANGER_RELEASE( m_td ); }
- inline typelib_TypeDescription * get() const SAL_THROW( () )
+ inline typelib_TypeDescription * get() const
{ return m_td; }
};
//__________________________________________________________________________________________________
@@ -155,107 +157,126 @@ inline TypeDescr::TypeDescr( typelib_TypeDescriptionReference * td_ref )
//##################################################################################################
//==================================================================================================
-class JNI_attach
+class JNI_context
{
- sal_uInt32 m_thread_id;
- ::JavaVMContext * m_context;
- JNI_info const * m_jni_info;
- JavaVM * m_vm;
- JNIEnv * m_env;
- bool m_revoke;
- bool m_detach;
+ JNI_info const * m_jni_info;
+ JNIEnv * m_env;
+
+ JNI_context( JNI_context & ); // not impl
+ void operator = ( JNI_context ); // not impl
+ void throw_bridge_error() const;
public:
- ~JNI_attach() SAL_THROW( () );
- JNI_attach( uno_Environment * java_env );
- JNI_attach( uno_Environment * java_env, JNIEnv * jni_env ) SAL_THROW( () );
+ inline explicit JNI_context( JNI_info const * jni_info, JNIEnv * env )
+ : m_jni_info( jni_info ),
+ m_env( env )
+ {}
- inline JavaVM * get_vm() const SAL_THROW( () )
- { return m_vm; }
- inline JNIEnv * get_jni_env() const SAL_THROW( () )
- { return m_env; }
- inline JNI_info const * get_jni_info() const SAL_THROW( () )
+ inline JNI_info const * get_info() const
{ return m_jni_info; }
- inline JNIEnv * operator -> () const SAL_THROW( () )
+ inline JNIEnv * operator -> () const
+ { return m_env; }
+ inline JNIEnv * get_jni_env() const
{ return m_env; }
- void throw_bridge_error() const;
inline void ensure_no_exception() const
{ if (JNI_FALSE != m_env->ExceptionCheck()) throw_bridge_error(); }
};
+//==================================================================================================
+class JNI_guarded_context
+ : private ::jvmaccess::VirtualMachine::AttachGuard,
+ public JNI_context
+{
+ JNI_guarded_context( JNI_guarded_context & ); // not impl
+ void operator = ( JNI_guarded_context ); // not impl
+
+public:
+ JNI_guarded_context(
+ JNI_info const * jni_info, ::jvmaccess::VirtualMachine * vm_access )
+ // workaround this by catching internally CreationException
+// try
+ : AttachGuard( vm_access ),
+ JNI_context( jni_info, AttachGuard::getEnvironment() )
+ {}
+// catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+// {
+// throw BridgeRuntimeError( OUSTR("attaching to java vm failed!") );
+// }
+};
+
//##################################################################################################
//==================================================================================================
class JLocalAutoRef
{
- JNI_attach const * m_attach;
- mutable jobject m_jo;
+ JNI_context const & m_jni;
+ jobject m_jo;
public:
- inline JLocalAutoRef() SAL_THROW( () )
- : m_attach( 0 ),
+ inline JLocalAutoRef( JNI_context const & jni )
+ : m_jni( jni ),
m_jo( 0 )
{}
- inline explicit JLocalAutoRef( JNI_attach const & attach, jobject jo ) SAL_THROW( () )
- : m_attach( &attach ),
+ inline explicit JLocalAutoRef( JNI_context const & jni, jobject jo )
+ : m_jni( jni ),
m_jo( jo )
{}
- inline JLocalAutoRef( JLocalAutoRef const & auto_ref ) SAL_THROW( () );
+ inline JLocalAutoRef( JLocalAutoRef & auto_ref );
inline ~JLocalAutoRef() SAL_THROW( () );
- inline jobject get() const SAL_THROW( () )
+ inline jobject get() const
{ return m_jo; }
- inline bool is() const SAL_THROW( () )
+ inline bool is() const
{ return (0 != m_jo); }
- inline jobject release() SAL_THROW( () );
- inline void reset() SAL_THROW( () );
- inline void reset( JNI_attach const & attach, jobject jo ) SAL_THROW( () );
- inline JLocalAutoRef & operator = ( JLocalAutoRef const & auto_ref ) SAL_THROW( () );
+ inline jobject release();
+ inline void reset();
+ inline void reset( jobject jo );
+ inline JLocalAutoRef & operator = ( JLocalAutoRef & auto_ref );
};
//__________________________________________________________________________________________________
inline JLocalAutoRef::~JLocalAutoRef() SAL_THROW( () )
{
if (0 != m_jo)
- (*m_attach)->DeleteLocalRef( m_jo );
+ m_jni->DeleteLocalRef( m_jo );
}
//__________________________________________________________________________________________________
-inline JLocalAutoRef::JLocalAutoRef( JLocalAutoRef const & auto_ref ) SAL_THROW( () )
- : m_attach( auto_ref.m_attach ),
+inline JLocalAutoRef::JLocalAutoRef( JLocalAutoRef & auto_ref )
+ : m_jni( auto_ref.m_jni ),
m_jo( auto_ref.m_jo )
{
auto_ref.m_jo = 0;
}
//__________________________________________________________________________________________________
-inline jobject JLocalAutoRef::release() SAL_THROW( () )
+inline jobject JLocalAutoRef::release()
{
jobject jo = m_jo;
m_jo = 0;
return jo;
}
//__________________________________________________________________________________________________
-inline void JLocalAutoRef::reset() SAL_THROW( () )
+inline void JLocalAutoRef::reset()
{
if (0 != m_jo)
- (*m_attach)->DeleteLocalRef( m_jo );
+ m_jni->DeleteLocalRef( m_jo );
m_jo = 0;
}
//__________________________________________________________________________________________________
-inline void JLocalAutoRef::reset( JNI_attach const & attach, jobject jo ) SAL_THROW( () )
+inline void JLocalAutoRef::reset( jobject jo )
{
if (jo != m_jo)
{
if (0 != m_jo)
- (*m_attach)->DeleteLocalRef( m_jo );
+ m_jni->DeleteLocalRef( m_jo );
m_jo = jo;
}
- m_attach = &attach;
}
//__________________________________________________________________________________________________
-inline JLocalAutoRef & JLocalAutoRef::operator = ( JLocalAutoRef const & auto_ref ) SAL_THROW( () )
+inline JLocalAutoRef & JLocalAutoRef::operator = ( JLocalAutoRef & auto_ref )
{
- reset( *auto_ref.m_attach, auto_ref.m_jo );
+ OSL_ASSERT( m_jni.get_jni_env() == auto_ref.m_jni.get_jni_env() );
+ reset( auto_ref.m_jo );
auto_ref.m_jo = 0;
return *this;
}
diff --git a/bridges/source/jni_uno/jni_bridge.cxx b/bridges/source/jni_uno/jni_bridge.cxx
index 9ac0091fd6a9..187687a71af7 100644
--- a/bridges/source/jni_uno/jni_bridge.cxx
+++ b/bridges/source/jni_uno/jni_bridge.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_bridge.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: dbo $ $Date: 2002-11-18 13:07:52 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,15 +61,15 @@
#include "jni_bridge.h"
-#include <rtl/unload.h>
-#include <rtl/strbuf.hxx>
-#include <uno/lbnames.h>
+#include "rtl/unload.h"
+#include "rtl/strbuf.hxx"
+#include "uno/lbnames.h"
using namespace ::std;
using namespace ::rtl;
using namespace ::osl;
-using namespace ::jni_bridge;
+using namespace ::jni_uno;
namespace
{
@@ -77,21 +77,21 @@ extern "C"
{
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_Mapping_acquire( uno_Mapping * mapping )
+void SAL_CALL Mapping_acquire( uno_Mapping * mapping )
SAL_THROW_EXTERN_C()
{
- jni_Mapping const * that = static_cast< jni_Mapping const * >( mapping );
+ Mapping const * that = static_cast< Mapping const * >( mapping );
that->m_bridge->acquire();
}
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_Mapping_release( uno_Mapping * mapping )
+void SAL_CALL Mapping_release( uno_Mapping * mapping )
SAL_THROW_EXTERN_C()
{
- jni_Mapping const * that = static_cast< jni_Mapping const * >( mapping );
+ Mapping const * that = static_cast< Mapping const * >( mapping );
that->m_bridge->release();
}
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_Mapping_java2uno(
+void SAL_CALL Mapping_java2uno(
uno_Mapping * mapping, void ** ppOut,
void * pIn, typelib_InterfaceTypeDescription * td )
SAL_THROW_EXTERN_C()
@@ -112,12 +112,16 @@ void SAL_CALL jni_Mapping_java2uno(
{
try
{
- jni_Mapping const * that = static_cast< jni_Mapping const * >( mapping );
- jni_Bridge const * bridge = that->m_bridge;
- JNI_attach attach( bridge->m_java_env );
+ Mapping const * that = static_cast< Mapping const * >( mapping );
+ Bridge const * bridge = that->m_bridge;
+
+ JNI_guarded_context jni(
+ bridge->m_jni_info,
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >( bridge->m_java_env->pContext ) );
+
JNI_type_info const * info =
- bridge->m_jni_info->get_type_info( attach, (typelib_TypeDescription *)td );
- *ppUnoI = bridge->map_java2uno( attach, javaI, info );
+ bridge->m_jni_info->get_type_info( jni, (typelib_TypeDescription *)td );
+ *ppUnoI = bridge->map_java2uno( jni, javaI, info );
}
catch (BridgeRuntimeError & err)
{
@@ -128,10 +132,14 @@ void SAL_CALL jni_Mapping_java2uno(
OSL_ENSURE( 0, cstr_msg.getStr() );
#endif
}
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ OSL_ENSURE( 0, "[jni_uno bridge error] attaching current thread to java failed!" );
+ }
}
}
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_Mapping_uno2java(
+void SAL_CALL Mapping_uno2java(
uno_Mapping * mapping, void ** ppOut,
void * pIn, typelib_InterfaceTypeDescription * td )
SAL_THROW_EXTERN_C()
@@ -144,22 +152,25 @@ void SAL_CALL jni_Mapping_uno2java(
try
{
- jni_Mapping const * that = static_cast< jni_Mapping const * >( mapping );
- jni_Bridge const * bridge = that->m_bridge;
- JNI_attach attach( bridge->m_java_env );
+ Mapping const * that = static_cast< Mapping const * >( mapping );
+ Bridge const * bridge = that->m_bridge;
+
+ JNI_guarded_context jni(
+ bridge->m_jni_info,
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >( bridge->m_java_env->pContext ) );
if (0 != *ppJavaI)
{
- attach->DeleteGlobalRef( *ppJavaI );
+ jni->DeleteGlobalRef( *ppJavaI );
*ppJavaI = 0;
}
if (0 != pUnoI)
{
JNI_type_info const * info =
- bridge->m_jni_info->get_type_info( attach, (typelib_TypeDescription *)td );
- jobject jlocal = bridge->map_uno2java( attach, pUnoI, info );
- *ppJavaI = attach->NewGlobalRef( jlocal );
- attach->DeleteLocalRef( jlocal );
+ bridge->m_jni_info->get_type_info( jni, (typelib_TypeDescription *)td );
+ jobject jlocal = bridge->map_uno2java( jni, pUnoI, info );
+ *ppJavaI = jni->NewGlobalRef( jlocal );
+ jni->DeleteLocalRef( jlocal );
}
}
catch (BridgeRuntimeError & err)
@@ -171,88 +182,82 @@ void SAL_CALL jni_Mapping_uno2java(
OSL_ENSURE( 0, cstr_msg.getStr() );
#endif
}
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ OSL_ENSURE( 0, "[jni_uno bridge error] attaching current thread to java failed!" );
+ }
}
//__________________________________________________________________________________________________
-void SAL_CALL jni_Bridge_free( uno_Mapping * mapping )
+void SAL_CALL Bridge_free( uno_Mapping * mapping )
SAL_THROW_EXTERN_C()
{
- jni_Mapping * that = static_cast< jni_Mapping * >( mapping );
+ Mapping * that = static_cast< Mapping * >( mapping );
delete that->m_bridge;
}
}
-}
-
-namespace jni_bridge
-{
//==================================================================================================
rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
+}
+
+namespace jni_uno
+{
+
//__________________________________________________________________________________________________
-void jni_Bridge::acquire() const SAL_THROW( () )
+void Bridge::acquire() const SAL_THROW( () )
{
if (1 == osl_incrementInterlockedCount( &m_ref ))
{
- if (m_registered_java2uno)
- {
- uno_Mapping * mapping = const_cast< jni_Mapping * >( &m_java2uno );
- ::uno_registerMapping(
- &mapping, jni_Bridge_free,
- m_java_env, (uno_Environment *)m_uno_env, 0 );
- }
- else
- {
- uno_Mapping * mapping = const_cast< jni_Mapping * >( &m_uno2java );
- ::uno_registerMapping(
- &mapping, jni_Bridge_free,
- (uno_Environment *)m_uno_env, m_java_env, 0 );
- }
+ uno_Mapping * mapping = const_cast< Mapping * >( &m_java2uno );
+ uno_registerMapping( &mapping, Bridge_free, m_java_env, (uno_Environment *)m_uno_env, 0 );
+ OSL_ASSERT( mapping == const_cast< Mapping * >( &m_java2uno ) );
+ mapping = const_cast< Mapping * >( &m_uno2java );
+ uno_registerMapping( &mapping, Bridge_free, (uno_Environment *)m_uno_env, m_java_env, 0 );
+ OSL_ASSERT( mapping == const_cast< Mapping * >( &m_uno2java ) );
}
}
//__________________________________________________________________________________________________
-void jni_Bridge::release() const SAL_THROW( () )
+void Bridge::release() const SAL_THROW( () )
{
if (! osl_decrementInterlockedCount( &m_ref ))
{
- ::uno_revokeMapping(
- m_registered_java2uno
- ? const_cast< jni_Mapping * >( &m_java2uno )
- : const_cast< jni_Mapping * >( &m_uno2java ) );
+ uno_revokeMapping( const_cast< Mapping * >( &m_java2uno ) );
+ uno_revokeMapping( const_cast< Mapping * >( &m_uno2java ) );
}
}
//__________________________________________________________________________________________________
-jni_Bridge::jni_Bridge(
- uno_Environment * java_env, uno_ExtEnvironment * uno_env, bool register_java2uno )
- SAL_THROW( () )
- : m_ref( 1 ),
- m_uno_env( uno_env ),
- m_java_env( java_env ),
- m_registered_java2uno( register_java2uno )
+Bridge::Bridge(
+ uno_Environment * java_env, uno_ExtEnvironment * uno_env )
+ : m_ref( 0 ),
+ m_uno_env( uno_env ),
+ m_java_env( java_env )
{
+ m_jni_info = new JNI_info( this );
+
OSL_ASSERT( 0 != m_java_env && 0 != m_uno_env );
(*((uno_Environment *)m_uno_env)->acquire)( (uno_Environment *)m_uno_env );
(*m_java_env->acquire)( m_java_env );
- JavaVMContext * jvm_context = reinterpret_cast< JavaVMContext * >( java_env->pContext );
- m_jni_info = reinterpret_cast< JNI_info * >( jvm_context->m_extra );
// java2uno
- m_java2uno.acquire = jni_Mapping_acquire;
- m_java2uno.release = jni_Mapping_release;
- m_java2uno.mapInterface = (uno_MapInterfaceFunc)jni_Mapping_java2uno;
+ m_java2uno.acquire = Mapping_acquire;
+ m_java2uno.release = Mapping_release;
+ m_java2uno.mapInterface = Mapping_java2uno;
m_java2uno.m_bridge = this;
// uno2java
- m_uno2java.acquire = jni_Mapping_acquire;
- m_uno2java.release = jni_Mapping_release;
- m_uno2java.mapInterface = jni_Mapping_uno2java;
+ m_uno2java.acquire = Mapping_acquire;
+ m_uno2java.release = Mapping_release;
+ m_uno2java.mapInterface = Mapping_uno2java;
m_uno2java.m_bridge = this;
(*g_moduleCount.modCnt.acquire)( &g_moduleCount.modCnt );
}
//__________________________________________________________________________________________________
-jni_Bridge::~jni_Bridge()
- SAL_THROW( () )
+Bridge::~Bridge() SAL_THROW( () )
{
+ delete m_jni_info;
+
(*m_java_env->release)( m_java_env );
(*((uno_Environment *)m_uno_env)->release)( (uno_Environment *)m_uno_env );
@@ -262,73 +267,7 @@ jni_Bridge::~jni_Bridge()
//##################################################################################################
//__________________________________________________________________________________________________
-JNI_attach::JNI_attach( uno_Environment * java_env, JNIEnv * jni_env ) SAL_THROW( () )
- : m_thread_id( ::osl::Thread::getCurrentIdentifier() ),
- m_env( jni_env ),
- m_detach( false )
-{
- OSL_ASSERT( 0 == rtl_ustr_ascii_compare( java_env->pTypeName->buffer, "java" ) );
- m_context = (JavaVMContext *)java_env->pContext;
- m_vm = m_context->_pJavaVM;
- m_jni_info = (JNI_info const *)m_context->m_extra;
-
- MutexGuard guard( m_context->_mutex );
- pair< JavaVMContext::t_map::iterator, bool > insertion(
- m_context->_registeredThreadMap.insert(
- JavaVMContext::t_map::value_type(
- m_thread_id, JavaVMContext::t_entry( 1, m_env ) ) ) );
- m_revoke = insertion.second;
-}
-//__________________________________________________________________________________________________
-JNI_attach::JNI_attach( uno_Environment * java_env )
- : m_thread_id( ::osl::Thread::getCurrentIdentifier() )
-{
- OSL_ASSERT( 0 == rtl_ustr_ascii_compare( java_env->pTypeName->buffer, "java" ) );
- m_context = (JavaVMContext *)java_env->pContext;
- m_vm = m_context->_pJavaVM;
- m_jni_info = (JNI_info const *)m_context->m_extra;
-
- MutexGuard guard( m_context->_mutex );
- pair< JavaVMContext::t_map::iterator, bool > insertion(
- m_context->_registeredThreadMap.insert(
- JavaVMContext::t_map::value_type(
- m_thread_id, JavaVMContext::t_entry( 1, 0 ) ) ) );
- if (insertion.second)
- {
- m_revoke = true;
- jint res = m_vm->AttachCurrentThread( (void **)&m_env, 0 );
- insertion.first->second.second = m_env;
- if (0 < res)
- {
- m_detach = false;
- throw BridgeRuntimeError( OUSTR("AttachCurrentThread() failed!") );
- }
- m_detach = true;
- }
- else
- {
- m_revoke = false;
- m_env = insertion.first->second.second;
- m_detach = false;
- }
-}
-//__________________________________________________________________________________________________
-JNI_attach::~JNI_attach() SAL_THROW( () )
-{
- if (m_revoke)
- {
- MutexGuard guard( m_context->_mutex );
- size_t erased = m_context->_registeredThreadMap.erase( m_thread_id );
- OSL_ASSERT( 1 == erased );
- }
- if (m_detach)
- {
- jint res = m_vm->DetachCurrentThread();
- OSL_ASSERT( 0 == res );
- }
-}
-//__________________________________________________________________________________________________
-void JNI_attach::throw_bridge_error() const
+void JNI_context::throw_bridge_error() const
{
JLocalAutoRef jo_exc( *this, m_env->ExceptionOccurred() );
m_env->ExceptionClear();
@@ -389,7 +328,7 @@ void JNI_attach::throw_bridge_error() const
}
-using namespace ::jni_bridge;
+using namespace ::jni_uno;
extern "C"
{
@@ -399,10 +338,10 @@ namespace
void SAL_CALL java_env_disposing( uno_Environment * java_env )
SAL_THROW_EXTERN_C()
{
- JavaVMContext * context = reinterpret_cast< JavaVMContext * >( java_env->pContext );
- delete reinterpret_cast< JNI_info * >( context->m_extra );
+ ::jvmaccess::VirtualMachine * machine =
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >( java_env->pContext );
java_env->pContext = 0;
- delete context;
+ machine->release();
}
}
//##################################################################################################
@@ -412,20 +351,10 @@ void SAL_CALL uno_initEnvironment( uno_Environment * java_env )
java_env->environmentDisposing = java_env_disposing;
java_env->pExtEnv = 0; // no extended support
OSL_ASSERT( 0 != java_env->pContext );
- try
- {
- ((JavaVMContext *)java_env->pContext)->m_extra = new JNI_info( java_env );
- }
- catch (BridgeRuntimeError & err)
- {
-#ifdef _DEBUG
- OStringBuffer buf( 64 );
- buf.append( RTL_CONSTASCII_STRINGPARAM("### error initializing (jni) java environment: ") );
- buf.append( OUStringToOString( err.m_message, RTL_TEXTENCODING_ASCII_US ) );
- OString msg( buf.makeStringAndClear() );
- OSL_ENSURE( 0, msg.getStr() );
-#endif
- }
+
+ ::jvmaccess::VirtualMachine * machine =
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >( java_env->pContext );
+ machine->acquire();
}
//##################################################################################################
void SAL_CALL uno_ext_getMapping(
@@ -467,24 +396,37 @@ void SAL_CALL uno_ext_getMapping(
uno_Mapping * mapping = 0;
- if (from_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_JAVA) ) &&
- to_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) ))
+ try
+ {
+ if (from_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_JAVA) ) &&
+ to_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) ))
+ {
+ Bridge * bridge = new Bridge( pFrom, pTo->pExtEnv ); // ref count = 0
+ bridge->acquire(); // 0->1 registers both mappings
+ mapping = &bridge->m_java2uno;
+ }
+ else if (from_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) ) &&
+ to_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_JAVA) ))
+ {
+ Bridge * bridge = new Bridge( pTo, pFrom->pExtEnv ); // ref count = 0
+ bridge->acquire(); // 0->1 registers both mappings
+ mapping = &bridge->m_uno2java;
+ }
+ }
+ catch (BridgeRuntimeError & err)
{
- jni_Bridge * bridge = new jni_Bridge( pFrom, pTo->pExtEnv, true ); // ref count = 1
- mapping = &bridge->m_java2uno;
- uno_registerMapping(
- &mapping, jni_Bridge_free,
- pFrom, (uno_Environment *)pTo->pExtEnv, 0 );
+#ifdef _DEBUG
+ OString cstr_msg(
+ OUStringToOString(
+ OUSTR("[jni_uno bridge error] ") + err.m_message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
+#endif
}
- else if (from_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) ) &&
- to_env_typename.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_JAVA) ))
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
{
- jni_Bridge * bridge = new jni_Bridge( pTo, pFrom->pExtEnv, false ); // ref count = 1
- mapping = &bridge->m_uno2java;
- uno_registerMapping(
- &mapping, jni_Bridge_free,
- (uno_Environment *)pFrom->pExtEnv, pTo, 0 );
+ OSL_ENSURE( 0, "[jni_uno bridge error] attaching current thread to java failed!" );
}
+
*ppMapping = mapping;
}
}
diff --git a/bridges/source/jni_uno/jni_bridge.h b/bridges/source/jni_uno/jni_bridge.h
index e3ad9d2b4a7a..cdb73b177c1e 100644
--- a/bridges/source/jni_uno/jni_bridge.h
+++ b/bridges/source/jni_uno/jni_bridge.h
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_bridge.h,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dbo $ $Date: 2002-11-01 14:24:56 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,64 +58,60 @@
*
*
************************************************************************/
-#ifndef _JNI_BRIDGE_H_
-#define _JNI_BRIDGE_H_
+#if ! defined INCLUDED_JNI_BRIDGE_H
+#define INCLUDED_JNI_BRIDGE_H
#include "jni_base.h"
#include "jni_info.h"
#include "jni_helper.h"
-#include <bridges/java/jvmcontext.hxx>
+#include "osl/diagnose.h"
+#include "osl/interlck.h"
-#include <osl/diagnose.h>
-#include <osl/interlck.h>
+#include "uno/mapping.h"
+#include "uno/dispatcher.h"
-#include <uno/mapping.h>
-#include <uno/dispatcher.h>
+#include "com/sun/star/uno/XInterface.hpp"
-#include <com/sun/star/uno/XInterface.hpp>
-
-namespace jni_bridge
+namespace jni_uno
{
//==== holds environments and mappings =============================================================
-struct jni_Bridge;
-struct jni_Mapping : public uno_Mapping
+struct Bridge;
+struct Mapping : public uno_Mapping
{
- jni_Bridge * m_bridge;
+ Bridge * m_bridge;
};
//==================================================================================================
-struct jni_Bridge
+struct Bridge
{
mutable oslInterlockedCount m_ref;
uno_ExtEnvironment * m_uno_env;
uno_Environment * m_java_env;
- JNI_info const * m_jni_info;
- jni_Mapping m_java2uno;
- jni_Mapping m_uno2java;
+ Mapping m_java2uno;
+ Mapping m_uno2java;
- bool m_registered_java2uno;
+ JNI_info const * m_jni_info;
- ~jni_Bridge() SAL_THROW( () );
- jni_Bridge(
- uno_Environment * java_env, uno_ExtEnvironment * uno_env,
- bool register_java2uno ) SAL_THROW( () );
+ //
+ ~Bridge() SAL_THROW( () );
+ Bridge( uno_Environment * java_env, uno_ExtEnvironment * uno_env );
- void acquire() const SAL_THROW( () );
- void release() const SAL_THROW( () );
+ void acquire() const;
+ void release() const;
// jni_data.cxx
void map_to_uno(
- JNI_attach const & attach,
+ JNI_context const & jni,
void * uno_data, jvalue java_data,
typelib_TypeDescriptionReference * type, JNI_type_info const * info /* maybe 0 */,
bool assign, bool out_param,
bool special_wrapped_integral_types = false ) const;
void map_to_java(
- JNI_attach const & attach,
+ JNI_context const & jni,
jvalue * java_data, void const * uno_data,
typelib_TypeDescriptionReference * type, JNI_type_info const * info /* maybe 0 */,
bool in_param, bool out_param,
@@ -123,27 +119,27 @@ struct jni_Bridge
// jni_uno2java.cxx
void handle_uno_exc(
- JNI_attach const & attach, uno_Any * uno_exc ) const;
+ JNI_context const & jni, uno_Any * uno_exc ) const;
void call_java(
jobject javaI, JNI_type_info const * info, sal_Int32 function_pos,
typelib_TypeDescriptionReference * return_type,
typelib_MethodParameter * params, sal_Int32 nParams,
void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const;
jobject map_uno2java(
- JNI_attach const & attach,
+ JNI_context const & jni,
uno_Interface * pUnoI, JNI_type_info const * info ) const;
// jni_java2uno.cxx
void handle_java_exc(
- JNI_attach const & attach, JLocalAutoRef const & jo_exc, uno_Any * uno_exc ) const;
+ JNI_context const & jni, JLocalAutoRef const & jo_exc, uno_Any * uno_exc ) const;
jobject call_uno(
- JNI_attach const & attach,
+ JNI_context const & jni,
uno_Interface * pUnoI, typelib_TypeDescription * member_td,
typelib_TypeDescriptionReference * return_tdref,
sal_Int32 nParams, typelib_MethodParameter const * pParams,
jobjectArray jo_args ) const;
uno_Interface * map_java2uno(
- JNI_attach const & attach,
+ JNI_context const & jni,
jobject javaI, JNI_type_info const * info ) const;
};
diff --git a/bridges/source/jni_uno/jni_data.cxx b/bridges/source/jni_uno/jni_data.cxx
index e9e01a6e0ea5..5471f445520c 100644
--- a/bridges/source/jni_uno/jni_data.cxx
+++ b/bridges/source/jni_uno/jni_data.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_data.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: dbo $ $Date: 2002-11-28 17:31:02 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,15 +61,15 @@
#include "jni_bridge.h"
-#include <rtl/strbuf.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <uno/sequence2.h>
+#include "rtl/strbuf.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "uno/sequence2.h"
using namespace ::std;
using namespace ::rtl;
-namespace jni_bridge
+namespace jni_uno
{
//--------------------------------------------------------------------------------------------------
@@ -84,29 +84,29 @@ inline auto_ptr< rtl_mem > seq_allocate( sal_Int32 nElements, sal_Int32 nSize )
}
//__________________________________________________________________________________________________
-void jni_Bridge::map_to_uno(
- JNI_attach const & attach,
+void Bridge::map_to_uno(
+ JNI_context const & jni,
void * uno_data, jvalue java_data,
typelib_TypeDescriptionReference * type, JNI_type_info const * info /* maybe 0 */,
bool assign, bool out_param,
bool special_wrapped_integral_types ) const
{
- OSL_ASSERT( !out_param || (1 == attach->GetArrayLength( (jarray)java_data.l )) );
+ OSL_ASSERT( !out_param || (1 == jni->GetArrayLength( (jarray)java_data.l )) );
switch (type->eTypeClass)
{
case typelib_TypeClass_CHAR:
if (out_param)
{
- attach->GetCharArrayRegion(
+ jni->GetCharArrayRegion(
(jcharArray)java_data.l, 0, 1, (jchar *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jchar *)uno_data = attach->CallCharMethodA(
+ *(jchar *)uno_data = jni->CallCharMethodA(
java_data.l, m_jni_info->m_method_Character_charValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -116,15 +116,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_BOOLEAN:
if (out_param)
{
- attach->GetBooleanArrayRegion(
+ jni->GetBooleanArrayRegion(
(jbooleanArray)java_data.l, 0, 1, (jboolean *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jboolean *)uno_data = attach->CallBooleanMethodA(
+ *(jboolean *)uno_data = jni->CallBooleanMethodA(
java_data.l, m_jni_info->m_method_Boolean_booleanValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -134,15 +134,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_BYTE:
if (out_param)
{
- attach->GetByteArrayRegion(
+ jni->GetByteArrayRegion(
(jbyteArray)java_data.l, 0, 1, (jbyte *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jbyte *)uno_data = attach->CallByteMethodA(
+ *(jbyte *)uno_data = jni->CallByteMethodA(
java_data.l, m_jni_info->m_method_Byte_byteValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -153,15 +153,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_UNSIGNED_SHORT:
if (out_param)
{
- attach->GetShortArrayRegion(
+ jni->GetShortArrayRegion(
(jshortArray)java_data.l, 0, 1, (jshort *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jshort *)uno_data = attach->CallShortMethodA(
+ *(jshort *)uno_data = jni->CallShortMethodA(
java_data.l, m_jni_info->m_method_Short_shortValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -172,15 +172,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_UNSIGNED_LONG:
if (out_param)
{
- attach->GetIntArrayRegion(
+ jni->GetIntArrayRegion(
(jintArray)java_data.l, 0, 1, (jint *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jint *)uno_data = attach->CallIntMethodA(
+ *(jint *)uno_data = jni->CallIntMethodA(
java_data.l, m_jni_info->m_method_Integer_intValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -191,15 +191,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_UNSIGNED_HYPER:
if (out_param)
{
- attach->GetLongArrayRegion(
+ jni->GetLongArrayRegion(
(jlongArray)java_data.l, 0, 1, (jlong *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jlong *)uno_data = attach->CallLongMethodA(
+ *(jlong *)uno_data = jni->CallLongMethodA(
java_data.l, m_jni_info->m_method_Long_longValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -209,15 +209,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_FLOAT:
if (out_param)
{
- attach->GetFloatArrayRegion(
+ jni->GetFloatArrayRegion(
(jfloatArray)java_data.l, 0, 1, (jfloat *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jfloat *)uno_data = attach->CallFloatMethodA(
+ *(jfloat *)uno_data = jni->CallFloatMethodA(
java_data.l, m_jni_info->m_method_Float_floatValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -227,15 +227,15 @@ void jni_Bridge::map_to_uno(
case typelib_TypeClass_DOUBLE:
if (out_param)
{
- attach->GetDoubleArrayRegion(
+ jni->GetDoubleArrayRegion(
(jdoubleArray)java_data.l, 0, 1, (jdouble *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else if (special_wrapped_integral_types)
{
- *(jdouble *)uno_data = attach->CallDoubleMethodA(
+ *(jdouble *)uno_data = jni->CallDoubleMethodA(
java_data.l, m_jni_info->m_method_Double_doubleValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -244,12 +244,11 @@ void jni_Bridge::map_to_uno(
break;
case typelib_TypeClass_STRING:
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
if (0 == java_data.l)
@@ -263,17 +262,16 @@ void jni_Bridge::map_to_uno(
if (! assign)
*(rtl_uString **)uno_data = 0;
jstring_to_ustring(
- attach, (rtl_uString **)uno_data, (jstring)java_data.l );
+ jni, (rtl_uString **)uno_data, (jstring)java_data.l );
break;
}
case typelib_TypeClass_TYPE:
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
if (0 == java_data.l)
@@ -287,7 +285,7 @@ void jni_Bridge::map_to_uno(
// type name
JLocalAutoRef jo_type_name(
- attach, attach->GetObjectField( java_data.l, m_jni_info->m_field_Type__typeName ) );
+ jni, jni->GetObjectField( java_data.l, m_jni_info->m_field_Type__typeName ) );
if (! jo_type_name.is())
{
OUStringBuffer buf( 128 );
@@ -297,7 +295,7 @@ void jni_Bridge::map_to_uno(
RTL_CONSTASCII_STRINGPARAM("] incomplete type object: no type name!") );
throw BridgeRuntimeError( buf.makeStringAndClear() );
}
- OUString type_name( jstring_to_oustring( attach, (jstring)jo_type_name.get() ) );
+ OUString type_name( jstring_to_oustring( jni, (jstring)jo_type_name.get() ) );
::com::sun::star::uno::TypeDescription td( type_name );
if (! td.is())
{
@@ -319,12 +317,11 @@ void jni_Bridge::map_to_uno(
}
case typelib_TypeClass_ANY: // xxx todo: possible opt on anys
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
if (0 == java_data.l)
@@ -347,24 +344,23 @@ void jni_Bridge::map_to_uno(
// dynamic type
JLocalAutoRef jo_class(
- attach, attach->CallObjectMethodA(
+ jni, jni->CallObjectMethodA(
java_data.l, m_jni_info->m_method_Object_getClass, 0 ) );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
jvalue arg;
arg.l = jo_class.get();
bool is_any =
- (JNI_FALSE != attach->CallBooleanMethodA(
+ (JNI_FALSE != jni->CallBooleanMethodA(
m_jni_info->m_class_Any, m_jni_info->m_method_Object_equals, &arg ));
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
- JLocalAutoRef jo_type;
- JLocalAutoRef jo_wrapped_holder;
+ JLocalAutoRef jo_type( jni );
+ JLocalAutoRef jo_wrapped_holder( jni );
if (is_any)
{
// wrapped value type
- jo_type.reset(
- attach, attach->GetObjectField( java_data.l, m_jni_info->m_field_Any__type ) );
+ jo_type.reset( jni->GetObjectField( java_data.l, m_jni_info->m_field_Any__type ) );
if (! jo_type.is())
{
OUStringBuffer buf( 128 );
@@ -376,33 +372,31 @@ void jni_Bridge::map_to_uno(
}
// wrapped value
jo_wrapped_holder.reset(
- attach, attach->GetObjectField( java_data.l, m_jni_info->m_field_Any__object ) );
+ jni->GetObjectField( java_data.l, m_jni_info->m_field_Any__object ) );
java_data.l = jo_wrapped_holder.get();
}
else
{
// check whether this is a proxy
- if (JNI_FALSE != attach->IsAssignableFrom(
+ if (JNI_FALSE != jni->IsAssignableFrom(
(jclass)jo_class.get(), m_jni_info->m_class_TypedProxy ))
{
// is proxy => determine exact type
- jo_type.reset(
- attach, attach->CallObjectMethodA(
- java_data.l, m_jni_info->m_method_TypedProxy_getType, 0 ) );
- attach.ensure_no_exception();
+ jo_type.reset( jni->CallObjectMethodA(
+ java_data.l, m_jni_info->m_method_TypedProxy_getType, 0 ) );
+ jni.ensure_no_exception();
}
else
{
- jo_type.reset(
- attach, create_type( attach, (jclass)jo_class.get() ) );
+ jo_type.reset( create_type( jni, (jclass)jo_class.get() ) );
}
}
// get type name
JLocalAutoRef jo_type_name(
- attach, attach->GetObjectField( jo_type.get(), m_jni_info->m_field_Type__typeName ) );
- attach.ensure_no_exception();
- OUString type_name( jstring_to_oustring( attach, (jstring)jo_type_name.get() ) );
+ jni, jni->GetObjectField( jo_type.get(), m_jni_info->m_field_Type__typeName ) );
+ jni.ensure_no_exception();
+ OUString type_name( jstring_to_oustring( jni, (jstring)jo_type_name.get() ) );
::com::sun::star::uno::TypeDescription value_td( type_name );
if (! value_td.is())
@@ -421,7 +415,7 @@ void jni_Bridge::map_to_uno(
if (typelib_TypeClass_ANY == type_class)
{
map_to_uno(
- attach, uno_data, java_data, value_td.get()->pWeakRef, 0,
+ jni, uno_data, java_data, value_td.get()->pWeakRef, 0,
assign, false /* no out param */ );
break;
}
@@ -437,51 +431,51 @@ void jni_Bridge::map_to_uno(
break;
case typelib_TypeClass_CHAR:
pAny->pData = &pAny->pReserved;
- *(jchar *)&pAny->pReserved = attach->CallCharMethodA(
+ *(jchar *)&pAny->pReserved = jni->CallCharMethodA(
java_data.l, m_jni_info->m_method_Character_charValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_BOOLEAN:
pAny->pData = &pAny->pReserved;
- *(jboolean *)&pAny->pReserved = attach->CallBooleanMethodA(
+ *(jboolean *)&pAny->pReserved = jni->CallBooleanMethodA(
java_data.l, m_jni_info->m_method_Boolean_booleanValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_BYTE:
pAny->pData = &pAny->pReserved;
- *(jbyte *)&pAny->pReserved = attach->CallByteMethodA(
+ *(jbyte *)&pAny->pReserved = jni->CallByteMethodA(
java_data.l, m_jni_info->m_method_Byte_byteValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
pAny->pData = &pAny->pReserved;
- *(jshort *)&pAny->pReserved = attach->CallShortMethodA(
+ *(jshort *)&pAny->pReserved = jni->CallShortMethodA(
java_data.l, m_jni_info->m_method_Short_shortValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
pAny->pData = &pAny->pReserved;
- *(jint *)&pAny->pReserved = attach->CallIntMethodA(
+ *(jint *)&pAny->pReserved = jni->CallIntMethodA(
java_data.l, m_jni_info->m_method_Integer_intValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
if (sizeof (sal_Int64) <= sizeof (void *))
{
pAny->pData = &pAny->pReserved;
- *(jlong *)&pAny->pReserved = attach->CallLongMethodA(
+ *(jlong *)&pAny->pReserved = jni->CallLongMethodA(
java_data.l, m_jni_info->m_method_Long_longValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (sal_Int64) ) );
- *(jlong *)mem.get() = attach->CallLongMethodA(
+ *(jlong *)mem.get() = jni->CallLongMethodA(
java_data.l, m_jni_info->m_method_Long_longValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
pAny->pData = mem.release();
}
break;
@@ -489,16 +483,16 @@ void jni_Bridge::map_to_uno(
if (sizeof (float) <= sizeof (void *))
{
pAny->pData = &pAny->pReserved;
- *(jfloat *)&pAny->pReserved = attach->CallFloatMethodA(
+ *(jfloat *)&pAny->pReserved = jni->CallFloatMethodA(
java_data.l, m_jni_info->m_method_Float_floatValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (float) ) );
- *(jfloat *)mem.get() = attach->CallFloatMethodA(
+ *(jfloat *)mem.get() = jni->CallFloatMethodA(
java_data.l, m_jni_info->m_method_Float_floatValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
pAny->pData = mem.release();
}
break;
@@ -506,16 +500,16 @@ void jni_Bridge::map_to_uno(
if (sizeof (double) <= sizeof (void *))
{
pAny->pData = &pAny->pReserved;
- *(jdouble *)&pAny->pReserved = attach->CallDoubleMethodA(
+ *(jdouble *)&pAny->pReserved = jni->CallDoubleMethodA(
java_data.l, m_jni_info->m_method_Double_doubleValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (double) ) );
- *(jdouble *)mem.get() = attach->CallDoubleMethodA(
+ *(jdouble *)mem.get() = jni->CallDoubleMethodA(
java_data.l, m_jni_info->m_method_Double_doubleValue, 0 );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
pAny->pData = mem.release();
}
break;
@@ -523,7 +517,7 @@ void jni_Bridge::map_to_uno(
pAny->pData = &pAny->pReserved;
pAny->pReserved = 0;
jstring_to_ustring(
- attach, (rtl_uString **)&pAny->pReserved, (jstring)java_data.l );
+ jni, (rtl_uString **)&pAny->pReserved, (jstring)java_data.l );
break;
case typelib_TypeClass_TYPE:
case typelib_TypeClass_ENUM:
@@ -532,7 +526,7 @@ void jni_Bridge::map_to_uno(
pAny->pData = &pAny->pReserved;
pAny->pReserved = 0;
map_to_uno(
- attach, &pAny->pReserved, java_data, value_td.get()->pWeakRef, 0,
+ jni, &pAny->pReserved, java_data, value_td.get()->pWeakRef, 0,
false /* no assign */, false /* no out param */ );
break;
case typelib_TypeClass_STRUCT:
@@ -540,7 +534,7 @@ void jni_Bridge::map_to_uno(
{
auto_ptr< rtl_mem > mem( rtl_mem::allocate( value_td.get()->nSize ) );
map_to_uno(
- attach, mem.get(), java_data, value_td.get()->pWeakRef, 0,
+ jni, mem.get(), java_data, value_td.get()->pWeakRef, 0,
false /* no assign */, false /* no out param */ );
pAny->pData = mem.release();
break;
@@ -567,12 +561,11 @@ void jni_Bridge::map_to_uno(
}
case typelib_TypeClass_ENUM:
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
if (0 == java_data.l)
@@ -584,19 +577,18 @@ void jni_Bridge::map_to_uno(
throw BridgeRuntimeError( buf.makeStringAndClear() );
}
- *(jint *)uno_data = attach->GetIntField(
+ *(jint *)uno_data = jni->GetIntField(
java_data.l, m_jni_info->m_field_Enum_m_value );
break;
}
case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION:
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
if (0 == java_data.l)
@@ -611,7 +603,7 @@ void jni_Bridge::map_to_uno(
if (0 == info)
{
TypeDescr td( type );
- info = m_jni_info->get_type_info( attach, td.get() );
+ info = m_jni_info->get_type_info( jni, td.get() );
}
typelib_CompoundTypeDescription * comp_td =
(typelib_CompoundTypeDescription *)info->m_td.get();
@@ -623,7 +615,7 @@ void jni_Bridge::map_to_uno(
if (0 != comp_td->pBaseTypeDescription)
{
map_to_uno(
- attach, uno_data, java_data,
+ jni, uno_data, java_data,
((typelib_TypeDescription *)comp_td->pBaseTypeDescription)->pWeakRef,
info->m_base,
assign, false /* no out param */ );
@@ -637,35 +629,35 @@ void jni_Bridge::map_to_uno(
switch (member_type->eTypeClass)
{
case typelib_TypeClass_CHAR:
- *(jchar *)p = attach->GetCharField( java_data.l, field_id );
+ *(jchar *)p = jni->GetCharField( java_data.l, field_id );
break;
case typelib_TypeClass_BOOLEAN:
- *(jboolean *)p = attach->GetBooleanField( java_data.l, field_id );
+ *(jboolean *)p = jni->GetBooleanField( java_data.l, field_id );
break;
case typelib_TypeClass_BYTE:
- *(jbyte *)p = attach->GetByteField( java_data.l, field_id );
+ *(jbyte *)p = jni->GetByteField( java_data.l, field_id );
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
- *(jshort *)p = attach->GetShortField( java_data.l, field_id );
+ *(jshort *)p = jni->GetShortField( java_data.l, field_id );
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
- *(jint *)p = attach->GetIntField( java_data.l, field_id );
+ *(jint *)p = jni->GetIntField( java_data.l, field_id );
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
- *(jlong *)p = attach->GetLongField( java_data.l, field_id );
+ *(jlong *)p = jni->GetLongField( java_data.l, field_id );
break;
case typelib_TypeClass_FLOAT:
- *(jfloat *)p = attach->GetFloatField( java_data.l, field_id );
+ *(jfloat *)p = jni->GetFloatField( java_data.l, field_id );
break;
case typelib_TypeClass_DOUBLE:
- *(jdouble *)p = attach->GetDoubleField( java_data.l, field_id );
+ *(jdouble *)p = jni->GetDoubleField( java_data.l, field_id );
break;
default:
{
- JLocalAutoRef jo_field;
+ JLocalAutoRef jo_field( jni );
if (0 == field_id) // special for Message: call Throwable.getMessage()
{
OSL_ASSERT(
@@ -676,17 +668,17 @@ void jni_Bridge::map_to_uno(
OSL_ASSERT( 0 == nPos ); // first member
// call getMessage()
jo_field.reset(
- attach, attach->CallObjectMethodA(
+ jni->CallObjectMethodA(
java_data.l, m_jni_info->m_method_Throwable_getMessage, 0 ) );
}
else
{
jo_field.reset(
- attach, attach->GetObjectField( java_data.l, field_id ) );
+ jni->GetObjectField( java_data.l, field_id ) );
}
jvalue val;
val.l = jo_field.get();
- map_to_uno( attach, p, val, member_type, 0, assign, false /* no out param */ );
+ map_to_uno( jni, p, val, member_type, 0, assign, false /* no out param */ );
break;
}
}
@@ -715,12 +707,11 @@ void jni_Bridge::map_to_uno(
}
case typelib_TypeClass_SEQUENCE:
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
if (0 == java_data.l)
@@ -737,68 +728,68 @@ void jni_Bridge::map_to_uno(
((typelib_IndirectTypeDescription *)td.get())->pType;
auto_ptr< rtl_mem > seq;
- sal_Int32 nElements = attach->GetArrayLength( (jarray)java_data.l );
+ sal_Int32 nElements = jni->GetArrayLength( (jarray)java_data.l );
switch (element_type->eTypeClass)
{
case typelib_TypeClass_CHAR:
seq = seq_allocate( nElements, sizeof (sal_Unicode) );
- attach->GetCharArrayRegion(
+ jni->GetCharArrayRegion(
(jcharArray)java_data.l, 0, nElements,
(jchar *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_BOOLEAN:
seq = seq_allocate( nElements, sizeof (sal_Bool) );
- attach->GetBooleanArrayRegion(
+ jni->GetBooleanArrayRegion(
(jbooleanArray)java_data.l, 0, nElements,
(jboolean *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_BYTE:
seq = seq_allocate( nElements, sizeof (sal_Int8) );
- attach->GetByteArrayRegion(
+ jni->GetByteArrayRegion(
(jbyteArray)java_data.l, 0, nElements,
(jbyte *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
seq = seq_allocate( nElements, sizeof (sal_Int16) );
- attach->GetShortArrayRegion(
+ jni->GetShortArrayRegion(
(jshortArray)java_data.l, 0, nElements,
(jshort *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
seq = seq_allocate( nElements, sizeof (sal_Int32) );
- attach->GetIntArrayRegion(
+ jni->GetIntArrayRegion(
(jintArray)java_data.l, 0, nElements,
(jint *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
seq = seq_allocate( nElements, sizeof (sal_Int64) );
- attach->GetLongArrayRegion(
+ jni->GetLongArrayRegion(
(jlongArray)java_data.l, 0, nElements,
(jlong *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_FLOAT:
seq = seq_allocate( nElements, sizeof (float) );
- attach->GetFloatArrayRegion(
+ jni->GetFloatArrayRegion(
(jfloatArray)java_data.l, 0, nElements,
(jfloat *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_DOUBLE:
seq = seq_allocate( nElements, sizeof (double) );
- attach->GetDoubleArrayRegion(
+ jni->GetDoubleArrayRegion(
(jdoubleArray)java_data.l, 0, nElements,
(jdouble *)((uno_Sequence *)seq.get())->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
case typelib_TypeClass_STRING:
case typelib_TypeClass_TYPE:
@@ -817,7 +808,7 @@ void jni_Bridge::map_to_uno(
typelib_TypeClass_EXCEPTION == element_type->eTypeClass ||
typelib_TypeClass_INTERFACE == element_type->eTypeClass)
{
- element_info = m_jni_info->get_type_info( attach, element_td.get() );
+ element_info = m_jni_info->get_type_info( jni, element_td.get() );
}
else
{
@@ -829,14 +820,14 @@ void jni_Bridge::map_to_uno(
try
{
JLocalAutoRef jo(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, nPos ) );
- attach.ensure_no_exception();
+ jni, jni->GetObjectArrayElement( (jobjectArray)java_data.l, nPos ) );
+ jni.ensure_no_exception();
jvalue val;
val.l = jo.get();
void * p =
((uno_Sequence *)seq.get())->elements + (nPos * element_td.get()->nSize);
map_to_uno(
- attach, p, val, element_td.get()->pWeakRef, element_info,
+ jni, p, val, element_td.get()->pWeakRef, element_info,
false /* no assign */, false /* no out param */ );
}
catch (...)
@@ -872,12 +863,11 @@ void jni_Bridge::map_to_uno(
}
case typelib_TypeClass_INTERFACE:
{
- JLocalAutoRef jo_out_holder;
+ JLocalAutoRef jo_out_holder( jni );
if (out_param)
{
- jo_out_holder.reset(
- attach, attach->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
- attach.ensure_no_exception();
+ jo_out_holder.reset( jni->GetObjectArrayElement( (jobjectArray)java_data.l, 0 ) );
+ jni.ensure_no_exception();
java_data.l = jo_out_holder.get();
}
@@ -896,9 +886,9 @@ void jni_Bridge::map_to_uno(
if (0 == info)
{
TypeDescr td( type );
- info = m_jni_info->get_type_info( attach, td.get() );
+ info = m_jni_info->get_type_info( jni, td.get() );
}
- uno_Interface * pUnoI = map_java2uno( attach, java_data.l, info );
+ uno_Interface * pUnoI = map_java2uno( jni, java_data.l, info );
if (assign)
{
uno_Interface * p = *(uno_Interface **)uno_data;
@@ -925,8 +915,8 @@ void jni_Bridge::map_to_uno(
//##################################################################################################
//__________________________________________________________________________________________________
-void jni_Bridge::map_to_java(
- JNI_attach const & attach,
+void Bridge::map_to_java(
+ JNI_context const & jni,
jvalue * java_data, void const * uno_data,
typelib_TypeDescriptionReference * type, JNI_type_info const * info /* maybe 0 */,
bool in_param, bool out_param,
@@ -939,13 +929,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewCharArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewCharArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetCharArrayRegion(
+ jni->SetCharArrayRegion(
(jcharArray)jo_ar.get(), 0, 1, (jchar *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -953,9 +943,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetCharArrayRegion(
+ jni->SetCharArrayRegion(
(jcharArray)java_data->l, 0, 1, (jchar *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -963,9 +953,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.c = *(jchar const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Character, m_jni_info->m_ctor_Character_with_char, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -977,13 +967,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewBooleanArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewBooleanArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetBooleanArrayRegion(
+ jni->SetBooleanArrayRegion(
(jbooleanArray)jo_ar.get(), 0, 1, (jboolean *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -991,9 +981,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetBooleanArrayRegion(
+ jni->SetBooleanArrayRegion(
(jbooleanArray)java_data->l, 0, 1, (jboolean *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1001,9 +991,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.z = *(jboolean const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Boolean, m_jni_info->m_ctor_Boolean_with_boolean, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1015,13 +1005,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewByteArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewByteArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetByteArrayRegion(
+ jni->SetByteArrayRegion(
(jbyteArray)jo_ar.get(), 0, 1, (jbyte *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -1029,9 +1019,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetByteArrayRegion(
+ jni->SetByteArrayRegion(
(jbyteArray)java_data->l, 0, 1, (jbyte *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1039,9 +1029,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.b = *(jbyte const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Byte, m_jni_info->m_ctor_Byte_with_byte, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1054,13 +1044,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewShortArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewShortArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetShortArrayRegion(
+ jni->SetShortArrayRegion(
(jshortArray)jo_ar.get(), 0, 1, (jshort *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -1068,9 +1058,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetShortArrayRegion(
+ jni->SetShortArrayRegion(
(jshortArray)java_data->l, 0, 1, (jshort *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1078,9 +1068,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.s = *(jshort const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Short, m_jni_info->m_ctor_Short_with_short, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1093,13 +1083,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewIntArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewIntArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetIntArrayRegion(
+ jni->SetIntArrayRegion(
(jintArray)jo_ar.get(), 0, 1, (jint *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -1107,9 +1097,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetIntArrayRegion(
+ jni->SetIntArrayRegion(
(jintArray)java_data->l, 0, 1, (jint *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1117,9 +1107,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.i = *(jint const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Integer, m_jni_info->m_ctor_Integer_with_int, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1132,13 +1122,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewLongArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewLongArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetLongArrayRegion(
+ jni->SetLongArrayRegion(
(jlongArray)jo_ar.get(), 0, 1, (jlong *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -1146,9 +1136,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetLongArrayRegion(
+ jni->SetLongArrayRegion(
(jlongArray)java_data->l, 0, 1, (jlong *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1156,9 +1146,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.j = *(jlong const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Long, m_jni_info->m_ctor_Long_with_long, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1170,13 +1160,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewFloatArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewFloatArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetFloatArrayRegion(
+ jni->SetFloatArrayRegion(
(jfloatArray)jo_ar.get(), 0, 1, (jfloat *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -1184,9 +1174,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetFloatArrayRegion(
+ jni->SetFloatArrayRegion(
(jfloatArray)java_data->l, 0, 1, (jfloat *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1194,9 +1184,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.f = *(jfloat const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Float, m_jni_info->m_ctor_Float_with_float, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1208,13 +1198,13 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_ar( attach, attach->NewDoubleArray( 1 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_ar( jni, jni->NewDoubleArray( 1 ) );
+ jni.ensure_no_exception();
if (in_param)
{
- attach->SetDoubleArrayRegion(
+ jni->SetDoubleArrayRegion(
(jdoubleArray)jo_ar.get(), 0, 1, (jdouble *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
java_data->l = jo_ar.release();
}
@@ -1222,9 +1212,9 @@ void jni_Bridge::map_to_java(
{
if (in_param)
{
- attach->SetDoubleArrayRegion(
+ jni->SetDoubleArrayRegion(
(jdoubleArray)java_data->l, 0, 1, (jdouble *)uno_data );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
}
@@ -1232,9 +1222,9 @@ void jni_Bridge::map_to_java(
{
jvalue arg;
arg.d = *(double const *)uno_data;
- java_data->l = attach->NewObjectA(
+ java_data->l = jni->NewObjectA(
m_jni_info->m_class_Double, m_jni_info->m_ctor_Double_with_double, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1245,29 +1235,28 @@ void jni_Bridge::map_to_java(
{
if (out_param)
{
- JLocalAutoRef jo_in;
+ JLocalAutoRef jo_in( jni );
if (in_param)
{
- jo_in.reset(
- attach, ustring_to_jstring( attach, *(rtl_uString * const *)uno_data ) );
+ jo_in.reset( ustring_to_jstring( jni, *(rtl_uString * const *)uno_data ) );
}
if (0 == java_data->l)
{
- java_data->l = attach->NewObjectArray(
+ java_data->l = jni->NewObjectArray(
1, m_jni_info->m_class_String, jo_in.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_in.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
{
OSL_ASSERT( in_param );
- java_data->l = ustring_to_jstring( attach, *(rtl_uString * const *)uno_data );
+ java_data->l = ustring_to_jstring( jni, *(rtl_uString * const *)uno_data );
}
break;
}
@@ -1275,37 +1264,36 @@ void jni_Bridge::map_to_java(
{
if (out_param)
{
- JLocalAutoRef jo_in;
+ JLocalAutoRef jo_in( jni );
if (in_param)
{
- jo_in.reset(
- attach, create_type(
- attach, *(typelib_TypeDescriptionReference * const *)uno_data ) );
+ jo_in.reset( create_type(
+ jni, *(typelib_TypeDescriptionReference * const *)uno_data ) );
}
if (0 == java_data->l)
{
- java_data->l = attach->NewObjectArray(
+ java_data->l = jni->NewObjectArray(
1, m_jni_info->m_class_Type, jo_in.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_in.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
{
OSL_ASSERT( in_param );
java_data->l = create_type(
- attach, *(typelib_TypeDescriptionReference * const *)uno_data );
+ jni, *(typelib_TypeDescriptionReference * const *)uno_data );
}
break;
}
case typelib_TypeClass_ANY:
{
- JLocalAutoRef jo_any;
+ JLocalAutoRef jo_any( jni );
if (in_param)
{
uno_Any const * pAny = (uno_Any const *)uno_data;
@@ -1314,7 +1302,7 @@ void jni_Bridge::map_to_java(
jvalue args[ 2 ];
// map value
map_to_java(
- attach, args, pAny->pData, pAny->pType, 0,
+ jni, args, pAny->pData, pAny->pType, 0,
true /* in */, false /* no out */, true /* create integral wrappers */ );
switch (pAny->pType->eTypeClass)
{
@@ -1323,19 +1311,19 @@ void jni_Bridge::map_to_java(
case typelib_TypeClass_UNSIGNED_HYPER:
{
// build up com.sun.star.uno.Any
- JLocalAutoRef jo_val( attach, args[ 0 ].l );
- JLocalAutoRef jo_type( attach, create_type( attach, pAny->pType ) );
+ JLocalAutoRef jo_val( jni, args[ 0 ].l );
+ JLocalAutoRef jo_type( jni, create_type( jni, pAny->pType ) );
args[ 0 ].l = jo_type.get();
args[ 1 ].l = jo_val.get();
jo_any.reset(
- attach, attach->NewObjectA(
+ jni->NewObjectA(
m_jni_info->m_class_Any,
m_jni_info->m_ctor_Any_with_Type_Object, args ) );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
break;
}
default:
- jo_any.reset( attach, args[ 0 ].l );
+ jo_any.reset( args[ 0 ].l );
break;
}
}
@@ -1344,15 +1332,15 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- java_data->l = attach->NewObjectArray(
+ java_data->l = jni->NewObjectArray(
1, m_jni_info->m_class_Object, jo_any.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_any.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
@@ -1366,9 +1354,9 @@ void jni_Bridge::map_to_java(
OUString const & type_name = *reinterpret_cast< OUString const * >( &type->pTypeName );
OString class_name(
OUStringToOString( type_name.replace( '.', '/' ), RTL_TEXTENCODING_ASCII_US ) );
- JLocalAutoRef jo_enum_class( attach, find_class( attach, class_name.getStr() ) );
+ JLocalAutoRef jo_enum_class( jni, find_class( jni, class_name.getStr() ) );
- JLocalAutoRef jo_enum;
+ JLocalAutoRef jo_enum( jni );
if (in_param)
{
// call static <enum_class>.fromInt( int )
@@ -1377,31 +1365,30 @@ void jni_Bridge::map_to_java(
sig_buf.append( class_name );
sig_buf.append( ';' );
OString sig( sig_buf.makeStringAndClear() );
- jmethodID method_id = attach->GetStaticMethodID(
+ jmethodID method_id = jni->GetStaticMethodID(
(jclass)jo_enum_class.get(), "fromInt", sig.getStr() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != method_id );
jvalue arg;
arg.i = *(jint const *)uno_data;
- jo_enum.reset(
- attach, attach->CallStaticObjectMethodA(
- (jclass)jo_enum_class.get(), method_id, &arg ) );
- attach.ensure_no_exception();
+ jo_enum.reset( jni->CallStaticObjectMethodA(
+ (jclass)jo_enum_class.get(), method_id, &arg ) );
+ jni.ensure_no_exception();
}
if (out_param)
{
if (0 == java_data->l)
{
- java_data->l = attach->NewObjectArray(
+ java_data->l = jni->NewObjectArray(
1, (jclass)jo_enum_class.get(), jo_enum.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_enum.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
@@ -1416,27 +1403,25 @@ void jni_Bridge::map_to_java(
if (0 == info)
{
TypeDescr td( type );
- info = m_jni_info->get_type_info( attach, td.get() );
+ info = m_jni_info->get_type_info( jni, td.get() );
}
- JLocalAutoRef jo_comp;
+ JLocalAutoRef jo_comp( jni );
if (in_param)
{
if (typelib_TypeClass_EXCEPTION == type->eTypeClass)
{
JLocalAutoRef jo_message(
- attach, ustring_to_jstring( attach, *(rtl_uString **)uno_data ) );
+ jni, ustring_to_jstring( jni, *(rtl_uString **)uno_data ) );
jvalue arg;
arg.l = jo_message.get();
- jo_comp.reset(
- attach, attach->NewObjectA( info->m_class, info->m_ctor, &arg ) );
- attach.ensure_no_exception();
+ jo_comp.reset( jni->NewObjectA( info->m_class, info->m_ctor, &arg ) );
+ jni.ensure_no_exception();
}
else
{
- jo_comp.reset(
- attach, attach->NewObjectA( info->m_class, info->m_ctor, 0 ) );
- attach.ensure_no_exception();
+ jo_comp.reset( jni->NewObjectA( info->m_class, info->m_ctor, 0 ) );
+ jni.ensure_no_exception();
}
for ( JNI_type_info const * linfo = info; 0 != linfo; linfo = linfo->m_base )
@@ -1455,55 +1440,55 @@ void jni_Bridge::map_to_java(
switch (member_type->eTypeClass)
{
case typelib_TypeClass_CHAR:
- attach->SetCharField(
+ jni->SetCharField(
jo_comp.get(), field_id, *(jchar const *)p );
break;
case typelib_TypeClass_BOOLEAN:
- attach->SetBooleanField(
+ jni->SetBooleanField(
jo_comp.get(), field_id, *(jboolean const *)p );
break;
case typelib_TypeClass_BYTE:
- attach->SetByteField(
+ jni->SetByteField(
jo_comp.get(), field_id, *(jbyte const *)p );
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
- attach->SetShortField(
+ jni->SetShortField(
jo_comp.get(), field_id, *(jshort const *)p );
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
- attach->SetIntField(
+ jni->SetIntField(
jo_comp.get(), field_id, *(jint const *)p );
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
- attach->SetLongField(
+ jni->SetLongField(
jo_comp.get(), field_id, *(jlong const *)p );
break;
case typelib_TypeClass_FLOAT:
- attach->SetFloatField(
+ jni->SetFloatField(
jo_comp.get(), field_id, *(jfloat const *)p );
break;
case typelib_TypeClass_DOUBLE:
- attach->SetDoubleField(
+ jni->SetDoubleField(
jo_comp.get(), field_id, *(jdouble const *)p );
break;
case typelib_TypeClass_STRING: // string opt here
{
JLocalAutoRef jo_string(
- attach, ustring_to_jstring( attach, *(rtl_uString * const *)p ) );
- attach->SetObjectField( jo_comp.get(), field_id, jo_string.get() );
+ jni, ustring_to_jstring( jni, *(rtl_uString * const *)p ) );
+ jni->SetObjectField( jo_comp.get(), field_id, jo_string.get() );
break;
}
default:
{
jvalue java_data;
map_to_java(
- attach, &java_data, p, member_type, 0,
+ jni, &java_data, p, member_type, 0,
true /* in */, false /* no out */ );
- JLocalAutoRef jo_obj( attach, java_data.l );
- attach->SetObjectField( jo_comp.get(), field_id, jo_obj.get() );
+ JLocalAutoRef jo_obj( jni, java_data.l );
+ jni->SetObjectField( jo_comp.get(), field_id, jo_obj.get() );
break;
}
}
@@ -1515,14 +1500,14 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- java_data->l = attach->NewObjectArray( 1, info->m_class, jo_comp.get() );
- attach.ensure_no_exception();
+ java_data->l = jni->NewObjectArray( 1, info->m_class, jo_comp.get() );
+ jni.ensure_no_exception();
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_comp.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
@@ -1533,7 +1518,7 @@ void jni_Bridge::map_to_java(
}
case typelib_TypeClass_SEQUENCE: // xxx todo: possible opt for pure out sequences
{
- JLocalAutoRef jo_ar;
+ JLocalAutoRef jo_ar( jni );
sal_Int32 nElements;
uno_Sequence const * seq = 0;
@@ -1554,108 +1539,106 @@ void jni_Bridge::map_to_java(
switch (element_type->eTypeClass)
{
case typelib_TypeClass_CHAR:
- jo_ar.reset( attach, attach->NewCharArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewCharArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetCharArrayRegion(
+ jni->SetCharArrayRegion(
(jcharArray)jo_ar.get(), 0, nElements, (jchar *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_BOOLEAN:
- jo_ar.reset( attach, attach->NewBooleanArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewBooleanArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetBooleanArrayRegion(
+ jni->SetBooleanArrayRegion(
(jbooleanArray)jo_ar.get(), 0, nElements, (jboolean *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_BYTE:
- jo_ar.reset( attach, attach->NewByteArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewByteArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetByteArrayRegion(
+ jni->SetByteArrayRegion(
(jbyteArray)jo_ar.get(), 0, nElements, (jbyte *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
- jo_ar.reset( attach, attach->NewShortArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewShortArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetShortArrayRegion(
+ jni->SetShortArrayRegion(
(jshortArray)jo_ar.get(), 0, nElements, (jshort *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
- jo_ar.reset( attach, attach->NewIntArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewIntArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetIntArrayRegion(
+ jni->SetIntArrayRegion(
(jintArray)jo_ar.get(), 0, nElements, (jint *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
- jo_ar.reset( attach, attach->NewLongArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewLongArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetLongArrayRegion(
+ jni->SetLongArrayRegion(
(jlongArray)jo_ar.get(), 0, nElements, (jlong *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_FLOAT:
- jo_ar.reset( attach, attach->NewFloatArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewFloatArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetFloatArrayRegion(
+ jni->SetFloatArrayRegion(
(jfloatArray)jo_ar.get(), 0, nElements, (jfloat *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_DOUBLE:
- jo_ar.reset( attach, attach->NewDoubleArray( nElements ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewDoubleArray( nElements ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
- attach->SetDoubleArrayRegion(
+ jni->SetDoubleArrayRegion(
(jdoubleArray)jo_ar.get(), 0, nElements, (jdouble *)seq->elements );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
break;
case typelib_TypeClass_STRING:
- jo_ar.reset(
- attach, attach->NewObjectArray( nElements, m_jni_info->m_class_String, 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, m_jni_info->m_class_String, 0 ) );
+ jni.ensure_no_exception();
if (in_param)
{
rtl_uString * const * pp = (rtl_uString * const *)seq->elements;
for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos )
{
- JLocalAutoRef jo_string( attach, ustring_to_jstring( attach, pp[ nPos ] ) );
- attach->SetObjectArrayElement(
+ JLocalAutoRef jo_string( jni, ustring_to_jstring( jni, pp[ nPos ] ) );
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_string.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
case typelib_TypeClass_TYPE:
- jo_ar.reset(
- attach, attach->NewObjectArray( nElements, m_jni_info->m_class_Type, 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, m_jni_info->m_class_Type, 0 ) );
+ jni.ensure_no_exception();
if (in_param)
{
typelib_TypeDescriptionReference * const * pp =
@@ -1664,19 +1647,18 @@ void jni_Bridge::map_to_java(
{
jvalue val;
map_to_java(
- attach, &val, &pp[ nPos ], element_type, 0,
+ jni, &val, &pp[ nPos ], element_type, 0,
true /* in */, false /* no out */ );
- JLocalAutoRef jo_element( attach, val.l );
- attach->SetObjectArrayElement(
+ JLocalAutoRef jo_element( jni, val.l );
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_element.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
case typelib_TypeClass_ANY:
- jo_ar.reset(
- attach, attach->NewObjectArray( nElements, m_jni_info->m_class_Object, 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, m_jni_info->m_class_Object, 0 ) );
+ jni.ensure_no_exception();
if (in_param)
{
uno_Any const * p = (uno_Any const *)seq->elements;
@@ -1684,12 +1666,12 @@ void jni_Bridge::map_to_java(
{
jvalue val;
map_to_java(
- attach, &val, &p[ nPos ], element_type, 0,
+ jni, &val, &p[ nPos ], element_type, 0,
true /* in */, false /* no out */ );
- JLocalAutoRef jo_element( attach, val.l );
- attach->SetObjectArrayElement(
+ JLocalAutoRef jo_element( jni, val.l );
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_element.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
@@ -1701,11 +1683,10 @@ void jni_Bridge::map_to_java(
OUStringToOString(
element_type_name.replace( '.', '/' ),
RTL_TEXTENCODING_ASCII_US ) );
- JLocalAutoRef jo_enum_class( attach, find_class( attach, class_name.getStr() ) );
+ JLocalAutoRef jo_enum_class( jni, find_class( jni, class_name.getStr() ) );
- jo_ar.reset(
- attach, attach->NewObjectArray( nElements, (jclass)jo_enum_class.get(), 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, (jclass)jo_enum_class.get(), 0 ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
@@ -1714,9 +1695,9 @@ void jni_Bridge::map_to_java(
sig_buf.append( RTL_CONSTASCII_STRINGPARAM("(I)") );
sig_buf.append( class_name );
OString sig( sig_buf.makeStringAndClear() );
- jmethodID method_id = attach->GetStaticMethodID(
+ jmethodID method_id = jni->GetStaticMethodID(
(jclass)jo_enum_class.get(), "fromInt", sig.getStr() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != method_id );
sal_Int32 const * p = (sal_Int32 const *)seq->elements;
@@ -1725,12 +1706,12 @@ void jni_Bridge::map_to_java(
jvalue arg;
arg.i = p[ nPos ];
JLocalAutoRef jo_enum(
- attach, attach->CallStaticObjectMethodA(
+ jni, jni->CallStaticObjectMethodA(
(jclass)jo_enum_class.get(), method_id, &arg ) );
- attach.ensure_no_exception();
- attach->SetObjectArrayElement(
+ jni.ensure_no_exception();
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_enum.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
@@ -1740,10 +1721,10 @@ void jni_Bridge::map_to_java(
{
TypeDescr element_td( element_type );
JNI_type_info const * element_info =
- m_jni_info->get_type_info( attach, element_td.get() );
+ m_jni_info->get_type_info( jni, element_td.get() );
- jo_ar.reset( attach, attach->NewObjectArray( nElements, element_info->m_class, 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, element_info->m_class, 0 ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
@@ -1753,12 +1734,12 @@ void jni_Bridge::map_to_java(
{
jvalue val;
map_to_java(
- attach, &val, p + (nSize * nPos), element_type, element_info,
+ jni, &val, p + (nSize * nPos), element_type, element_info,
true /* in */, false /* no out */ );
- JLocalAutoRef jo_element( attach, val.l );
- attach->SetObjectArrayElement(
+ JLocalAutoRef jo_element( jni, val.l );
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_element.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
@@ -1768,11 +1749,10 @@ void jni_Bridge::map_to_java(
OStringBuffer buf( 64 );
m_jni_info->append_sig( &buf, element_type );
OString class_name( buf.makeStringAndClear() );
- JLocalAutoRef jo_seq_class( attach, find_class( attach, class_name.getStr() ) );
+ JLocalAutoRef jo_seq_class( jni, find_class( jni, class_name.getStr() ) );
- jo_ar.reset(
- attach, attach->NewObjectArray( nElements, (jclass)jo_seq_class.get(), 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, (jclass)jo_seq_class.get(), 0 ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
@@ -1782,12 +1762,12 @@ void jni_Bridge::map_to_java(
{
jvalue java_data;
map_to_java(
- attach, &java_data, elements + nPos, element_type, 0,
+ jni, &java_data, elements + nPos, element_type, 0,
true /* in */, false /* no out */ );
- JLocalAutoRef jo_seq( attach, java_data.l );
- attach->SetObjectArrayElement(
+ JLocalAutoRef jo_seq( jni, java_data.l );
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_seq.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
@@ -1796,10 +1776,10 @@ void jni_Bridge::map_to_java(
{
TypeDescr element_td( element_type );
JNI_type_info const * element_info =
- m_jni_info->get_type_info( attach, element_td.get() );
+ m_jni_info->get_type_info( jni, element_td.get() );
- jo_ar.reset( attach, attach->NewObjectArray( nElements, element_info->m_class, 0 ) );
- attach.ensure_no_exception();
+ jo_ar.reset( jni->NewObjectArray( nElements, element_info->m_class, 0 ) );
+ jni.ensure_no_exception();
if (0 < nElements)
{
@@ -1809,12 +1789,12 @@ void jni_Bridge::map_to_java(
{
jvalue val;
map_to_java(
- attach, &val, p + (nSize * nPos), element_type, element_info,
+ jni, &val, p + (nSize * nPos), element_type, element_info,
true /* in */, false /* no out */ );
- JLocalAutoRef jo_element( attach, val.l );
- attach->SetObjectArrayElement(
+ JLocalAutoRef jo_element( jni, val.l );
+ jni->SetObjectArrayElement(
(jobjectArray)jo_ar.get(), nPos, jo_element.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
break;
@@ -1834,24 +1814,24 @@ void jni_Bridge::map_to_java(
{
if (0 == java_data->l)
{
- JLocalAutoRef jo_element_class( attach, get_class( attach, jo_ar.get() ) );
+ JLocalAutoRef jo_element_class( jni, get_class( jni, jo_ar.get() ) );
if (in_param)
{
java_data->l =
- attach->NewObjectArray( 1, (jclass)jo_element_class.get(), jo_ar.get() );
+ jni->NewObjectArray( 1, (jclass)jo_element_class.get(), jo_ar.get() );
}
else
{
java_data->l =
- attach->NewObjectArray( 1, (jclass)jo_element_class.get(), 0 );
+ jni->NewObjectArray( 1, (jclass)jo_element_class.get(), 0 );
}
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_ar.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
@@ -1862,7 +1842,7 @@ void jni_Bridge::map_to_java(
}
case typelib_TypeClass_INTERFACE:
{
- JLocalAutoRef jo_iface;
+ JLocalAutoRef jo_iface( jni );
if (in_param)
{
uno_Interface * pUnoI = *(uno_Interface * const *)uno_data;
@@ -1871,9 +1851,9 @@ void jni_Bridge::map_to_java(
if (0 == info)
{
TypeDescr td( type );
- info = m_jni_info->get_type_info( attach, td.get() );
+ info = m_jni_info->get_type_info( jni, td.get() );
}
- jo_iface.reset( attach, map_uno2java( attach, pUnoI, info ) );
+ jo_iface.reset( map_uno2java( jni, pUnoI, info ) );
}
}
if (out_param)
@@ -1883,9 +1863,9 @@ void jni_Bridge::map_to_java(
if (typelib_typedescriptionreference_equals(
type, m_jni_info->m_XInterface_td.get()->pWeakRef ))
{
- java_data->l = attach->NewObjectArray(
+ java_data->l = jni->NewObjectArray(
1, m_jni_info->m_class_Object, jo_iface.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
else
{
@@ -1896,18 +1876,18 @@ void jni_Bridge::map_to_java(
type_name.replace( '.', '/' ),
RTL_TEXTENCODING_ASCII_US ) );
JLocalAutoRef jo_iface_class(
- attach, find_class( attach, class_name.getStr() ) );
+ jni, find_class( jni, class_name.getStr() ) );
- java_data->l = attach->NewObjectArray(
+ java_data->l = jni->NewObjectArray(
1, (jclass)jo_iface_class.get(), jo_iface.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
{
- attach->SetObjectArrayElement(
+ jni->SetObjectArrayElement(
(jobjectArray)java_data->l, 0, jo_iface.get() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
}
else
diff --git a/bridges/source/jni_uno/jni_helper.h b/bridges/source/jni_uno/jni_helper.h
index d00779aca97d..1238f59b81b6 100644
--- a/bridges/source/jni_uno/jni_helper.h
+++ b/bridges/source/jni_uno/jni_helper.h
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_helper.h,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: dbo $ $Date: 2002-11-01 14:24:57 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,18 +58,18 @@
*
*
************************************************************************/
-#ifndef _JNI_HELPER_H_
-#define _JNI_HELPER_H_
+#if ! defined INCLUDED_JNI_HELPER_H
+#define INCLUDED_JNI_HELPER_H
#include "jni_base.h"
#include "jni_info.h"
-namespace jni_bridge
+namespace jni_uno
{
//--------------------------------------------------------------------------------------------------
-inline void jstring_to_ustring( JNI_attach const & attach, rtl_uString ** out_ustr, jstring jstr )
+inline void jstring_to_ustring( JNI_context const & jni, rtl_uString ** out_ustr, jstring jstr )
{
if (0 == jstr)
{
@@ -77,12 +77,12 @@ inline void jstring_to_ustring( JNI_attach const & attach, rtl_uString ** out_us
}
else
{
- jsize len = attach->GetStringLength( jstr );
+ jsize len = jni->GetStringLength( jstr );
::std::auto_ptr< rtl_mem > mem(
rtl_mem::allocate( sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) );
rtl_uString * ustr = (rtl_uString *)mem.get();
- attach->GetStringRegion( jstr, 0, len, (jchar *)ustr->buffer );
- attach.ensure_no_exception();
+ jni->GetStringRegion( jstr, 0, len, (jchar *)ustr->buffer );
+ jni.ensure_no_exception();
ustr->refCount = 1;
ustr->length = len;
ustr->buffer[ len ] = '\0';
@@ -93,98 +93,98 @@ inline void jstring_to_ustring( JNI_attach const & attach, rtl_uString ** out_us
}
}
//--------------------------------------------------------------------------------------------------
-inline ::rtl::OUString jstring_to_oustring( JNI_attach const & attach, jstring jstr )
+inline ::rtl::OUString jstring_to_oustring( JNI_context const & jni, jstring jstr )
{
rtl_uString * ustr = 0;
- jstring_to_ustring( attach, &ustr, jstr );
+ jstring_to_ustring( jni, &ustr, jstr );
return ::rtl::OUString( ustr, SAL_NO_ACQUIRE );
}
//--------------------------------------------------------------------------------------------------
-inline jstring ustring_to_jstring( JNI_attach const & attach, rtl_uString const * ustr )
+inline jstring ustring_to_jstring( JNI_context const & jni, rtl_uString const * ustr )
{
- jstring jstr = attach->NewString( (jchar const *)ustr->buffer, ustr->length );
- attach.ensure_no_exception();
+ jstring jstr = jni->NewString( (jchar const *)ustr->buffer, ustr->length );
+ jni.ensure_no_exception();
return jstr;
}
//##################################################################################################
//--------------------------------------------------------------------------------------------------
-inline jclass find_class( JNI_attach const & attach, char const * class_name )
+inline jclass find_class( JNI_context const & jni, char const * class_name )
{
- jclass jo_class = attach->FindClass( class_name );
- attach.ensure_no_exception();
+ jclass jo_class = jni->FindClass( class_name );
+ jni.ensure_no_exception();
return jo_class;
}
//--------------------------------------------------------------------------------------------------
-inline jclass find_class( JNI_attach const & attach, ::rtl::OUString const & class_name )
+inline jclass find_class( JNI_context const & jni, ::rtl::OUString const & class_name )
{
::rtl::OString cstr_name( ::rtl::OUStringToOString( class_name, RTL_TEXTENCODING_ASCII_US ) );
- return find_class( attach, cstr_name );
+ return find_class( jni, cstr_name );
}
//--------------------------------------------------------------------------------------------------
-inline jclass get_class( JNI_attach const & attach, jobject jo )
+inline jclass get_class( JNI_context const & jni, jobject jo )
{
- jclass jo_class = (jclass)attach->CallObjectMethodA(
- jo, attach.get_jni_info()->m_method_Object_getClass, 0 );
- attach.ensure_no_exception();
+ jclass jo_class = (jclass)jni->CallObjectMethodA(
+ jo, jni.get_info()->m_method_Object_getClass, 0 );
+ jni.ensure_no_exception();
return jo_class;
}
//--------------------------------------------------------------------------------------------------
-inline ::rtl::OUString get_class_name( JNI_attach const & attach, jobject jo )
+inline ::rtl::OUString get_class_name( JNI_context const & jni, jobject jo )
{
- JLocalAutoRef jo_class( attach, get_class( attach, jo ) );
+ JLocalAutoRef jo_class( jni, get_class( jni, jo ) );
JLocalAutoRef jo_name(
- attach, attach->CallObjectMethodA(
- jo_class.get(), attach.get_jni_info()->m_method_Class_getName, 0 ) );
- attach.ensure_no_exception();
- return jstring_to_oustring( attach, (jstring)jo_name.get() );
+ jni, jni->CallObjectMethodA(
+ jo_class.get(), jni.get_info()->m_method_Class_getName, 0 ) );
+ jni.ensure_no_exception();
+ return jstring_to_oustring( jni, (jstring)jo_name.get() );
}
//##################################################################################################
//--------------------------------------------------------------------------------------------------
-inline jobject create_type( JNI_attach const & attach, jclass clazz )
+inline jobject create_type( JNI_context const & jni, jclass clazz )
{
- JNI_info const * jni_info = attach.get_jni_info();
+ JNI_info const * jni_info = jni.get_info();
jvalue arg;
arg.l = clazz;
jobject jo_type =
- attach->NewObjectA( jni_info->m_class_Type, jni_info->m_ctor_Type_with_Class, &arg );
- attach.ensure_no_exception();
+ jni->NewObjectA( jni_info->m_class_Type, jni_info->m_ctor_Type_with_Class, &arg );
+ jni.ensure_no_exception();
return jo_type;
}
//--------------------------------------------------------------------------------------------------
inline jobject create_type(
- JNI_attach const & attach, typelib_TypeDescriptionReference * type )
+ JNI_context const & jni, typelib_TypeDescriptionReference * type )
{
- JNI_info const * jni_info = attach.get_jni_info();
+ JNI_info const * jni_info = jni.get_info();
jvalue args[ 2 ];
// get type class
args[ 0 ].i = type->eTypeClass;
JLocalAutoRef jo_type_class(
- attach, attach->CallStaticObjectMethodA(
+ jni, jni->CallStaticObjectMethodA(
jni_info->m_class_TypeClass, jni_info->m_method_TypeClass_fromInt, args ) );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
// construct type
- JLocalAutoRef jo_type_name( attach, ustring_to_jstring( attach, type->pTypeName ) );
+ JLocalAutoRef jo_type_name( jni, ustring_to_jstring( jni, type->pTypeName ) );
args[ 0 ].l = jo_type_name.get();
args[ 1 ].l = jo_type_class.get();
- jobject jo_type = attach->NewObjectA(
+ jobject jo_type = jni->NewObjectA(
jni_info->m_class_Type, jni_info->m_ctor_Type_with_Name_TypeClass, args );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
return jo_type;
}
//--------------------------------------------------------------------------------------------------
-inline jobject compute_oid( JNI_attach const & attach, jobject jo )
+inline jobject compute_oid( JNI_context const & jni, jobject jo )
{
- JNI_info const * jni_info = attach.get_jni_info();
+ JNI_info const * jni_info = jni.get_info();
jvalue arg;
arg.l= jo;
- jobject jo_oid = attach->CallStaticObjectMethodA(
+ jobject jo_oid = jni->CallStaticObjectMethodA(
jni_info->m_class_UnoRuntime, jni_info->m_method_UnoRuntime_generateOid, &arg );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
return jo_oid;
}
diff --git a/bridges/source/jni_uno/jni_info.cxx b/bridges/source/jni_uno/jni_info.cxx
index 7eba5f2425c8..3f291a39a1ce 100644
--- a/bridges/source/jni_uno/jni_info.cxx
+++ b/bridges/source/jni_uno/jni_info.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_info.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: dbo $ $Date: 2002-11-01 14:24:57 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,21 +61,21 @@
#include "jni_bridge.h"
-#include <rtl/string.hxx>
-#include <rtl/strbuf.hxx>
-#include <rtl/ustrbuf.hxx>
+#include "rtl/string.hxx"
+#include "rtl/strbuf.hxx"
+#include "rtl/ustrbuf.hxx"
using namespace ::std;
using namespace ::osl;
using namespace ::rtl;
-namespace jni_bridge
+namespace jni_uno
{
//__________________________________________________________________________________________________
JNI_type_info::JNI_type_info(
- JNI_attach const & attach, typelib_InterfaceTypeDescription * td )
+ JNI_context const & jni, typelib_InterfaceTypeDescription * td )
: m_td( (typelib_TypeDescription *)td ),
m_methods( 0 ),
m_fields( 0 )
@@ -94,13 +94,13 @@ JNI_type_info::JNI_type_info(
OString java_name(
OUStringToOString( uno_name.replace( '.', '/' ), RTL_TEXTENCODING_ASCII_US ) );
- JLocalAutoRef jo_class( attach, find_class( attach, java_name.getStr() ) );
+ JLocalAutoRef jo_class( jni, find_class( jni, java_name.getStr() ) );
- JNI_info const * jni_info = attach.get_jni_info();
+ JNI_info const * jni_info = jni.get_info();
// retrieve info for base type
typelib_TypeDescription * base_td = (typelib_TypeDescription *)td->pBaseTypeDescription;
- m_base = (0 == base_td ? 0 : jni_info->get_type_info( attach, base_td ));
+ m_base = (0 == base_td ? 0 : jni_info->get_type_info( jni, base_td ));
// if ! XInterface
if (! typelib_typedescriptionreference_equals(
@@ -142,9 +142,9 @@ JNI_type_info::JNI_type_info(
*reinterpret_cast< OUString const * >( &method_td->aBase.pMemberName ),
RTL_TEXTENCODING_ASCII_US ) );
- m_methods[ nMethodIndex ] = attach->GetMethodID(
+ m_methods[ nMethodIndex ] = jni->GetMethodID(
(jclass)jo_class.get(), method_name.getStr(), method_signature.getStr() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_methods[ nMethodIndex ] );
++nMethodIndex;
}
@@ -173,9 +173,9 @@ JNI_type_info::JNI_type_info(
OString method_name(
OUStringToOString(
name_buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) );
- m_methods[ nMethodIndex ] = attach->GetMethodID(
+ m_methods[ nMethodIndex ] = jni->GetMethodID(
(jclass)jo_class.get(), method_name.getStr(), method_signature.getStr() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_methods[ nMethodIndex ] );
++nMethodIndex;
if (! attribute_td->bReadOnly)
@@ -191,10 +191,10 @@ JNI_type_info::JNI_type_info(
name_buf.append( member_name );
method_name = OUStringToOString(
name_buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US );
- m_methods[ nMethodIndex ] = attach->GetMethodID(
+ m_methods[ nMethodIndex ] = jni->GetMethodID(
(jclass)jo_class.get(), method_name.getStr(),
method_signature.getStr() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_methods[ nMethodIndex ] );
++nMethodIndex;
}
@@ -208,14 +208,14 @@ JNI_type_info::JNI_type_info(
}
}
- JLocalAutoRef jo_type( attach, create_type( attach, (jclass)jo_class.get() ) );
+ JLocalAutoRef jo_type( jni, create_type( jni, (jclass)jo_class.get() ) );
- m_class = (jclass)attach->NewGlobalRef( jo_class.get() );
- m_jo_type = attach->NewGlobalRef( jo_type.get() );
+ m_class = (jclass)jni->NewGlobalRef( jo_class.get() );
+ m_jo_type = jni->NewGlobalRef( jo_type.get() );
}
//__________________________________________________________________________________________________
JNI_type_info::JNI_type_info(
- JNI_attach const & attach, typelib_CompoundTypeDescription * td )
+ JNI_context const & jni, typelib_CompoundTypeDescription * td )
: m_td( (typelib_TypeDescription *)td ),
m_methods( 0 ),
m_fields( 0 )
@@ -234,20 +234,20 @@ JNI_type_info::JNI_type_info(
OString java_name(
OUStringToOString( uno_name.replace( '.', '/' ), RTL_TEXTENCODING_ASCII_US ) );
- JLocalAutoRef jo_class( attach, find_class( attach, java_name.getStr() ) );
+ JLocalAutoRef jo_class( jni, find_class( jni, java_name.getStr() ) );
- JNI_info const * jni_info = attach.get_jni_info();
+ JNI_info const * jni_info = jni.get_info();
// retrieve ctor
- m_ctor = attach->GetMethodID(
+ m_ctor = jni->GetMethodID(
(jclass)jo_class.get(), "<init>",
(typelib_TypeClass_EXCEPTION == m_td.get()->eTypeClass ? "(Ljava/lang/String;)V" : "()V") );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor );
// retrieve info for base type
typelib_TypeDescription * base_td = (typelib_TypeDescription *)td->pBaseTypeDescription;
- m_base = (0 == base_td ? 0 : jni_info->get_type_info( attach, base_td ));
+ m_base = (0 == base_td ? 0 : jni_info->get_type_info( jni, base_td ));
try
{
@@ -261,9 +261,9 @@ JNI_type_info::JNI_type_info(
m_fields = new jfieldID[ 2 ];
m_fields[ 0 ] = 0; // special Throwable.getMessage()
// field Context
- m_fields[ 1 ] = attach->GetFieldID(
+ m_fields[ 1 ] = jni->GetFieldID(
(jclass)jo_class.get(), "Context", "Ljava/lang/Object;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_fields[ 1 ] );
}
else
@@ -283,9 +283,9 @@ JNI_type_info::JNI_type_info(
*reinterpret_cast< OUString const * >( &td->ppMemberNames[ nPos ] ),
RTL_TEXTENCODING_ASCII_US ) );
- m_fields[ nPos ] = attach->GetFieldID(
+ m_fields[ nPos ] = jni->GetFieldID(
(jclass)jo_class.get(), member_name.getStr(), sig.getStr() );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_fields[ nPos ] );
}
}
@@ -296,15 +296,15 @@ JNI_type_info::JNI_type_info(
throw;
}
- m_class = (jclass)attach->NewGlobalRef( jo_class.get() );
+ m_class = (jclass)jni->NewGlobalRef( jo_class.get() );
m_jo_type = 0;
}
//__________________________________________________________________________________________________
-void JNI_type_info::_delete( JNI_attach const & attach, JNI_type_info * that ) SAL_THROW( () )
+void JNI_type_info::_delete( JNI_context const & jni, JNI_type_info * that ) SAL_THROW( () )
{
delete [] that->m_fields;
delete [] that->m_methods;
- attach->DeleteGlobalRef( that->m_class );
+ jni->DeleteGlobalRef( that->m_class );
delete that;
}
@@ -312,7 +312,7 @@ void JNI_type_info::_delete( JNI_attach const & attach, JNI_type_info * that ) S
//__________________________________________________________________________________________________
JNI_type_info const * JNI_info::get_type_info(
- JNI_attach const & attach, typelib_TypeDescription * td ) const
+ JNI_context const & jni, typelib_TypeDescription * td ) const
{
JNI_type_info * info;
@@ -329,10 +329,10 @@ JNI_type_info const * JNI_info::get_type_info(
{
case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION:
- new_info = new JNI_type_info( attach, (typelib_CompoundTypeDescription *)td );
+ new_info = new JNI_type_info( jni, (typelib_CompoundTypeDescription *)td );
break;
case typelib_TypeClass_INTERFACE:
- new_info = new JNI_type_info( attach, (typelib_InterfaceTypeDescription *)td );
+ new_info = new JNI_type_info( jni, (typelib_InterfaceTypeDescription *)td );
break;
default:
throw BridgeRuntimeError(
@@ -353,7 +353,7 @@ JNI_type_info const * JNI_info::get_type_info(
{
info = holder.m_info;
guard.clear();
- JNI_type_info::_delete( attach, new_info );
+ JNI_type_info::_delete( jni, new_info );
}
}
else
@@ -365,7 +365,7 @@ JNI_type_info const * JNI_info::get_type_info(
}
//__________________________________________________________________________________________________
JNI_type_info const * JNI_info::get_type_info(
- JNI_attach const & attach, OUString const & uno_name ) const
+ JNI_context const & jni, OUString const & uno_name ) const
{
JNI_type_info * info;
@@ -384,10 +384,10 @@ JNI_type_info const * JNI_info::get_type_info(
{
case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION:
- new_info = new JNI_type_info( attach, (typelib_CompoundTypeDescription *)td.get() );
+ new_info = new JNI_type_info( jni, (typelib_CompoundTypeDescription *)td.get() );
break;
case typelib_TypeClass_INTERFACE:
- new_info = new JNI_type_info( attach, (typelib_InterfaceTypeDescription *)td.get() );
+ new_info = new JNI_type_info( jni, (typelib_InterfaceTypeDescription *)td.get() );
break;
default:
throw BridgeRuntimeError( OUSTR("unsupported: type info for ") + uno_name );
@@ -406,7 +406,7 @@ JNI_type_info const * JNI_info::get_type_info(
{
info = holder.m_info;
guard.clear();
- JNI_type_info::_delete( attach, new_info );
+ JNI_type_info::_delete( jni, new_info );
}
}
else
@@ -417,8 +417,8 @@ JNI_type_info const * JNI_info::get_type_info(
return info;
}
//__________________________________________________________________________________________________
-JNI_info::JNI_info( uno_Environment * java_env )
- : m_java_env( java_env ), // unacquired pointer to owner
+JNI_info::JNI_info( Bridge const * bridge )
+ : m_bridge( bridge ), // unacquired pointer to owner
m_XInterface_td(
::getCppuType(
(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > const *)0 ) ),
@@ -432,340 +432,359 @@ JNI_info::JNI_info( uno_Environment * java_env )
(::com::sun::star::uno::RuntimeException const *)0 ) ),
m_class_JNI_proxy( 0 )
{
- JNI_attach attach( java_env );
+ JNI_guarded_context jni(
+ this, reinterpret_cast< ::jvmaccess::VirtualMachine * >( m_bridge->m_java_env->pContext ) );
// class lookup
JLocalAutoRef jo_Object(
- attach, find_class( attach, "java/lang/Object" ) );
+ jni, find_class( jni, "java/lang/Object" ) );
JLocalAutoRef jo_Class(
- attach, find_class( attach, "java/lang/Class" ) );
+ jni, find_class( jni, "java/lang/Class" ) );
JLocalAutoRef jo_Throwable(
- attach, find_class( attach, "java/lang/Throwable" ) );
+ jni, find_class( jni, "java/lang/Throwable" ) );
JLocalAutoRef jo_Character(
- attach, find_class( attach, "java/lang/Character" ) );
+ jni, find_class( jni, "java/lang/Character" ) );
JLocalAutoRef jo_Boolean(
- attach, find_class( attach, "java/lang/Boolean" ) );
+ jni, find_class( jni, "java/lang/Boolean" ) );
JLocalAutoRef jo_Byte(
- attach, find_class( attach, "java/lang/Byte" ) );
+ jni, find_class( jni, "java/lang/Byte" ) );
JLocalAutoRef jo_Short(
- attach, find_class( attach, "java/lang/Short" ) );
+ jni, find_class( jni, "java/lang/Short" ) );
JLocalAutoRef jo_Integer(
- attach, find_class( attach, "java/lang/Integer" ) );
+ jni, find_class( jni, "java/lang/Integer" ) );
JLocalAutoRef jo_Long(
- attach, find_class( attach, "java/lang/Long" ) );
+ jni, find_class( jni, "java/lang/Long" ) );
JLocalAutoRef jo_Float(
- attach, find_class( attach, "java/lang/Float" ) );
+ jni, find_class( jni, "java/lang/Float" ) );
JLocalAutoRef jo_Double(
- attach, find_class( attach, "java/lang/Double" ) );
+ jni, find_class( jni, "java/lang/Double" ) );
JLocalAutoRef jo_String(
- attach, find_class( attach, "java/lang/String" ) );
+ jni, find_class( jni, "java/lang/String" ) );
JLocalAutoRef jo_RuntimeException(
- attach, find_class( attach, "com/sun/star/uno/RuntimeException" ) );
+ jni, find_class( jni, "com/sun/star/uno/RuntimeException" ) );
JLocalAutoRef jo_UnoRuntime(
- attach, find_class( attach, "com/sun/star/uno/UnoRuntime" ) );
+ jni, find_class( jni, "com/sun/star/uno/UnoRuntime" ) );
JLocalAutoRef jo_Any(
- attach, find_class( attach, "com/sun/star/uno/Any" ) );
+ jni, find_class( jni, "com/sun/star/uno/Any" ) );
JLocalAutoRef jo_Enum(
- attach, find_class( attach, "com/sun/star/uno/Enum" ) );
+ jni, find_class( jni, "com/sun/star/uno/Enum" ) );
JLocalAutoRef jo_Type(
- attach, find_class( attach, "com/sun/star/uno/Type" ) );
+ jni, find_class( jni, "com/sun/star/uno/Type" ) );
JLocalAutoRef jo_TypeClass(
- attach, find_class( attach, "com/sun/star/uno/TypeClass" ) );
+ jni, find_class( jni, "com/sun/star/uno/TypeClass" ) );
JLocalAutoRef jo_IEnvironment(
- attach, find_class( attach, "com/sun/star/uno/IEnvironment" ) );
+ jni, find_class( jni, "com/sun/star/uno/IEnvironment" ) );
JLocalAutoRef jo_TypedProxy(
- attach, find_class( attach, "com/sun/star/lib/uno/TypedProxy" ) );
+ jni, find_class( jni, "com/sun/star/lib/uno/TypedProxy" ) );
JLocalAutoRef jo_JNI_proxy(
- attach, find_class( attach, "com/sun/star/bridges/jni_uno/JNI_proxy" ) );
+ jni, find_class( jni, "com/sun/star/bridges/jni_uno/JNI_proxy" ) );
// method Object.getClass()
- m_method_Object_getClass = attach->GetMethodID(
+ m_method_Object_getClass = jni->GetMethodID(
(jclass)jo_Object.get(), "getClass", "()Ljava/lang/Class;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Object_getClass );
// method Object.equals()
- m_method_Object_equals = attach->GetMethodID(
+ m_method_Object_equals = jni->GetMethodID(
(jclass)jo_Object.get(), "equals", "(Ljava/lang/Object;)Z" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Object_equals );
// method Object.toString()
- m_method_Object_toString = attach->GetMethodID(
+ m_method_Object_toString = jni->GetMethodID(
(jclass)jo_Object.get(), "toString", "()Ljava/lang/String;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Object_toString );
// method Class.getName()
- m_method_Class_getName = attach->GetMethodID(
+ m_method_Class_getName = jni->GetMethodID(
(jclass)jo_Class.get(), "getName", "()Ljava/lang/String;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Class_getName );
// method Throwable.getMessage()
- m_method_Throwable_getMessage = attach->GetMethodID(
+ m_method_Throwable_getMessage = jni->GetMethodID(
(jclass)jo_Throwable.get(), "getMessage", "()Ljava/lang/String;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Throwable_getMessage );
// method Character.charValue()
- m_method_Character_charValue = attach->GetMethodID(
+ m_method_Character_charValue = jni->GetMethodID(
(jclass)jo_Character.get(), "charValue", "()C" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Character_charValue );
// method Boolean.booleanValue()
- m_method_Boolean_booleanValue = attach->GetMethodID(
+ m_method_Boolean_booleanValue = jni->GetMethodID(
(jclass)jo_Boolean.get(), "booleanValue", "()Z" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Boolean_booleanValue );
// method Byte.byteValue()
- m_method_Byte_byteValue = attach->GetMethodID(
+ m_method_Byte_byteValue = jni->GetMethodID(
(jclass)jo_Byte.get(), "byteValue", "()B" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Byte_byteValue );
// method Short.shortValue()
- m_method_Short_shortValue = attach->GetMethodID(
+ m_method_Short_shortValue = jni->GetMethodID(
(jclass)jo_Short.get(), "shortValue", "()S" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Short_shortValue );
// method Integer.intValue()
- m_method_Integer_intValue = attach->GetMethodID(
+ m_method_Integer_intValue = jni->GetMethodID(
(jclass)jo_Integer.get(), "intValue", "()I" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Integer_intValue );
// method Long.longValue()
- m_method_Long_longValue = attach->GetMethodID(
+ m_method_Long_longValue = jni->GetMethodID(
(jclass)jo_Long.get(), "longValue", "()J" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Long_longValue );
// method Float.floatValue()
- m_method_Float_floatValue = attach->GetMethodID(
+ m_method_Float_floatValue = jni->GetMethodID(
(jclass)jo_Float.get(), "floatValue", "()F" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Float_floatValue );
// method Double.doubleValue()
- m_method_Double_doubleValue = attach->GetMethodID(
+ m_method_Double_doubleValue = jni->GetMethodID(
(jclass)jo_Double.get(), "doubleValue", "()D" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_Double_doubleValue );
// ctor Character( char )
- m_ctor_Character_with_char = attach->GetMethodID(
+ m_ctor_Character_with_char = jni->GetMethodID(
(jclass)jo_Character.get(), "<init>", "(C)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Character_with_char );
// ctor Boolean( boolean )
- m_ctor_Boolean_with_boolean = attach->GetMethodID(
+ m_ctor_Boolean_with_boolean = jni->GetMethodID(
(jclass)jo_Boolean.get(), "<init>", "(Z)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Boolean_with_boolean );
// ctor Byte( byte )
- m_ctor_Byte_with_byte = attach->GetMethodID(
+ m_ctor_Byte_with_byte = jni->GetMethodID(
(jclass)jo_Byte.get(), "<init>", "(B)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Byte_with_byte );
// ctor Short( short )
- m_ctor_Short_with_short = attach->GetMethodID(
+ m_ctor_Short_with_short = jni->GetMethodID(
(jclass)jo_Short.get(), "<init>", "(S)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Short_with_short );
// ctor Integer( int )
- m_ctor_Integer_with_int = attach->GetMethodID(
+ m_ctor_Integer_with_int = jni->GetMethodID(
(jclass)jo_Integer.get(), "<init>", "(I)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Integer_with_int );
// ctor Long( long )
- m_ctor_Long_with_long = attach->GetMethodID(
+ m_ctor_Long_with_long = jni->GetMethodID(
(jclass)jo_Long.get(), "<init>", "(J)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Long_with_long );
// ctor Float( float )
- m_ctor_Float_with_float = attach->GetMethodID(
+ m_ctor_Float_with_float = jni->GetMethodID(
(jclass)jo_Float.get(), "<init>", "(F)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Float_with_float );
// ctor Double( double )
- m_ctor_Double_with_double = attach->GetMethodID(
+ m_ctor_Double_with_double = jni->GetMethodID(
(jclass)jo_Double.get(), "<init>", "(D)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Double_with_double );
// static method UnoRuntime.generateOid()
- m_method_UnoRuntime_generateOid = attach->GetStaticMethodID(
+ m_method_UnoRuntime_generateOid = jni->GetStaticMethodID(
(jclass)jo_UnoRuntime.get(), "generateOid", "(Ljava/lang/Object;)Ljava/lang/String;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_UnoRuntime_generateOid );
// static method UnoRuntime.queryInterface()
- m_method_UnoRuntime_queryInterface = attach->GetStaticMethodID(
+ m_method_UnoRuntime_queryInterface = jni->GetStaticMethodID(
(jclass)jo_UnoRuntime.get(),
"queryInterface", "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)Ljava/lang/Object;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_UnoRuntime_queryInterface );
// field Enum.m_value
- m_field_Enum_m_value = attach->GetFieldID(
+ m_field_Enum_m_value = jni->GetFieldID(
(jclass)jo_Enum.get(), "m_value", "I" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_Enum_m_value );
// static method TypeClass.fromInt()
- m_method_TypeClass_fromInt = attach->GetStaticMethodID(
+ m_method_TypeClass_fromInt = jni->GetStaticMethodID(
(jclass)jo_TypeClass.get(), "fromInt", "(I)Lcom/sun/star/uno/TypeClass;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_TypeClass_fromInt );
// ctor Type( Class )
- m_ctor_Type_with_Class = attach->GetMethodID(
+ m_ctor_Type_with_Class = jni->GetMethodID(
(jclass)jo_Type.get(), "<init>", "(Ljava/lang/Class;)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Type_with_Class );
// ctor Type( String, TypeClass )
- m_ctor_Type_with_Name_TypeClass = attach->GetMethodID(
+ m_ctor_Type_with_Name_TypeClass = jni->GetMethodID(
(jclass)jo_Type.get(), "<init>", "(Ljava/lang/String;Lcom/sun/star/uno/TypeClass;)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Type_with_Name_TypeClass );
// field Type._typeName
- m_field_Type__typeName = attach->GetFieldID(
+ m_field_Type__typeName = jni->GetFieldID(
(jclass)jo_Type.get(), "_typeName", "Ljava/lang/String;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_Type__typeName );
// ctor Any( Type, Object )
- m_ctor_Any_with_Type_Object = attach->GetMethodID(
+ m_ctor_Any_with_Type_Object = jni->GetMethodID(
(jclass)jo_Any.get(), "<init>", "(Lcom/sun/star/uno/Type;Ljava/lang/Object;)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_ctor_Any_with_Type_Object );
// field Any._type
- m_field_Any__type = attach->GetFieldID(
+ m_field_Any__type = jni->GetFieldID(
(jclass)jo_Any.get(), "_type", "Lcom/sun/star/uno/Type;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_Any__type );
// field Any._object
- m_field_Any__object = attach->GetFieldID(
+ m_field_Any__object = jni->GetFieldID(
(jclass)jo_Any.get(), "_object", "Ljava/lang/Object;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_Any__object );
// method IEnvironment.getRegisteredInterface()
- m_method_IEnvironment_getRegisteredInterface = attach->GetMethodID(
+ m_method_IEnvironment_getRegisteredInterface = jni->GetMethodID(
(jclass)jo_IEnvironment.get(), "getRegisteredInterface",
"(Ljava/lang/String;Lcom/sun/star/uno/Type;)Ljava/lang/Object;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_IEnvironment_getRegisteredInterface );
// method IEnvironment.registerInterface()
- m_method_IEnvironment_registerInterface = attach->GetMethodID(
+ m_method_IEnvironment_registerInterface = jni->GetMethodID(
(jclass)jo_IEnvironment.get(), "registerInterface",
"(Ljava/lang/Object;[Ljava/lang/String;Lcom/sun/star/uno/Type;)Ljava/lang/Object;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_IEnvironment_registerInterface );
// method IEnvironment.revokeInterface()
- m_method_IEnvironment_revokeInterface = attach->GetMethodID(
+ m_method_IEnvironment_revokeInterface = jni->GetMethodID(
(jclass)jo_IEnvironment.get(), "revokeInterface",
"(Ljava/lang/String;Lcom/sun/star/uno/Type;)V" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_IEnvironment_revokeInterface );
// method TypedProxy.getType()
- m_method_TypedProxy_getType = attach->GetMethodID(
+ m_method_TypedProxy_getType = jni->GetMethodID(
(jclass)jo_TypedProxy.get(), "getType",
"()Lcom/sun/star/uno/Type;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_TypedProxy_getType );
// static method JNI_proxy.create()
- m_method_JNI_proxy_create = attach->GetStaticMethodID(
+ m_method_JNI_proxy_create = jni->GetStaticMethodID(
(jclass)jo_JNI_proxy.get(), "create",
"(JLcom/sun/star/uno/IEnvironment;JJLcom/sun/star/uno/Type;Ljava/lang/String;)Ljava/lang/Object;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_method_JNI_proxy_create );
// field JNI_proxy.m_receiver_handle
- m_field_JNI_proxy_m_receiver_handle = attach->GetFieldID(
+ m_field_JNI_proxy_m_receiver_handle = jni->GetFieldID(
(jclass)jo_JNI_proxy.get(), "m_receiver_handle", "J" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_JNI_proxy_m_receiver_handle );
// field JNI_proxy.m_td_handle
- m_field_JNI_proxy_m_td_handle = attach->GetFieldID(
+ m_field_JNI_proxy_m_td_handle = jni->GetFieldID(
(jclass)jo_JNI_proxy.get(), "m_td_handle", "J" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_JNI_proxy_m_td_handle );
// field JNI_proxy.m_type
- m_field_JNI_proxy_m_type = attach->GetFieldID(
+ m_field_JNI_proxy_m_type = jni->GetFieldID(
(jclass)jo_JNI_proxy.get(), "m_type", "Lcom/sun/star/uno/Type;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_JNI_proxy_m_type );
// field JNI_proxy.m_oid
- m_field_JNI_proxy_m_oid = attach->GetFieldID(
+ m_field_JNI_proxy_m_oid = jni->GetFieldID(
(jclass)jo_JNI_proxy.get(), "m_oid", "Ljava/lang/String;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != m_field_JNI_proxy_m_oid );
// get java env
- JLocalAutoRef jo_java( attach, ustring_to_jstring( attach, java_env->pTypeName ) );
+ JLocalAutoRef jo_java( jni, ustring_to_jstring( jni, m_bridge->m_java_env->pTypeName ) );
jvalue args[ 2 ];
args[ 0 ].l = jo_java.get();
args[ 1 ].l = 0;
- jmethodID method_getEnvironment = attach->GetStaticMethodID(
+ jmethodID method_getEnvironment = jni->GetStaticMethodID(
(jclass)jo_UnoRuntime.get(), "getEnvironment",
"(Ljava/lang/String;Ljava/lang/Object;)Lcom/sun/star/uno/IEnvironment;" );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
OSL_ASSERT( 0 != method_getEnvironment );
JLocalAutoRef jo_java_env(
- attach, attach->CallStaticObjectMethodA(
+ jni, jni->CallStaticObjectMethodA(
(jclass)jo_UnoRuntime.get(), method_getEnvironment, args ) );
// make global refs
- m_class_UnoRuntime = (jclass)attach->NewGlobalRef( jo_UnoRuntime.get() );
- m_class_RuntimeException = (jclass)attach->NewGlobalRef( jo_RuntimeException.get() );
- m_class_Any = (jclass)attach->NewGlobalRef( jo_Any.get() );
- m_class_Type = (jclass)attach->NewGlobalRef( jo_Type.get() );
- m_class_TypeClass = (jclass)attach->NewGlobalRef( jo_TypeClass.get() );
- m_class_TypedProxy = (jclass)attach->NewGlobalRef( jo_TypedProxy.get() );
- m_class_JNI_proxy = (jclass)attach->NewGlobalRef( jo_JNI_proxy.get() );
-
- m_class_Character = (jclass)attach->NewGlobalRef( jo_Character.get() );
- m_class_Boolean = (jclass)attach->NewGlobalRef( jo_Boolean.get() );
- m_class_Byte = (jclass)attach->NewGlobalRef( jo_Byte.get() );
- m_class_Short = (jclass)attach->NewGlobalRef( jo_Short.get() );
- m_class_Integer = (jclass)attach->NewGlobalRef( jo_Integer.get() );
- m_class_Long = (jclass)attach->NewGlobalRef( jo_Long.get() );
- m_class_Float = (jclass)attach->NewGlobalRef( jo_Float.get() );
- m_class_Double = (jclass)attach->NewGlobalRef( jo_Double.get() );
- m_class_String = (jclass)attach->NewGlobalRef( jo_String.get() );
- m_class_Object = (jclass)attach->NewGlobalRef( jo_Object.get() );
-
- m_object_java_env = attach->NewGlobalRef( jo_java_env.get() );
+ m_class_UnoRuntime = (jclass)jni->NewGlobalRef( jo_UnoRuntime.get() );
+ m_class_RuntimeException = (jclass)jni->NewGlobalRef( jo_RuntimeException.get() );
+ m_class_Any = (jclass)jni->NewGlobalRef( jo_Any.get() );
+ m_class_Type = (jclass)jni->NewGlobalRef( jo_Type.get() );
+ m_class_TypeClass = (jclass)jni->NewGlobalRef( jo_TypeClass.get() );
+ m_class_TypedProxy = (jclass)jni->NewGlobalRef( jo_TypedProxy.get() );
+ m_class_JNI_proxy = (jclass)jni->NewGlobalRef( jo_JNI_proxy.get() );
+
+ m_class_Character = (jclass)jni->NewGlobalRef( jo_Character.get() );
+ m_class_Boolean = (jclass)jni->NewGlobalRef( jo_Boolean.get() );
+ m_class_Byte = (jclass)jni->NewGlobalRef( jo_Byte.get() );
+ m_class_Short = (jclass)jni->NewGlobalRef( jo_Short.get() );
+ m_class_Integer = (jclass)jni->NewGlobalRef( jo_Integer.get() );
+ m_class_Long = (jclass)jni->NewGlobalRef( jo_Long.get() );
+ m_class_Float = (jclass)jni->NewGlobalRef( jo_Float.get() );
+ m_class_Double = (jclass)jni->NewGlobalRef( jo_Double.get() );
+ m_class_String = (jclass)jni->NewGlobalRef( jo_String.get() );
+ m_class_Object = (jclass)jni->NewGlobalRef( jo_Object.get() );
+
+ m_object_java_env = jni->NewGlobalRef( jo_java_env.get() );
}
//__________________________________________________________________________________________________
JNI_info::~JNI_info() SAL_THROW( () )
{
- JNI_attach attach( m_java_env );
+ try
+ {
+ JNI_guarded_context jni(
+ this,
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >( m_bridge->m_java_env->pContext ) );
+
+ t_str2type::const_iterator iPos( m_type_map.begin() );
+ t_str2type::const_iterator const iEnd( m_type_map.begin() );
+ for ( ; iPos != iEnd; ++iPos )
+ {
+ JNI_type_info::_delete( jni, iPos->second.m_info );
+ }
- t_str2type::const_iterator iPos( m_type_map.begin() );
- t_str2type::const_iterator const iEnd( m_type_map.begin() );
- for ( ; iPos != iEnd; ++iPos )
+ // free global refs
+ jni->DeleteGlobalRef( m_object_java_env );
+
+ jni->DeleteGlobalRef( m_class_Object );
+ jni->DeleteGlobalRef( m_class_String );
+ jni->DeleteGlobalRef( m_class_Double );
+ jni->DeleteGlobalRef( m_class_Float );
+ jni->DeleteGlobalRef( m_class_Long );
+ jni->DeleteGlobalRef( m_class_Integer );
+ jni->DeleteGlobalRef( m_class_Short );
+ jni->DeleteGlobalRef( m_class_Byte );
+ jni->DeleteGlobalRef( m_class_Boolean );
+ jni->DeleteGlobalRef( m_class_Character );
+
+ jni->DeleteGlobalRef( m_class_JNI_proxy );
+ jni->DeleteGlobalRef( m_class_RuntimeException );
+ jni->DeleteGlobalRef( m_class_UnoRuntime );
+ jni->DeleteGlobalRef( m_class_TypeClass );
+ jni->DeleteGlobalRef( m_class_Type );
+ jni->DeleteGlobalRef( m_class_Any );
+ }
+ catch (BridgeRuntimeError & err)
{
- JNI_type_info::_delete( attach, iPos->second.m_info );
+#ifdef _DEBUG
+ OString cstr_msg(
+ OUStringToOString(
+ OUSTR("[jni_uno bridge error] ") + err.m_message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
+#endif
+ }
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ OSL_ENSURE( 0, "[jni_uno bridge error] attaching current thread to java failed!" );
}
-
- // free global refs
- attach->DeleteGlobalRef( m_object_java_env );
-
- attach->DeleteGlobalRef( m_class_Object );
- attach->DeleteGlobalRef( m_class_String );
- attach->DeleteGlobalRef( m_class_Double );
- attach->DeleteGlobalRef( m_class_Float );
- attach->DeleteGlobalRef( m_class_Long );
- attach->DeleteGlobalRef( m_class_Integer );
- attach->DeleteGlobalRef( m_class_Short );
- attach->DeleteGlobalRef( m_class_Byte );
- attach->DeleteGlobalRef( m_class_Boolean );
- attach->DeleteGlobalRef( m_class_Character );
-
- attach->DeleteGlobalRef( m_class_JNI_proxy );
- attach->DeleteGlobalRef( m_class_RuntimeException );
- attach->DeleteGlobalRef( m_class_UnoRuntime );
- attach->DeleteGlobalRef( m_class_TypeClass );
- attach->DeleteGlobalRef( m_class_Type );
- attach->DeleteGlobalRef( m_class_Any );
}
}
diff --git a/bridges/source/jni_uno/jni_info.h b/bridges/source/jni_uno/jni_info.h
index b4334fc5e0cd..9d39ec9f41a8 100644
--- a/bridges/source/jni_uno/jni_info.h
+++ b/bridges/source/jni_uno/jni_info.h
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_info.h,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: dbo $ $Date: 2002-11-01 14:24:58 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,24 +58,24 @@
*
*
************************************************************************/
-#ifndef _JNI_INFO_H_
-#define _JNI_INFO_H_
-
-#include "jni_base.h"
+#if ! defined INCLUDED_JNI_INFO_H
+#define INCLUDED_JNI_INFO_H
#include <hash_map>
-#include <osl/mutex.hxx>
-#include <rtl/ustring.hxx>
-#include <rtl/strbuf.hxx>
+#include "jni_base.h"
-#include <uno/environment.h>
-#include <typelib/typedescription.hxx>
+#include "osl/mutex.hxx"
+#include "rtl/ustring.hxx"
+#include "rtl/strbuf.hxx"
-#include <com/sun/star/uno/Type.hxx>
+#include "uno/environment.h"
+#include "typelib/typedescription.hxx"
+#include "com/sun/star/uno/Type.hxx"
-namespace jni_bridge
+
+namespace jni_uno
{
//==================================================================================================
@@ -91,12 +91,10 @@ struct JNI_type_info
jfieldID * m_fields;
jmethodID m_ctor;
- JNI_type_info(
- JNI_attach const & attach, typelib_InterfaceTypeDescription * td );
- JNI_type_info(
- JNI_attach const & attach, typelib_CompoundTypeDescription * td );
+ JNI_type_info( JNI_context const & jni, typelib_InterfaceTypeDescription * td );
+ JNI_type_info( JNI_context const & jni, typelib_CompoundTypeDescription * td );
- static void _delete( JNI_attach const & attach, JNI_type_info * that ) SAL_THROW( () );
+ static void _delete( JNI_context const & jni, JNI_type_info * that ) SAL_THROW( () );
};
//==================================================================================================
struct JNI_type_info_holder
@@ -109,10 +107,12 @@ struct JNI_type_info_holder
//==================================================================================================
typedef ::std::hash_map< ::rtl::OUString, JNI_type_info_holder, ::rtl::OUStringHash > t_str2type;
+struct Bridge;
+
//==================================================================================================
class JNI_info
{
- uno_Environment * m_java_env;
+ Bridge const * m_bridge; // unacquired pointer to owner
mutable ::osl::Mutex m_mutex;
mutable t_str2type m_type_map;
@@ -193,24 +193,24 @@ public:
jfieldID m_field_JNI_proxy_m_oid;
//
- JNI_info( uno_Environment * java_env );
~JNI_info() SAL_THROW( () );
+ JNI_info( Bridge const * bridge );
//
JNI_type_info const * get_type_info(
- JNI_attach const & attach, typelib_TypeDescription * td ) const;
+ JNI_context const & jni, typelib_TypeDescription * td ) const;
JNI_type_info const * get_type_info(
- JNI_attach const & attach, ::rtl::OUString const & uno_name ) const;
+ JNI_context const & jni, ::rtl::OUString const & uno_name ) const;
//
inline void append_sig(
::rtl::OStringBuffer * buf, typelib_TypeDescriptionReference * type ) const;
//
inline jobject java_env_getRegisteredInterface(
- JNI_attach const & attach, jstring oid, jobject type ) const;
+ JNI_context const & jni, jstring oid, jobject type ) const;
inline jobject java_env_registerInterface(
- JNI_attach const & attach, jobject javaI, jstring oid, jobject type ) const;
+ JNI_context const & jni, jobject javaI, jstring oid, jobject type ) const;
inline void java_env_revokeInterface(
- JNI_attach const & attach, jstring oid, jobject type ) const;
+ JNI_context const & jni, jstring oid, jobject type ) const;
};
//__________________________________________________________________________________________________
inline void JNI_info::append_sig(
@@ -301,40 +301,40 @@ inline void JNI_info::append_sig(
}
//__________________________________________________________________________________________________
inline jobject JNI_info::java_env_getRegisteredInterface(
- JNI_attach const & attach, jstring oid, jobject type ) const
+ JNI_context const & jni, jstring oid, jobject type ) const
{
jvalue args[ 2 ];
args[ 0 ].l = oid;
args[ 1 ].l = type;
- jobject jo_iface = attach->CallObjectMethodA(
+ jobject jo_iface = jni->CallObjectMethodA(
m_object_java_env, m_method_IEnvironment_getRegisteredInterface, args );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
return jo_iface;
}
//__________________________________________________________________________________________________
inline jobject JNI_info::java_env_registerInterface(
- JNI_attach const & attach, jobject javaI, jstring oid, jobject type ) const
+ JNI_context const & jni, jobject javaI, jstring oid, jobject type ) const
{
- JLocalAutoRef jo_string_array( attach, attach->NewObjectArray( 1, m_class_String, oid ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_string_array( jni, jni->NewObjectArray( 1, m_class_String, oid ) );
+ jni.ensure_no_exception();
jvalue args[ 3 ];
args[ 0 ].l = javaI;
args[ 1 ].l = jo_string_array.get();
args[ 2 ].l = type;
- jobject jo_iface = attach->CallObjectMethodA(
+ jobject jo_iface = jni->CallObjectMethodA(
m_object_java_env, m_method_IEnvironment_registerInterface, args );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
return jo_iface;
}
//__________________________________________________________________________________________________
inline void JNI_info::java_env_revokeInterface(
- JNI_attach const & attach, jstring oid, jobject type ) const
+ JNI_context const & jni, jstring oid, jobject type ) const
{
jvalue args[ 2 ];
args[ 0 ].l = oid;
args[ 1 ].l = type;
- attach->CallVoidMethodA( m_object_java_env, m_method_IEnvironment_revokeInterface, args );
- attach.ensure_no_exception();
+ jni->CallVoidMethodA( m_object_java_env, m_method_IEnvironment_revokeInterface, args );
+ jni.ensure_no_exception();
}
}
diff --git a/bridges/source/jni_uno/jni_java2uno.cxx b/bridges/source/jni_uno/jni_java2uno.cxx
index a475fe18be94..608cd6969311 100644
--- a/bridges/source/jni_uno/jni_java2uno.cxx
+++ b/bridges/source/jni_uno/jni_java2uno.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_java2uno.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: dbo $ $Date: 2002-11-28 17:31:02 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,12 +72,12 @@
using namespace ::rtl;
-namespace jni_bridge
+namespace jni_uno
{
//__________________________________________________________________________________________________
-jobject jni_Bridge::map_uno2java(
- JNI_attach const & attach,
+jobject Bridge::map_uno2java(
+ JNI_context const & jni,
uno_Interface * pUnoI, JNI_type_info const * info ) const
{
// get oid
@@ -87,10 +87,10 @@ jobject jni_Bridge::map_uno2java(
OUString oid( pOid, SAL_NO_ACQUIRE );
// getRegisteredInterface()
- JLocalAutoRef jo_oid( attach, ustring_to_jstring( attach, oid.pData ) );
+ JLocalAutoRef jo_oid( jni, ustring_to_jstring( jni, oid.pData ) );
JLocalAutoRef jo_iface(
- attach, m_jni_info->java_env_getRegisteredInterface(
- attach, (jstring)jo_oid.get(), info->m_jo_type ) );
+ jni, m_jni_info->java_env_getRegisteredInterface(
+ jni, (jstring)jo_oid.get(), info->m_jo_type ) );
if (! jo_iface.is()) // no registered iface
{
@@ -111,10 +111,10 @@ jobject jni_Bridge::map_uno2java(
args[ 4 ].l = info->m_jo_type;
args[ 5 ].l = jo_oid.get();
jo_iface.reset(
- attach, attach->CallStaticObjectMethodA(
+ jni->CallStaticObjectMethodA(
m_jni_info->m_class_JNI_proxy,
m_jni_info->m_method_JNI_proxy_create, args ) );
- attach.ensure_no_exception();
+ jni.ensure_no_exception();
}
return jo_iface.release();
@@ -123,7 +123,7 @@ jobject jni_Bridge::map_uno2java(
//##################################################################################################
//__________________________________________________________________________________________________
-void jni_Bridge::handle_uno_exc( JNI_attach const & attach, uno_Any * uno_exc ) const
+void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const
{
if (typelib_TypeClass_EXCEPTION == uno_exc->pType->eTypeClass)
{
@@ -139,7 +139,7 @@ void jni_Bridge::handle_uno_exc( JNI_attach const & attach, uno_Any * uno_exc )
try
{
map_to_java(
- attach, &java_exc, uno_exc->pData, uno_exc->pType, 0,
+ jni, &java_exc, uno_exc->pData, uno_exc->pType, 0,
true /* in */, false /* no out */ );
}
catch (...)
@@ -148,8 +148,8 @@ void jni_Bridge::handle_uno_exc( JNI_attach const & attach, uno_Any * uno_exc )
throw;
}
uno_any_destruct( uno_exc, 0 );
- JLocalAutoRef jo_exc( attach, java_exc.l );
- jint res = attach->Throw( (jthrowable)jo_exc.get() );
+ JLocalAutoRef jo_exc( jni, java_exc.l );
+ jint res = jni->Throw( (jthrowable)jo_exc.get() );
if (0 != res)
{
OUStringBuffer buf( 64 );
@@ -176,8 +176,8 @@ union largest
uno_Any a;
};
//__________________________________________________________________________________________________
-jobject jni_Bridge::call_uno(
- JNI_attach const & attach,
+jobject Bridge::call_uno(
+ JNI_context const & jni,
uno_Interface * pUnoI, typelib_TypeDescription * member_td,
typelib_TypeDescriptionReference * return_type /* 0 indicates void return */,
sal_Int32 nParams, typelib_MethodParameter const * pParams,
@@ -200,7 +200,7 @@ jobject jni_Bridge::call_uno(
void * uno_ret = (mem + (nParams * sizeof (void *)));
largest * uno_args_mem = (largest *)(mem + (nParams * sizeof (void *)) + return_size);
- OSL_ASSERT( (0 == nParams) || (nParams == attach->GetArrayLength( jo_args )) );
+ OSL_ASSERT( (0 == nParams) || (nParams == jni->GetArrayLength( jo_args )) );
for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
{
typelib_MethodParameter const & param = pParams[ nPos ];
@@ -217,14 +217,14 @@ jobject jni_Bridge::call_uno(
if (param.bIn)
{
- JLocalAutoRef jo_arg( attach, attach->GetObjectArrayElement( jo_args, nPos ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_arg( jni, jni->GetObjectArrayElement( jo_args, nPos ) );
+ jni.ensure_no_exception();
jvalue java_arg;
java_arg.l = jo_arg.get();
try
{
map_to_uno(
- attach, uno_args[ nPos ], java_arg, type, 0,
+ jni, uno_args[ nPos ], java_arg, type, 0,
false /* no assign */, sal_False != param.bOut,
true /* special wrapped integral types */ );
}
@@ -261,12 +261,12 @@ jobject jni_Bridge::call_uno(
{
// get out holder array[ 1 ]
JLocalAutoRef jo_out_holder(
- attach, attach->GetObjectArrayElement( jo_args, nPos ) );
- attach.ensure_no_exception();
+ jni, jni->GetObjectArrayElement( jo_args, nPos ) );
+ jni.ensure_no_exception();
jvalue java_arg;
java_arg.l = jo_out_holder.get();
map_to_java(
- attach, &java_arg, uno_args[ nPos ], param.pTypeRef, 0,
+ jni, &java_arg, uno_args[ nPos ], param.pTypeRef, 0,
true /* in */, true /* out holder */ );
}
catch (...)
@@ -295,7 +295,7 @@ jobject jni_Bridge::call_uno(
{
jvalue java_ret;
map_to_java(
- attach, &java_ret, uno_ret, return_type, 0,
+ jni, &java_ret, uno_ret, return_type, 0,
true /* in */, false /* no out */,
true /* special_wrapped_integral_types */ );
return java_ret.l;
@@ -320,14 +320,14 @@ jobject jni_Bridge::call_uno(
}
}
- handle_uno_exc( attach, uno_exc );
+ handle_uno_exc( jni, uno_exc );
return 0;
}
}
}
-using namespace ::jni_bridge;
+using namespace ::jni_uno;
extern "C"
{
@@ -338,21 +338,21 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
jstring jo_decl_class, jstring jo_method, jobjectArray jo_args /* may be 0 */ )
SAL_THROW_EXTERN_C()
{
- jni_Bridge const * bridge = reinterpret_cast< jni_Bridge const * >( bridge_handle );
+ Bridge const * bridge = reinterpret_cast< Bridge const * >( bridge_handle );
JNI_info const * jni_info = bridge->m_jni_info;
- JNI_attach attach( bridge->m_java_env, jni_env );
+ JNI_context jni( jni_info, jni_env );
try
{
- OUString method_name( jstring_to_oustring( attach, jo_method ) );
+ OUString method_name( jstring_to_oustring( jni, jo_method ) );
#ifdef DEBUG
OUStringBuffer trace_buf( 64 );
trace_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("java->uno call: ") );
trace_buf.append( method_name );
trace_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" on oid ") );
JLocalAutoRef jo_oid(
- attach, attach->GetObjectField( jo_proxy, jni_info->m_field_JNI_proxy_m_oid ) );
- trace_buf.append( jstring_to_oustring( attach, (jstring)jo_oid.get() ) );
+ jni, jni->GetObjectField( jo_proxy, jni_info->m_field_JNI_proxy_m_oid ) );
+ trace_buf.append( jstring_to_oustring( jni, (jstring)jo_oid.get() ) );
OString cstr_msg(
OUStringToOString( trace_buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) );
OSL_TRACE( cstr_msg.getStr() );
@@ -363,23 +363,23 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
{
// oid
JLocalAutoRef jo_oid(
- attach, attach->GetObjectField( jo_proxy, jni_info->m_field_JNI_proxy_m_oid ) );
+ jni, jni->GetObjectField( jo_proxy, jni_info->m_field_JNI_proxy_m_oid ) );
// type
- JLocalAutoRef jo_type( attach, attach->GetObjectArrayElement( jo_args, 0 ) );
- attach.ensure_no_exception();
+ JLocalAutoRef jo_type( jni, jni->GetObjectArrayElement( jo_args, 0 ) );
+ jni.ensure_no_exception();
JLocalAutoRef jo_type_name(
- attach, attach->GetObjectField(
+ jni, jni->GetObjectField(
jo_type.get(), jni_info->m_field_Type__typeName ) );
if (! jo_type_name.is())
throw BridgeRuntimeError( OUSTR("incomplete type object: no type name!") );
- OUString type_name( jstring_to_oustring( attach, (jstring)jo_type_name.get() ) );
- JNI_type_info const * info = jni_info->get_type_info( attach, type_name );
+ OUString type_name( jstring_to_oustring( jni, (jstring)jo_type_name.get() ) );
+ JNI_type_info const * info = jni_info->get_type_info( jni, type_name );
// getRegisteredInterface() already tested in JNI_proxy
// perform queryInterface call on binary uno interface
uno_Interface * pUnoI = reinterpret_cast< uno_Interface * >(
- attach->GetLongField(
+ jni->GetLongField(
jo_proxy, jni_info->m_field_JNI_proxy_m_receiver_handle ) );
uno_Any uno_ret;
@@ -399,7 +399,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
{
try
{
- jo_ret = bridge->map_uno2java( attach, pUnoRet, info );
+ jo_ret = bridge->map_uno2java( jni, pUnoRet, info );
}
catch (...)
{
@@ -413,7 +413,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
}
else
{
- bridge->handle_uno_exc( attach, uno_exc );
+ bridge->handle_uno_exc( jni, uno_exc );
return 0;
}
}
@@ -421,10 +421,10 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
// determine exact interface td
typelib_TypeDescription * orig_td =
reinterpret_cast< typelib_TypeDescription * >(
- attach->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_td_handle ) );
+ jni->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_td_handle ) );
typelib_InterfaceTypeDescription * td =
reinterpret_cast< typelib_InterfaceTypeDescription * >( orig_td );
- OUString iface_name( jstring_to_oustring( attach, jo_decl_class ) );
+ OUString iface_name( jstring_to_oustring( jni, jo_decl_class ) );
while ((0 != td) &&
!reinterpret_cast< OUString const * >(
&((typelib_TypeDescription *)td)->pTypeName )->equals( iface_name ))
@@ -444,7 +444,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
uno_Interface * pUnoI =
reinterpret_cast< uno_Interface * >(
- attach->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_receiver_handle ) );
+ jni->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_receiver_handle ) );
typelib_TypeDescriptionReference ** ppAllMembers = td->ppAllMembers;
for ( sal_Int32 nPos = td->nAllMembers; nPos--; )
@@ -469,7 +469,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
typelib_InterfaceMethodTypeDescription * method_td =
(typelib_InterfaceMethodTypeDescription *)member_td.get();
return bridge->call_uno(
- attach, pUnoI, member_td.get(),
+ jni, pUnoI, member_td.get(),
method_td->pReturnTypeRef, method_td->nParams, method_td->pParams,
jo_args );
}
@@ -493,7 +493,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
typelib_InterfaceAttributeTypeDescription * attribute_td =
(typelib_InterfaceAttributeTypeDescription *)member_td.get();
return bridge->call_uno(
- attach, pUnoI, member_td.get(),
+ jni, pUnoI, member_td.get(),
attribute_td->pAttributeTypeRef, 0, 0,
jo_args );
}
@@ -509,7 +509,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
param.bIn = sal_True;
param.bOut = sal_False;
return bridge->call_uno(
- attach, pUnoI, member_td.get(),
+ jni, pUnoI, member_td.get(),
0 /* indicates void return */, 1, &param,
jo_args );
}
@@ -533,8 +533,18 @@ JNIEXPORT jobject JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch
OString cstr_msg(
OUStringToOString(
OUSTR("[jni_uno bridge error] ") + err.m_message, RTL_TEXTENCODING_ASCII_US ) );
- OSL_TRACE( cstr_msg.getStr() );
- jint res = attach->ThrowNew( jni_info->m_class_RuntimeException, cstr_msg.getStr() );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
+ jint res = jni->ThrowNew( jni_info->m_class_RuntimeException, cstr_msg.getStr() );
+ OSL_ASSERT( 0 == res );
+ return 0;
+ }
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ OString cstr_msg(
+ RTL_CONSTASCII_STRINGPARAM(
+ "[jni_uno bridge error] attaching current thread to java failed!") );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
+ jint res = jni->ThrowNew( jni_info->m_class_RuntimeException, cstr_msg.getStr() );
OSL_ASSERT( 0 == res );
return 0;
}
@@ -544,19 +554,19 @@ JNIEXPORT void JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_finalize__J
JNIEnv * jni_env, jobject jo_proxy, jlong bridge_handle )
SAL_THROW_EXTERN_C()
{
- jni_Bridge const * bridge = reinterpret_cast< jni_Bridge const * >( bridge_handle );
+ Bridge const * bridge = reinterpret_cast< Bridge const * >( bridge_handle );
JNI_info const * jni_info = bridge->m_jni_info;
- JNI_attach attach( bridge->m_java_env, jni_env );
+ JNI_context jni( jni_info, jni_env );
uno_Interface * pUnoI = reinterpret_cast< uno_Interface * >(
- attach->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_receiver_handle ) );
+ jni->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_receiver_handle ) );
typelib_TypeDescription * td = reinterpret_cast< typelib_TypeDescription * >(
- attach->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_td_handle ) );
+ jni->GetLongField( jo_proxy, jni_info->m_field_JNI_proxy_m_td_handle ) );
#ifdef DEBUG
JLocalAutoRef jo_oid(
- attach, attach->GetObjectField( jo_proxy, jni_info->m_field_JNI_proxy_m_oid ) );
- OUString oid( jstring_to_oustring( attach, (jstring)jo_oid.get() ) );
+ jni, jni->GetObjectField( jo_proxy, jni_info->m_field_JNI_proxy_m_oid ) );
+ OUString oid( jstring_to_oustring( jni, (jstring)jo_oid.get() ) );
OString cstr_msg(
OUStringToOString(
OUSTR("freeing java uno proxy: ") + oid, RTL_TEXTENCODING_ASCII_US ) );
diff --git a/bridges/source/jni_uno/jni_uno2java.cxx b/bridges/source/jni_uno/jni_uno2java.cxx
index adf92d932e2a..17968fdaa382 100644
--- a/bridges/source/jni_uno/jni_uno2java.cxx
+++ b/bridges/source/jni_uno/jni_uno2java.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: jni_uno2java.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: dbo $ $Date: 2002-11-22 11:54:01 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:26:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,29 +80,28 @@ namespace
extern "C"
{
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_free(
- uno_ExtEnvironment * env, void * proxy )
+void SAL_CALL UNO_proxy_free( uno_ExtEnvironment * env, void * proxy )
SAL_THROW_EXTERN_C();
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_acquire( uno_Interface * pUnoI )
+void SAL_CALL UNO_proxy_acquire( uno_Interface * pUnoI )
SAL_THROW_EXTERN_C();
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_release( uno_Interface * pUnoI )
+void SAL_CALL UNO_proxy_release( uno_Interface * pUnoI )
SAL_THROW_EXTERN_C();
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_dispatch(
+void SAL_CALL UNO_proxy_dispatch(
uno_Interface * pUnoI, typelib_TypeDescription const * member_td,
void * uno_ret, void * uno_args[], uno_Any ** uno_exc )
SAL_THROW_EXTERN_C();
}
}
-namespace jni_bridge
+namespace jni_uno
{
//__________________________________________________________________________________________________
-void jni_Bridge::handle_java_exc(
- JNI_attach const & attach, JLocalAutoRef const & jo_exc, uno_Any * uno_exc ) const
+void Bridge::handle_java_exc(
+ JNI_context const & jni, JLocalAutoRef const & jo_exc, uno_Any * uno_exc ) const
{
OSL_ASSERT( jo_exc.is() );
if (! jo_exc.is())
@@ -111,16 +110,16 @@ void jni_Bridge::handle_java_exc(
OUSTR("java exception occured, but no java exception available!?") );
}
- OUString exc_name( get_class_name( attach, jo_exc.get() ) );
+ OUString exc_name( get_class_name( jni, jo_exc.get() ) );
::com::sun::star::uno::TypeDescription td( exc_name.pData );
if (!td.is() || (typelib_TypeClass_EXCEPTION != td.get()->eTypeClass))
{
// call toString()
JLocalAutoRef jo_descr(
- attach, attach->CallObjectMethodA(
+ jni, jni->CallObjectMethodA(
jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) );
- attach.ensure_no_exception();
- OUString descr( jstring_to_oustring( attach, (jstring)jo_descr.get() ) );
+ jni.ensure_no_exception();
+ OUString descr( jstring_to_oustring( jni, (jstring)jo_descr.get() ) );
throw BridgeRuntimeError( OUSTR("non-UNO exception occurred: ") + descr );
}
@@ -128,7 +127,7 @@ void jni_Bridge::handle_java_exc(
jvalue val;
val.l = jo_exc.get();
map_to_uno(
- attach, uno_data.get(), val, td.get()->pWeakRef, 0,
+ jni, uno_data.get(), val, td.get()->pWeakRef, 0,
false /* no assign */, false /* no out param */ );
typelib_typedescriptionreference_acquire( td.get()->pWeakRef );
@@ -143,7 +142,7 @@ void jni_Bridge::handle_java_exc(
#endif
}
//__________________________________________________________________________________________________
-void jni_Bridge::call_java(
+void Bridge::call_java(
jobject javaI, JNI_type_info const * info, sal_Int32 function_pos,
typelib_TypeDescriptionReference * return_type /* 0 indicates void return */,
typelib_MethodParameter * params, sal_Int32 nParams,
@@ -163,7 +162,8 @@ void jni_Bridge::call_java(
info = info->m_base;
}
- JNI_attach attach( m_java_env );
+ JNI_guarded_context jni(
+ m_jni_info, reinterpret_cast< ::jvmaccess::VirtualMachine * >( m_java_env->pContext ) );
// prepare java args, save param td
jvalue * java_args = (jvalue *)alloca( sizeof (jvalue) * nParams );
@@ -176,7 +176,7 @@ void jni_Bridge::call_java(
{
java_args[ nPos ].l = 0; // build up array[ 1 ]
map_to_java(
- attach, &java_args[ nPos ],
+ jni, &java_args[ nPos ],
uno_args[ nPos ],
param.pTypeRef, 0,
sal_False != param.bIn /* convert uno value */,
@@ -188,74 +188,74 @@ void jni_Bridge::call_java(
for ( sal_Int32 n = 0; n < nPos; ++n )
{
if (param.bOut || typelib_TypeClass_DOUBLE < param.pTypeRef->eTypeClass)
- attach->DeleteLocalRef( java_args[ n ].l );
+ jni->DeleteLocalRef( java_args[ n ].l );
}
throw;
}
}
// complex return value
- JLocalAutoRef java_ret;
+ JLocalAutoRef java_ret( jni );
jmethodID method_id = info->m_methods[ function_pos ];
if (0 == return_type) // indicates void return
{
- attach->CallVoidMethodA( javaI, method_id, java_args );
+ jni->CallVoidMethodA( javaI, method_id, java_args );
}
else
{
switch (return_type->eTypeClass)
{
case typelib_TypeClass_VOID:
- attach->CallVoidMethodA( javaI, method_id, java_args );
+ jni->CallVoidMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_CHAR:
- *(sal_Unicode *)uno_ret = attach->CallCharMethodA( javaI, method_id, java_args );
+ *(sal_Unicode *)uno_ret = jni->CallCharMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_BOOLEAN:
- *(sal_Bool *)uno_ret = attach->CallBooleanMethodA( javaI, method_id, java_args );
+ *(sal_Bool *)uno_ret = jni->CallBooleanMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_BYTE:
- *(sal_Int8 *)uno_ret = attach->CallByteMethodA( javaI, method_id, java_args );
+ *(sal_Int8 *)uno_ret = jni->CallByteMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
- *(sal_Int16 *)uno_ret = attach->CallShortMethodA( javaI, method_id, java_args );
+ *(sal_Int16 *)uno_ret = jni->CallShortMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
- *(sal_Int32 *)uno_ret = attach->CallIntMethodA( javaI, method_id, java_args );
+ *(sal_Int32 *)uno_ret = jni->CallIntMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
- *(sal_Int64 *)uno_ret = attach->CallLongMethodA( javaI, method_id, java_args );
+ *(sal_Int64 *)uno_ret = jni->CallLongMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_FLOAT:
- *(float *)uno_ret = attach->CallFloatMethodA( javaI, method_id, java_args );
+ *(float *)uno_ret = jni->CallFloatMethodA( javaI, method_id, java_args );
break;
case typelib_TypeClass_DOUBLE:
- *(double *)uno_ret = attach->CallDoubleMethodA( javaI, method_id, java_args );
+ *(double *)uno_ret = jni->CallDoubleMethodA( javaI, method_id, java_args );
break;
default:
- java_ret.reset( attach, attach->CallObjectMethodA( javaI, method_id, java_args ) );
+ java_ret.reset( jni->CallObjectMethodA( javaI, method_id, java_args ) );
break;
}
}
- if (attach->ExceptionCheck())
+ if (jni->ExceptionCheck())
{
- JLocalAutoRef jo_exc( attach, attach->ExceptionOccurred() );
- attach->ExceptionClear();
+ JLocalAutoRef jo_exc( jni, jni->ExceptionOccurred() );
+ jni->ExceptionClear();
// release temp java local refs
for ( nPos = 0; nPos < nParams; ++nPos )
{
typelib_MethodParameter const & param = params[ nPos ];
if (param.bOut || typelib_TypeClass_DOUBLE < param.pTypeRef->eTypeClass)
- attach->DeleteLocalRef( java_args[ nPos ].l );
+ jni->DeleteLocalRef( java_args[ nPos ].l );
}
- handle_java_exc( attach, jo_exc, *uno_exc );
+ handle_java_exc( jni, jo_exc, *uno_exc );
}
else // no exception
{
@@ -268,10 +268,10 @@ void jni_Bridge::call_java(
try
{
map_to_uno(
- attach, uno_args[ nPos ], java_args[ nPos ], param.pTypeRef, 0,
+ jni, uno_args[ nPos ], java_args[ nPos ], param.pTypeRef, 0,
sal_False != param.bIn /* assign if inout */, true /* out param */ );
// out array
- attach->DeleteLocalRef( java_args[ nPos ].l );
+ jni->DeleteLocalRef( java_args[ nPos ].l );
}
catch (...)
{
@@ -287,7 +287,7 @@ void jni_Bridge::call_java(
{
typelib_MethodParameter const & param = params[ nPos ];
if (param.bOut || typelib_TypeClass_DOUBLE < param.pTypeRef->eTypeClass)
- attach->DeleteLocalRef( java_args[ nPos ].l );
+ jni->DeleteLocalRef( java_args[ nPos ].l );
}
throw;
}
@@ -295,7 +295,7 @@ void jni_Bridge::call_java(
else // pure temp in param
{
if (typelib_TypeClass_DOUBLE < param.pTypeRef->eTypeClass)
- attach->DeleteLocalRef( java_args[ nPos ].l );
+ jni->DeleteLocalRef( java_args[ nPos ].l );
}
}
@@ -306,7 +306,7 @@ void jni_Bridge::call_java(
jvalue val;
val.l = java_ret.get();
map_to_uno(
- attach, uno_ret, val, return_type, 0,
+ jni, uno_ret, val, return_type, 0,
false /* no assign */, false /* no out param */ );
} // else already set integral uno return value
@@ -316,10 +316,10 @@ void jni_Bridge::call_java(
}
//==== a uno proxy wrapping a java interface =======================================================
-struct jni_unoInterfaceProxy : public uno_Interface
+struct UNO_proxy : public uno_Interface
{
mutable oslInterlockedCount m_ref;
- jni_Bridge const * m_bridge;
+ Bridge const * m_bridge;
// mapping information
OUString m_oid;
@@ -327,45 +327,43 @@ struct jni_unoInterfaceProxy : public uno_Interface
jstring m_jo_oid;
JNI_type_info const * m_type_info;
- inline void acquire() const SAL_THROW( () );
- inline void release() const SAL_THROW( () );
+ inline void acquire() const;
+ inline void release() const;
// ctor
- inline jni_unoInterfaceProxy(
- JNI_attach const & attach, jni_Bridge const * bridge,
- jobject javaI, jstring jo_oid, OUString const & oid, JNI_type_info const * info )
- SAL_THROW( () );
+ inline UNO_proxy(
+ JNI_context const & jni, Bridge const * bridge,
+ jobject javaI, jstring jo_oid, OUString const & oid, JNI_type_info const * info );
};
//__________________________________________________________________________________________________
-inline jni_unoInterfaceProxy::jni_unoInterfaceProxy(
- JNI_attach const & attach, jni_Bridge const * bridge,
+inline UNO_proxy::UNO_proxy(
+ JNI_context const & jni, Bridge const * bridge,
jobject javaI, jstring jo_oid, OUString const & oid, JNI_type_info const * info )
- SAL_THROW( () )
: m_ref( 1 ),
m_oid( oid ),
m_type_info( info )
{
bridge->acquire();
m_bridge = bridge;
- m_javaI = attach->NewGlobalRef( javaI );
- m_jo_oid = (jstring)attach->NewGlobalRef( jo_oid );
+ m_javaI = jni->NewGlobalRef( javaI );
+ m_jo_oid = (jstring)jni->NewGlobalRef( jo_oid );
// uno_Interface
- uno_Interface::acquire = jni_unoInterfaceProxy_acquire;
- uno_Interface::release = jni_unoInterfaceProxy_release;
- uno_Interface::pDispatcher = jni_unoInterfaceProxy_dispatch;
+ uno_Interface::acquire = UNO_proxy_acquire;
+ uno_Interface::release = UNO_proxy_release;
+ uno_Interface::pDispatcher = UNO_proxy_dispatch;
}
//__________________________________________________________________________________________________
-inline void jni_unoInterfaceProxy::acquire() const SAL_THROW( () )
+inline void UNO_proxy::acquire() const
{
if (1 == osl_incrementInterlockedCount( &m_ref ))
{
// rebirth of proxy zombie
- void * that = const_cast< jni_unoInterfaceProxy * >( this );
+ void * that = const_cast< UNO_proxy * >( this );
// register at uno env
(*m_bridge->m_uno_env->registerProxyInterface)(
m_bridge->m_uno_env, &that,
- jni_unoInterfaceProxy_free, m_oid.pData,
+ UNO_proxy_free, m_oid.pData,
(typelib_InterfaceTypeDescription *)m_type_info->m_td.get() );
#ifdef DEBUG
OSL_ASSERT( this == (void const * const)that );
@@ -373,25 +371,25 @@ inline void jni_unoInterfaceProxy::acquire() const SAL_THROW( () )
}
}
//__________________________________________________________________________________________________
-inline void jni_unoInterfaceProxy::release() const SAL_THROW( () )
+inline void UNO_proxy::release() const
{
if (0 == osl_decrementInterlockedCount( &m_ref ))
{
// revoke from uno env on last release
(*m_bridge->m_uno_env->revokeInterface)(
- m_bridge->m_uno_env, const_cast< jni_unoInterfaceProxy * >( this ) );
+ m_bridge->m_uno_env, const_cast< UNO_proxy * >( this ) );
}
}
//##################################################################################################
//__________________________________________________________________________________________________
-uno_Interface * jni_Bridge::map_java2uno(
- JNI_attach const & attach,
+uno_Interface * Bridge::map_java2uno(
+ JNI_context const & jni,
jobject javaI, JNI_type_info const * info ) const
{
- JLocalAutoRef jo_oid( attach, compute_oid( attach, javaI ) );
- OUString oid( jstring_to_oustring( attach, (jstring)jo_oid.get() ) );
+ JLocalAutoRef jo_oid( jni, compute_oid( jni, javaI ) );
+ OUString oid( jstring_to_oustring( jni, (jstring)jo_oid.get() ) );
uno_Interface * pUnoI = 0;
(*m_uno_env->getRegisteredInterface)(
@@ -401,17 +399,17 @@ uno_Interface * jni_Bridge::map_java2uno(
if (0 == pUnoI) // no existing interface, register new proxy
{
JLocalAutoRef jo_iface(
- attach, m_jni_info->java_env_registerInterface(
- attach, javaI, (jstring)jo_oid.get(), info->m_jo_type ) );
+ jni, m_jni_info->java_env_registerInterface(
+ jni, javaI, (jstring)jo_oid.get(), info->m_jo_type ) );
// refcount initially 1
- pUnoI = new jni_unoInterfaceProxy(
- attach, const_cast< jni_Bridge * >( this ),
+ pUnoI = new UNO_proxy(
+ jni, const_cast< Bridge * >( this ),
jo_iface.get(), (jstring)jo_oid.get(), oid, info );
(*m_uno_env->registerProxyInterface)(
m_uno_env, (void **)&pUnoI,
- jni_unoInterfaceProxy_free,
+ UNO_proxy_free,
oid.pData, (typelib_InterfaceTypeDescription *)info->m_td.get() );
}
return pUnoI;
@@ -419,7 +417,7 @@ uno_Interface * jni_Bridge::map_java2uno(
}
-using namespace ::jni_bridge;
+using namespace ::jni_uno;
namespace
{
@@ -427,10 +425,10 @@ extern "C"
{
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_free( uno_ExtEnvironment * env, void * proxy )
+void SAL_CALL UNO_proxy_free( uno_ExtEnvironment * env, void * proxy )
SAL_THROW_EXTERN_C()
{
- jni_unoInterfaceProxy const * that = reinterpret_cast< jni_unoInterfaceProxy const * >( proxy );
+ UNO_proxy const * that = reinterpret_cast< UNO_proxy const * >( proxy );
OSL_ASSERT( env == that->m_bridge->m_uno_env );
#ifdef DEBUG
OString cstr_msg(
@@ -441,29 +439,42 @@ void SAL_CALL jni_unoInterfaceProxy_free( uno_ExtEnvironment * env, void * proxy
try
{
- JNI_attach attach( that->m_bridge->m_java_env );
+ Bridge const * bridge = that->m_bridge;
+ JNI_guarded_context jni(
+ bridge->m_jni_info,
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >( bridge->m_java_env->pContext ) );
+
try
{
- that->m_bridge->m_jni_info->java_env_revokeInterface(
- attach, that->m_jo_oid, that->m_type_info->m_jo_type );
+ bridge->m_jni_info->java_env_revokeInterface(
+ jni, that->m_jo_oid, that->m_type_info->m_jo_type );
}
catch (BridgeRuntimeError & err)
{
#ifdef _DEBUG
- OString cstr( OUStringToOString( err.m_message, RTL_TEXTENCODING_ASCII_US ) );
- OSL_ENSURE( 0, cstr.getStr() );
+ OString cstr_msg( OUStringToOString( err.m_message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
#endif
}
- attach->DeleteGlobalRef( that->m_javaI );
- attach->DeleteGlobalRef( that->m_jo_oid );
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ OSL_ENSURE( 0, "[jni_uno bridge error] attaching current thread to java failed!" );
+ }
+
+ jni->DeleteGlobalRef( that->m_javaI );
+ jni->DeleteGlobalRef( that->m_jo_oid );
}
catch (BridgeRuntimeError & err)
{
#ifdef _DEBUG
- OString cstr( OUStringToOString( err.m_message, RTL_TEXTENCODING_ASCII_US ) );
- OSL_ENSURE( 0, cstr.getStr() );
+ OString cstr_msg( OUStringToOString( err.m_message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
#endif
}
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ OSL_ENSURE( 0, "[jni_uno bridge error] attaching current thread to java failed!" );
+ }
that->m_bridge->release();
#ifdef DEBUG
@@ -472,27 +483,27 @@ void SAL_CALL jni_unoInterfaceProxy_free( uno_ExtEnvironment * env, void * proxy
delete that;
}
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_acquire( uno_Interface * pUnoI )
+void SAL_CALL UNO_proxy_acquire( uno_Interface * pUnoI )
SAL_THROW_EXTERN_C()
{
- jni_unoInterfaceProxy const * that = static_cast< jni_unoInterfaceProxy const * >( pUnoI );
+ UNO_proxy const * that = static_cast< UNO_proxy const * >( pUnoI );
that->acquire();
}
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_release( uno_Interface * pUnoI )
+void SAL_CALL UNO_proxy_release( uno_Interface * pUnoI )
SAL_THROW_EXTERN_C()
{
- jni_unoInterfaceProxy * that = static_cast< jni_unoInterfaceProxy * >( pUnoI );
+ UNO_proxy * that = static_cast< UNO_proxy * >( pUnoI );
that->release();
}
//--------------------------------------------------------------------------------------------------
-void SAL_CALL jni_unoInterfaceProxy_dispatch(
+void SAL_CALL UNO_proxy_dispatch(
uno_Interface * pUnoI, typelib_TypeDescription const * member_td,
void * uno_ret, void * uno_args [], uno_Any ** uno_exc )
SAL_THROW_EXTERN_C()
{
- jni_unoInterfaceProxy const * that = static_cast< jni_unoInterfaceProxy const * >( pUnoI );
+ UNO_proxy const * that = static_cast< UNO_proxy const * >( pUnoI );
#ifdef DEBUG
OUStringBuffer trace_buf( 64 );
trace_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("uno->java call: ") );
@@ -506,7 +517,7 @@ void SAL_CALL jni_unoInterfaceProxy_dispatch(
try
{
- jni_Bridge const * bridge = that->m_bridge;
+ Bridge const * bridge = that->m_bridge;
switch (member_td->eTypeClass)
{
@@ -581,48 +592,50 @@ void SAL_CALL jni_unoInterfaceProxy_dispatch(
if (0 == pInterface)
{
JNI_info const * jni_info = bridge->m_jni_info;
- JNI_attach attach( bridge->m_java_env );
+ JNI_guarded_context jni(
+ jni_info,
+ reinterpret_cast< ::jvmaccess::VirtualMachine * >(
+ bridge->m_java_env->pContext ) );
JNI_type_info const * info =
- jni_info->get_type_info( attach, demanded_td.get() );
+ jni_info->get_type_info( jni, demanded_td.get() );
jvalue args[ 2 ];
args[ 0 ].l = info->m_jo_type;
args[ 1 ].l = that->m_javaI;
JLocalAutoRef jo_ret(
- attach, attach->CallStaticObjectMethodA(
+ jni, jni->CallStaticObjectMethodA(
jni_info->m_class_UnoRuntime,
jni_info->m_method_UnoRuntime_queryInterface, args ) );
- if (attach->ExceptionCheck())
+ if (jni->ExceptionCheck())
{
- JLocalAutoRef jo_exc( attach, attach->ExceptionOccurred() );
- attach->ExceptionClear();
- bridge->handle_java_exc( attach, jo_exc, *uno_exc );
+ JLocalAutoRef jo_exc( jni, jni->ExceptionOccurred() );
+ jni->ExceptionClear();
+ bridge->handle_java_exc( jni, jo_exc, *uno_exc );
}
else
{
if (jo_ret.is())
{
#ifdef _DEBUG
- JLocalAutoRef jo_oid( attach, compute_oid( attach, jo_ret.get() ) );
- OUString oid( jstring_to_oustring( attach, (jstring)jo_oid.get() ) );
+ JLocalAutoRef jo_oid( jni, compute_oid( jni, jo_ret.get() ) );
+ OUString oid( jstring_to_oustring( jni, (jstring)jo_oid.get() ) );
OSL_ENSURE( oid.equals( that->m_oid ), "### different oids!" );
#endif
JLocalAutoRef jo_iface(
- attach, jni_info->java_env_registerInterface(
- attach, jo_ret.get(), that->m_jo_oid, info->m_jo_type ) );
+ jni, jni_info->java_env_registerInterface(
+ jni, jo_ret.get(), that->m_jo_oid, info->m_jo_type ) );
// refcount initially 1
- uno_Interface * pUnoI = new jni_unoInterfaceProxy(
- attach, bridge, jo_iface.get(),
+ uno_Interface * pUnoI = new UNO_proxy(
+ jni, bridge, jo_iface.get(),
that->m_jo_oid, that->m_oid, info );
(*bridge->m_uno_env->registerProxyInterface)(
bridge->m_uno_env, (void **)&pUnoI,
- (uno_freeProxyFunc)jni_unoInterfaceProxy_free,
- that->m_oid.pData,
+ UNO_proxy_free, that->m_oid.pData,
(typelib_InterfaceTypeDescription *)info->m_td.get() );
uno_any_construct(
@@ -648,11 +661,11 @@ void SAL_CALL jni_unoInterfaceProxy_dispatch(
break;
}
case 1: // acquire this proxy
- jni_unoInterfaceProxy_acquire( const_cast< jni_unoInterfaceProxy * >( that ) );
+ UNO_proxy_acquire( const_cast< UNO_proxy * >( that ) );
*uno_exc = 0;
break;
case 2: // release this proxy
- jni_unoInterfaceProxy_release( const_cast< jni_unoInterfaceProxy * >( that ) );
+ UNO_proxy_release( const_cast< UNO_proxy * >( that ) );
*uno_exc = 0;
break;
default: // arbitrary method call
@@ -684,7 +697,20 @@ void SAL_CALL jni_unoInterfaceProxy_dispatch(
uno_type_any_construct( *uno_exc, &exc, exc_type.getTypeLibType(), 0 );
#ifdef _DEBUG
OString cstr_msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
- OSL_TRACE( cstr_msg.getStr() );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
+#endif
+ }
+ catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
+ {
+ // binary identical struct
+ ::com::sun::star::uno::RuntimeException exc(
+ OUSTR("[jni_uno bridge error] attaching current thread to java failed!"),
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
+ ::com::sun::star::uno::Type const & exc_type = ::getCppuType( &exc );
+ uno_type_any_construct( *uno_exc, &exc, exc_type.getTypeLibType(), 0 );
+#ifdef _DEBUG
+ OString cstr_msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_ENSURE( 0, cstr_msg.getStr() );
#endif
}
}
diff --git a/bridges/source/jni_uno/makefile.mk b/bridges/source/jni_uno/makefile.mk
index fa90cf92387f..8543dbac6065 100644
--- a/bridges/source/jni_uno/makefile.mk
+++ b/bridges/source/jni_uno/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: dbo $ $Date: 2002-10-28 18:20:35 $
+# last change: $Author: dbo $ $Date: 2002-12-06 10:26:05 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -82,6 +82,7 @@ SLOFILES= \
SHL1TARGET=$(TARGET)
SHL1STDLIBS= \
+ $(JVMACCESSLIB) \
$(CPPULIB) \
$(SALLIB)