Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
214c3799
Kaydet (Commit)
214c3799
authored
Ara 03, 2013
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clean up use of OSL debug functionality
Change-Id: I1efcdb7359ac43ee50d2f526bc29a10b1bef35b4
üst
413be25c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
227 deletions
+153
-227
jni_base.h
bridges/source/jni_uno/jni_base.h
+5
-1
jni_bridge.cxx
bridges/source/jni_uno/jni_bridge.cxx
+40
-54
jni_data.cxx
bridges/source/jni_uno/jni_data.cxx
+13
-20
jni_info.cxx
bridges/source/jni_uno/jni_info.cxx
+0
-0
jni_java2uno.cxx
bridges/source/jni_uno/jni_java2uno.cxx
+49
-69
jni_uno2java.cxx
bridges/source/jni_uno/jni_uno2java.cxx
+46
-83
No files found.
bridges/source/jni_uno/jni_base.h
Dosyayı görüntüle @
214c3799
...
...
@@ -20,6 +20,10 @@
#ifndef INCLUDED_JNI_BASE_H
#define INCLUDED_JNI_BASE_H
#include <sal/config.h>
#include <cassert>
#include "jvmaccess/unovirtualmachine.hxx"
#include "jvmaccess/virtualmachine.hxx"
...
...
@@ -208,7 +212,7 @@ inline void JLocalAutoRef::reset( jobject jo )
//______________________________________________________________________________
inline
JLocalAutoRef
&
JLocalAutoRef
::
operator
=
(
JLocalAutoRef
&
auto_ref
)
{
OSL_ASSERT
(
m_jni
.
get_jni_env
()
==
auto_ref
.
m_jni
.
get_jni_env
()
);
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
;
...
...
bridges/source/jni_uno/jni_bridge.cxx
Dosyayı görüntüle @
214c3799
...
...
@@ -17,9 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <cassert>
#include "jni_bridge.h"
#include <boost/static_assert.hpp>
#include "jvmaccess/unovirtualmachine.hxx"
#include "rtl/ref.hxx"
#include "rtl/strbuf.hxx"
...
...
@@ -61,8 +65,9 @@ void SAL_CALL Mapping_map_to_uno(
uno_Interface
**
ppUnoI
=
(
uno_Interface
**
)
ppOut
;
jobject
javaI
=
(
jobject
)
pIn
;
OSL_ASSERT
(
sizeof
(
void
*
)
==
sizeof
(
jobject
)
);
OSL_ENSURE
(
ppUnoI
&&
td
,
"### null ptr!"
);
BOOST_STATIC_ASSERT
(
sizeof
(
void
*
)
==
sizeof
(
jobject
)
);
assert
(
ppUnoI
!=
0
);
assert
(
td
!=
0
);
if
(
0
==
javaI
)
{
...
...
@@ -98,21 +103,13 @@ void SAL_CALL Mapping_map_to_uno(
}
catch
(
const
BridgeRuntimeError
&
err
)
{
#if OSL_DEBUG_LEVEL > 0
OString
cstr_msg
(
OUStringToOString
(
"[jni_uno bridge error] "
+
err
.
m_message
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_FAIL
(
cstr_msg
.
getStr
()
);
#else
(
void
)
err
;
// unused
#endif
SAL_WARN
(
"bridges"
,
"ingoring BridgeRuntimeError
\"
"
<<
err
.
m_message
<<
"
\"
"
);
}
catch
(
const
::
jvmaccess
::
VirtualMachine
::
AttachGuard
::
CreationException
&
)
{
OSL_FAIL
(
"[jni_uno bridge error] attaching current thread "
"to java failed!"
);
SAL_WARN
(
"bridges"
,
"attaching current thread to java failed"
);
}
}
}
...
...
@@ -126,8 +123,9 @@ void SAL_CALL Mapping_map_to_java(
jobject
*
ppJavaI
=
(
jobject
*
)
ppOut
;
uno_Interface
*
pUnoI
=
(
uno_Interface
*
)
pIn
;
OSL_ASSERT
(
sizeof
(
void
*
)
==
sizeof
(
jobject
)
);
OSL_ENSURE
(
ppJavaI
&&
td
,
"### null ptr!"
);
BOOST_STATIC_ASSERT
(
sizeof
(
void
*
)
==
sizeof
(
jobject
)
);
assert
(
ppJavaI
!=
0
);
assert
(
td
!=
0
);
try
{
...
...
@@ -167,20 +165,13 @@ void SAL_CALL Mapping_map_to_java(
}
catch
(
const
BridgeRuntimeError
&
err
)
{
#if OSL_DEBUG_LEVEL > 0
OString
cstr_msg
(
OUStringToOString
(
"[jni_uno bridge error] "
+
err
.
m_message
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_FAIL
(
cstr_msg
.
getStr
()
);
#else
(
void
)
err
;
// unused
#endif
SAL_WARN
(
"bridges"
,
"ingoring BridgeRuntimeError
\"
"
<<
err
.
m_message
<<
"
\"
"
);
}
catch
(
const
::
jvmaccess
::
VirtualMachine
::
AttachGuard
::
CreationException
&
)
{
OSL_FAIL
(
"[jni_uno bridge error] attaching current thread to java failed!"
);
SAL_WARN
(
"bridges"
,
"attaching current thread to java failed"
);
}
}
...
...
@@ -247,7 +238,8 @@ Bridge::Bridge(
reinterpret_cast
<
::
jvmaccess
::
UnoVirtualMachine
*
>
(
m_java_env
->
pContext
)
);
OSL_ASSERT
(
0
!=
m_java_env
&&
0
!=
m_uno_env
);
assert
(
m_java_env
!=
0
);
assert
(
m_uno_env
!=
0
);
(
*
((
uno_Environment
*
)
m_uno_env
)
->
acquire
)(
(
uno_Environment
*
)
m_uno_env
);
(
*
m_java_env
->
acquire
)(
m_java_env
);
...
...
@@ -278,7 +270,7 @@ void JNI_context::java_exc_occurred() const
JLocalAutoRef
jo_exc
(
*
this
,
m_env
->
ExceptionOccurred
()
);
m_env
->
ExceptionClear
();
OSL_ASSERT
(
jo_exc
.
is
()
);
assert
(
jo_exc
.
is
()
);
if
(
!
jo_exc
.
is
())
{
throw
BridgeRuntimeError
(
...
...
@@ -305,7 +297,7 @@ void JNI_context::java_exc_occurred() const
"cannot get method id of java.lang.Object.toString()!"
+
get_stack_trace
()
);
}
OSL_ASSERT
(
0
!=
method_Object_toString
);
assert
(
method_Object_toString
!=
0
);
JLocalAutoRef
jo_descr
(
*
this
,
m_env
->
CallObjectMethodA
(
...
...
@@ -450,7 +442,7 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_initEnvironment( uno_Environment * java_e
{
java_env
->
environmentDisposing
=
java_env_disposing
;
java_env
->
pExtEnv
=
0
;
// no extended support
OSL_ASSERT
(
0
!=
java_env
->
pContext
);
assert
(
java_env
->
pContext
!=
0
);
::
jvmaccess
::
UnoVirtualMachine
*
machine
=
reinterpret_cast
<
::
jvmaccess
::
UnoVirtualMachine
*
>
(
...
...
@@ -467,23 +459,25 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping(
uno_Mapping
**
ppMapping
,
uno_Environment
*
pFrom
,
uno_Environment
*
pTo
)
SAL_THROW_EXTERN_C
()
{
OSL_ASSERT
(
0
!=
ppMapping
&&
0
!=
pFrom
&&
0
!=
pTo
);
assert
(
ppMapping
!=
0
);
assert
(
pFrom
!=
0
);
assert
(
pTo
!=
0
);
if
(
0
!=
*
ppMapping
)
{
(
*
(
*
ppMapping
)
->
release
)(
*
ppMapping
);
*
ppMapping
=
0
;
}
OSL
_ASSERT
(
JNI_FALSE
==
sal_False
);
OSL
_ASSERT
(
JNI_TRUE
==
sal_True
);
OSL
_ASSERT
(
sizeof
(
jboolean
)
==
sizeof
(
sal_Bool
)
);
OSL
_ASSERT
(
sizeof
(
jchar
)
==
sizeof
(
sal_Unicode
)
);
OSL
_ASSERT
(
sizeof
(
jdouble
)
==
sizeof
(
double
)
);
OSL
_ASSERT
(
sizeof
(
jfloat
)
==
sizeof
(
float
)
);
OSL
_ASSERT
(
sizeof
(
jbyte
)
==
sizeof
(
sal_Int8
)
);
OSL
_ASSERT
(
sizeof
(
jshort
)
==
sizeof
(
sal_Int16
)
);
OSL
_ASSERT
(
sizeof
(
jint
)
==
sizeof
(
sal_Int32
)
);
OSL
_ASSERT
(
sizeof
(
jlong
)
==
sizeof
(
sal_Int64
)
);
BOOST_STATIC
_ASSERT
(
JNI_FALSE
==
sal_False
);
BOOST_STATIC
_ASSERT
(
JNI_TRUE
==
sal_True
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jboolean
)
==
sizeof
(
sal_Bool
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jchar
)
==
sizeof
(
sal_Unicode
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jdouble
)
==
sizeof
(
double
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jfloat
)
==
sizeof
(
float
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jbyte
)
==
sizeof
(
sal_Int8
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jshort
)
==
sizeof
(
sal_Int16
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jint
)
==
sizeof
(
sal_Int32
)
);
BOOST_STATIC
_ASSERT
(
sizeof
(
jlong
)
==
sizeof
(
sal_Int64
)
);
if
((
JNI_FALSE
==
sal_False
)
&&
(
JNI_TRUE
==
sal_True
)
&&
(
sizeof
(
jboolean
)
==
sizeof
(
sal_Bool
))
&&
...
...
@@ -525,21 +519,13 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping(
}
catch
(
const
BridgeRuntimeError
&
err
)
{
#if OSL_DEBUG_LEVEL > 0
OString
cstr_msg
(
OUStringToOString
(
"[jni_uno bridge error] "
+
err
.
m_message
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_FAIL
(
cstr_msg
.
getStr
()
);
#else
(
void
)
err
;
// unused
#endif
SAL_WARN
(
"bridges"
,
"ingoring BridgeRuntimeError
\"
"
<<
err
.
m_message
<<
"
\"
"
);
}
catch
(
const
::
jvmaccess
::
VirtualMachine
::
AttachGuard
::
CreationException
&
)
{
OSL_FAIL
(
"[jni_uno bridge error] attaching current thread "
"to java failed!"
);
SAL_WARN
(
"bridges"
,
"attaching current thread to java failed"
);
}
*
ppMapping
=
mapping
;
...
...
bridges/source/jni_uno/jni_data.cxx
Dosyayı görüntüle @
214c3799
...
...
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <cassert>
#include "jni_bridge.h"
...
...
@@ -111,7 +114,7 @@ void createDefaultUnoValue(
}
*
static_cast
<
typelib_TypeDescriptionReference
**
>
(
uno_data
)
=
*
typelib_static_type_getByTypeClass
(
typelib_TypeClass_VOID
);
OSL_ASSERT
(
assert
(
*
static_cast
<
typelib_TypeDescriptionReference
**
>
(
uno_data
)
!=
0
);
typelib_typedescriptionreference_acquire
(
*
static_cast
<
typelib_TypeDescriptionReference
**
>
(
uno_data
));
...
...
@@ -205,7 +208,7 @@ void createDefaultUnoValue(
break
;
default
:
OSL_ASSERT
(
false
);
assert
(
false
);
break
;
}
}
...
...
@@ -220,7 +223,7 @@ void Bridge::map_to_uno(
bool
assign
,
bool
out_param
,
bool
special_wrapped_integral_types
)
const
{
OSL_ASSERT
(
assert
(
!
out_param
||
(
1
==
jni
->
GetArrayLength
(
(
jarray
)
java_data
.
l
))
);
...
...
@@ -504,16 +507,6 @@ void Bridge::map_to_uno(
// create type out of class
JLocalAutoRef
jo_class
(
jni
,
jni
->
GetObjectClass
(
java_data
.
l
)
);
jo_type
.
reset
(
create_type
(
jni
,
(
jclass
)
jo_class
.
get
()
)
);
#if OSL_DEBUG_LEVEL > 1
{
JLocalAutoRef
jo_toString
(
jni
,
jni
->
CallObjectMethodA
(
java_data
.
l
,
m_jni_info
->
m_method_Object_toString
,
0
)
);
jni
.
ensure_no_exception
();
OUString
toString
(
jstring_to_oustring
(
jni
,
(
jstring
)
jo_toString
.
get
()
)
);
}
#endif
}
// get type name
...
...
@@ -935,7 +928,7 @@ void Bridge::map_to_uno(
if
(
0
==
field_id
)
{
// special for Message: call Throwable.getMessage()
OSL_ASSERT
(
assert
(
type_equals
(
type
,
m_jni_info
->
m_Exception_type
.
getTypeLibType
()
)
...
...
@@ -943,7 +936,7 @@ void Bridge::map_to_uno(
type
,
m_jni_info
->
m_RuntimeException_type
.
getTypeLibType
()
)
);
OSL_ASSERT
(
0
==
nPos
);
// first member
assert
(
0
==
nPos
);
// first member
// call getMessage()
jo_field
.
reset
(
jni
->
CallObjectMethodA
(
...
...
@@ -1570,7 +1563,7 @@ void Bridge::map_to_java(
}
else
{
OSL_ASSERT
(
in_param
);
assert
(
in_param
);
java_data
->
l
=
ustring_to_jstring
(
jni
,
*
(
rtl_uString
*
const
*
)
uno_data
);
}
...
...
@@ -1604,7 +1597,7 @@ void Bridge::map_to_java(
}
else
{
OSL_ASSERT
(
in_param
);
assert
(
in_param
);
java_data
->
l
=
create_type
(
jni
,
...
...
@@ -1774,7 +1767,7 @@ void Bridge::map_to_java(
// polymorphic struct types:
OUString
const
&
name
=
OUString
::
unacquired
(
&
pAny
->
pType
->
pTypeName
);
OSL_ASSERT
(
!
name
.
isEmpty
());
assert
(
!
name
.
isEmpty
());
if
(
name
[
name
.
getLength
()
-
1
]
==
'>'
)
{
// Box up in com.sun.star.uno.Any:
...
...
@@ -1850,7 +1843,7 @@ void Bridge::map_to_java(
jmethodID
method_id
=
jni
->
GetStaticMethodID
(
(
jclass
)
jo_enum_class
.
get
(),
"fromInt"
,
sig
.
getStr
()
);
jni
.
ensure_no_exception
();
OSL_ASSERT
(
0
!=
method_id
);
assert
(
0
!=
method_id
);
jvalue
arg
;
arg
.
i
=
*
(
jint
const
*
)
uno_data
;
...
...
@@ -2339,7 +2332,7 @@ void Bridge::map_to_java(
jmethodID
method_id
=
jni
->
GetStaticMethodID
(
(
jclass
)
jo_enum_class
.
get
(),
"fromInt"
,
sig
.
getStr
()
);
jni
.
ensure_no_exception
();
OSL_ASSERT
(
0
!=
method_id
);
assert
(
0
!=
method_id
);
sal_Int32
const
*
p
=
(
sal_Int32
const
*
)
seq
->
elements
;
for
(
sal_Int32
nPos
=
0
;
nPos
<
nElements
;
++
nPos
)
...
...
bridges/source/jni_uno/jni_info.cxx
Dosyayı görüntüle @
214c3799
This diff is collapsed.
Click to expand it.
bridges/source/jni_uno/jni_java2uno.cxx
Dosyayı görüntüle @
214c3799
...
...
@@ -17,7 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <cassert>
#include <sal/alloca.h>
#include "jni_bridge.h"
...
...
@@ -40,7 +42,7 @@ jobject Bridge::map_to_java(
// get oid
rtl_uString
*
pOid
=
0
;
(
*
m_uno_env
->
getObjectIdentifier
)(
m_uno_env
,
&
pOid
,
pUnoI
);
OSL_ASSERT
(
0
!=
pOid
);
assert
(
0
!=
pOid
);
OUString
oid
(
pOid
,
SAL_NO_ACQUIRE
);
// opt getRegisteredInterface()
...
...
@@ -78,7 +80,7 @@ jobject Bridge::map_to_java(
jni
.
ensure_no_exception
();
}
OSL_ASSERT
(
0
!=
jo_iface
);
assert
(
0
!=
jo_iface
);
return
jo_iface
;
}
...
...
@@ -93,22 +95,12 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const
reinterpret_cast
<
::
com
::
sun
::
star
::
uno
::
Exception
*
>
(
uno_exc
->
pData
)
->
Message
+=
jni
.
get_stack_trace
();
#endif
#if OSL_DEBUG_LEVEL > 1
{
OUStringBuffer
buf
(
128
);
buf
.
append
(
"exception occurred java->uno: ["
);
buf
.
append
(
OUString
::
unacquired
(
&
uno_exc
->
pType
->
pTypeName
)
);
buf
.
append
(
"] "
);
buf
.
append
(
reinterpret_cast
<
::
com
::
sun
::
star
::
uno
::
Exception
const
*
>
(
uno_exc
->
pData
)
->
Message
);
OString
cstr_msg
(
OUStringToOString
(
buf
.
makeStringAndClear
(),
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_msg
.
getStr
()
);
}
#endif
SAL_INFO
(
"bridges"
,
"exception occurred java->uno: ["
<<
OUString
::
unacquired
(
&
uno_exc
->
pType
->
pTypeName
)
<<
"] "
<<
reinterpret_cast
<
css
::
uno
::
Exception
const
*>
(
uno_exc
->
pData
)
->
Message
);
// signal exception
jvalue
java_exc
;
try
...
...
@@ -198,7 +190,7 @@ jobject Bridge::call_uno(
largest
*
uno_args_mem
=
(
largest
*
)
(
mem
+
(
nParams
*
sizeof
(
void
*
))
+
return_size
);
OSL_ASSERT
(
(
0
==
nParams
)
||
(
nParams
==
jni
->
GetArrayLength
(
jo_args
))
);
assert
(
(
0
==
nParams
)
||
(
nParams
==
jni
->
GetArrayLength
(
jo_args
))
);
for
(
sal_Int32
nPos
=
0
;
nPos
<
nParams
;
++
nPos
)
{
typelib_MethodParameter
const
&
param
=
pParams
[
nPos
];
...
...
@@ -396,23 +388,17 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
try
{
method_name
=
jstring_to_oustring
(
jni
,
jo_method
);
#if OSL_DEBUG_LEVEL > 1
{
OUStringBuffer
trace_buf
(
64
);
trace_buf
.
append
(
"java->uno call: "
);
trace_buf
.
append
(
method_name
);
trace_buf
.
append
(
" on oid "
);
JLocalAutoRef
jo_oid
(
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
(
"%s"
,
cstr_msg
.
getStr
()
);
}
#endif
SAL_INFO
(
"bridges"
,
"java->uno call: "
<<
method_name
<<
" on oid "
<<
jstring_to_oustring
(
jni
,
static_cast
<
jstring
>
(
JLocalAutoRef
(
jni
,
jni
->
GetObjectField
(
jo_proxy
,
jni_info
->
m_field_JNI_proxy_m_oid
))
.
get
())));
// special IQueryInterface.queryInterface()
if
(
method_name
==
"queryInterface"
)
{
...
...
@@ -515,9 +501,9 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
OUString
const
&
type_name
=
OUString
::
unacquired
(
&
member_type
->
pTypeName
);
sal_Int32
offset
=
type_name
.
indexOf
(
':'
)
+
2
;
OSL_ASSERT
(
offset
>=
2
&&
offset
<
type_name
.
getLength
()
&&
type_name
[
offset
-
1
]
==
':'
);
assert
(
offset
>=
2
);
assert
(
offset
<
type_name
.
getLength
());
assert
(
type_name
[
offset
-
1
]
==
':'
);
sal_Int32
remainder
=
type_name
.
getLength
()
-
offset
;
if
(
typelib_TypeClass_INTERFACE_METHOD
==
member_type
->
eTypeClass
)
{
...
...
@@ -540,7 +526,7 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
}
else
// attribute
{
OSL_ASSERT
(
assert
(
typelib_TypeClass_INTERFACE_ATTRIBUTE
==
member_type
->
eTypeClass
);
...
...
@@ -604,35 +590,32 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
}
catch
(
const
BridgeRuntimeError
&
err
)
{
OUStringBuffer
buf
(
128
);
buf
.
append
(
"[jni_uno bridge error] "
"Java calling UNO method "
);
buf
.
append
(
method_name
);
buf
.
append
(
": "
);
buf
.
append
(
err
.
m_message
);
SAL_WARN
(
"bridges"
,
"Java calling UNO method "
<<
method_name
<<
": "
<<
err
.
m_message
);
// notify RuntimeException
OString
cstr_msg
(
OUStringToOString
(
buf
.
makeStringAndClear
(),
RTL_TEXTENCODING_JAVA_UTF8
)
);
OSL_FAIL
(
cstr_msg
.
getStr
()
);
"[jni_uno bridge error] Java calling UNO method "
+
OUStringToOString
(
method_name
,
RTL_TEXTENCODING_JAVA_UTF8
)
+
": "
+
OUStringToOString
(
err
.
m_message
,
RTL_TEXTENCODING_JAVA_UTF8
)
);
if
(
jni
->
ThrowNew
(
jni_info
->
m_class_RuntimeException
,
cstr_msg
.
getStr
())
!=
0
)
{
OSL_ASSERT
(
false
);
assert
(
false
);
}
return
0
;
}
catch
(
const
::
jvmaccess
::
VirtualMachine
::
AttachGuard
::
CreationException
&
)
{
SAL_WARN
(
"bridges"
,
"attaching current thread to java failed"
);
OString
cstr_msg
(
OString
(
"[jni_uno bridge error] "
"attaching current thread to java failed!"
)
+
OUStringToOString
(
jni
.
get_stack_trace
(),
RTL_TEXTENCODING_JAVA_UTF8
)
);
OSL_FAIL
(
cstr_msg
.
getStr
()
);
"[jni_uno bridge error] attaching current thread to java failed"
+
OUStringToOString
(
jni
.
get_stack_trace
(),
RTL_TEXTENCODING_JAVA_UTF8
));
if
(
jni
->
ThrowNew
(
jni_info
->
m_class_RuntimeException
,
cstr_msg
.
getStr
())
!=
0
)
{
OSL_ASSERT
(
false
);
assert
(
false
);
}
return
0
;
}
...
...
@@ -659,20 +642,17 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_finalize__J(
reinterpret_cast
<
typelib_TypeDescription
*
>
(
jni
->
GetLongField
(
jo_proxy
,
jni_info
->
m_field_JNI_proxy_m_td_handle
)
);
#if OSL_DEBUG_LEVEL > 1
{
JLocalAutoRef
jo_oid
(
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
(
"freeing java uno proxy: "
+
oid
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_msg
.
getStr
()
);
}
#endif
SAL_INFO
(
"bridges"
,
"freeing java uno proxy: "
<<
jstring_to_oustring
(
jni
,
static_cast
<
jstring
>
(
JLocalAutoRef
(
jni
,
jni
->
GetObjectField
(
jo_proxy
,
jni_info
->
m_field_JNI_proxy_m_oid
))
.
get
())));
// revoke from uno env; has already been revoked from java env
(
*
bridge
->
m_uno_env
->
revokeInterface
)(
bridge
->
m_uno_env
,
pUnoI
);
// release receiver
...
...
bridges/source/jni_uno/jni_uno2java.cxx
Dosyayı görüntüle @
214c3799
...
...
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <cassert>
#include <sal/alloca.h>
...
...
@@ -63,7 +66,7 @@ void Bridge::handle_java_exc(
JNI_context
const
&
jni
,
JLocalAutoRef
const
&
jo_exc
,
uno_Any
*
uno_exc
)
const
{
OSL_ASSERT
(
jo_exc
.
is
()
);
assert
(
jo_exc
.
is
()
);
if
(
!
jo_exc
.
is
())
{
throw
BridgeRuntimeError
(
...
...
@@ -113,19 +116,11 @@ void Bridge::handle_java_exc(
uno_exc
->
pType
=
td
.
get
()
->
pWeakRef
;
uno_exc
->
pData
=
uno_data
.
release
();
#if OSL_DEBUG_LEVEL > 1
OUStringBuffer
trace_buf
(
128
);
trace_buf
.
append
(
"exception occurred uno->java: ["
);
trace_buf
.
append
(
exc_name
);
trace_buf
.
append
(
"] "
);
trace_buf
.
append
(
reinterpret_cast
<
::
com
::
sun
::
star
::
uno
::
Exception
const
*
>
(
uno_exc
->
pData
)
->
Message
);
OString
cstr_trace
(
OUStringToOString
(
trace_buf
.
makeStringAndClear
(),
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_trace
.
getStr
()
);
#endif
SAL_INFO
(
"bridges"
,
"exception occurred uno->java: ["
<<
exc_name
<<
"] "
<<
(
reinterpret_cast
<
css
::
uno
::
Exception
const
*>
(
uno_exc
->
pData
)
->
Message
));
}
//______________________________________________________________________________
...
...
@@ -136,7 +131,7 @@ void Bridge::call_java(
typelib_MethodParameter
*
params
,
sal_Int32
nParams
,
void
*
uno_ret
,
void
*
uno_args
[],
uno_Any
**
uno_exc
)
const
{
OSL_ASSERT
(
function_pos_offset
==
0
||
function_pos_offset
==
1
);
assert
(
function_pos_offset
==
0
||
function_pos_offset
==
1
);
JNI_guarded_context
jni
(
m_jni_info
,
reinterpret_cast
<
::
jvmaccess
::
UnoVirtualMachine
*
>
(
...
...
@@ -157,7 +152,7 @@ void Bridge::call_java(
}
iface_td
=
reinterpret_cast
<
typelib_InterfaceTypeDescription
*>
(
iface_holder
.
get
()
);
OSL_ASSERT
(
iface_td
->
aBase
.
eTypeClass
==
typelib_TypeClass_INTERFACE
);
assert
(
iface_td
->
aBase
.
eTypeClass
==
typelib_TypeClass_INTERFACE
);
}
// prepare java args, save param td
...
...
@@ -201,19 +196,20 @@ void Bridge::call_java(
}
sal_Int32
base_members
=
iface_td
->
nAllMembers
-
iface_td
->
nMembers
;
OSL_ASSERT
(
base_members
<
iface_td
->
nAllMembers
);
assert
(
base_members
<
iface_td
->
nAllMembers
);
sal_Int32
base_members_function_pos
=
iface_td
->
pMapMemberIndexToFunctionIndex
[
base_members
];
sal_Int32
member_pos
=
base_members
+
local_member_index
;
OSL_ENSURE
(
member_pos
<
iface_td
->
nAllMembers
,
"### member pos out of range!"
);
SAL_WARN_IF
(
member_pos
>=
iface_td
->
nAllMembers
,
"bridges"
,
"member pos out of range"
);
sal_Int32
function_pos
=
iface_td
->
pMapMemberIndexToFunctionIndex
[
member_pos
]
+
function_pos_offset
;
OSL_ENSURE
(
function_pos
>=
base_members_function_pos
&&
function_pos
<
iface_td
->
nMapFunctionIndexToMemberIndex
,
"
### illegal function index!"
);
SAL_WARN_IF
(
(
function_pos
<
base_members_function_pos
||
function_pos
>=
iface_td
->
nMapFunctionIndexToMemberIndex
)
,
"
bridges"
,
"illegal function index"
);
function_pos
-=
base_members_function_pos
;
JNI_interface_type_info
const
*
info
=
...
...
@@ -221,7 +217,7 @@ void Bridge::call_java(
m_jni_info
->
get_type_info
(
jni
,
&
iface_td
->
aBase
)
);
jmethodID
method_id
=
info
->
m_methods
[
function_pos
];
#if OSL_DEBUG_LEVEL >
1
#if OSL_DEBUG_LEVEL >
0
OUStringBuffer
trace_buf
(
128
);
trace_buf
.
append
(
"calling "
);
JLocalAutoRef
jo_method
(
...
...
@@ -246,10 +242,7 @@ void Bridge::call_java(
jni
.
ensure_no_exception
();
trace_buf
.
append
(
jstring_to_oustring
(
jni
,
(
jstring
)
jo_descr
.
get
()
)
);
trace_buf
.
append
(
")"
);
OString
cstr_trace
(
OUStringToOString
(
trace_buf
.
makeStringAndClear
(),
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_trace
.
getStr
()
);
SAL_INFO
(
"bridges"
,
trace_buf
.
makeStringAndClear
());
#endif
// complex return value
...
...
@@ -476,9 +469,7 @@ inline void UNO_proxy::acquire() const
m_bridge
->
m_uno_env
,
&
that
,
UNO_proxy_free
,
m_oid
.
pData
,
(
typelib_InterfaceTypeDescription
*
)
m_type_info
->
m_td
.
get
()
);
#if OSL_DEBUG_LEVEL > 1
OSL_ASSERT
(
this
==
(
void
const
*
const
)
that
);
#endif
assert
(
this
==
(
void
const
*
const
)
that
);
}
}
...
...
@@ -538,16 +529,8 @@ void SAL_CALL UNO_proxy_free( uno_ExtEnvironment * env, void * proxy )
UNO_proxy
const
*
that
=
reinterpret_cast
<
UNO_proxy
const
*
>
(
proxy
);
Bridge
const
*
bridge
=
that
->
m_bridge
;
if
(
env
!=
bridge
->
m_uno_env
)
{
OSL_ASSERT
(
false
);
}
#if OSL_DEBUG_LEVEL > 1
OString
cstr_msg
(
OUStringToOString
(
"freeing binary uno proxy: "
+
that
->
m_oid
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_msg
.
getStr
()
);
#endif
assert
(
env
==
bridge
->
m_uno_env
);
SAL_INFO
(
"bridges"
,
"freeing binary uno proxy: "
<<
that
->
m_oid
);
try
{
...
...
@@ -561,22 +544,17 @@ void SAL_CALL UNO_proxy_free( uno_ExtEnvironment * env, void * proxy )
}
catch
(
BridgeRuntimeError
&
err
)
{
#if OSL_DEBUG_LEVEL > 0
OString
cstr_msg2
(
OUStringToOString
(
err
.
m_message
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_FAIL
(
cstr_msg2
.
getStr
()
);
#else
(
void
)
err
;
// unused
#endif
SAL_WARN
(
"bridges"
,
"ignoring BridgeRuntimeError
\"
"
<<
err
.
m_message
<<
"
\"
"
);
}
catch
(
::
jvmaccess
::
VirtualMachine
::
AttachGuard
::
CreationException
&
)
{
OSL_FAIL
(
"[jni_uno bridge error] attaching current thread to java failed!"
);
SAL_WARN
(
"bridges"
,
"attaching current thread to java failed"
);
}
bridge
->
release
();
#if OSL_DEBUG_LEVEL >
1
#if OSL_DEBUG_LEVEL >
0
*
(
int
*
)
that
=
0xdeadcafe
;
#endif
delete
that
;
...
...
@@ -607,17 +585,10 @@ void SAL_CALL UNO_proxy_dispatch(
UNO_proxy
const
*
that
=
static_cast
<
UNO_proxy
const
*
>
(
pUnoI
);
Bridge
const
*
bridge
=
that
->
m_bridge
;
#if OSL_DEBUG_LEVEL > 1
OUStringBuffer
trace_buf
(
64
);
trace_buf
.
append
(
"uno->java call: "
);
trace_buf
.
append
(
OUString
::
unacquired
(
&
member_td
->
pTypeName
)
);
trace_buf
.
append
(
" on oid "
);
trace_buf
.
append
(
that
->
m_oid
);
OString
cstr_msg
(
OUStringToOString
(
trace_buf
.
makeStringAndClear
(),
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_msg
.
getStr
()
);
#endif
SAL_INFO
(
"bridges"
,
"uno->java call: "
<<
OUString
::
unacquired
(
&
member_td
->
pTypeName
)
<<
" on oid "
<<
that
->
m_oid
);
try
{
...
...
@@ -633,7 +604,7 @@ void SAL_CALL UNO_proxy_dispatch(
while
(
attrib_td
->
pBaseRef
!=
0
)
{
attrib_holder
=
com
::
sun
::
star
::
uno
::
TypeDescription
(
attrib_td
->
pBaseRef
);
OSL_ASSERT
(
assert
(
attrib_holder
.
get
()
->
eTypeClass
==
typelib_TypeClass_INTERFACE_ATTRIBUTE
);
attrib_td
=
reinterpret_cast
<
...
...
@@ -676,7 +647,7 @@ void SAL_CALL UNO_proxy_dispatch(
while
(
method_td
->
pBaseRef
!=
0
)
{
method_holder
=
com
::
sun
::
star
::
uno
::
TypeDescription
(
method_td
->
pBaseRef
);
OSL_ASSERT
(
assert
(
method_holder
.
get
()
->
eTypeClass
==
typelib_TypeClass_INTERFACE_METHOD
);
method_td
=
reinterpret_cast
<
...
...
@@ -737,15 +708,15 @@ void SAL_CALL UNO_proxy_dispatch(
{
if
(
jo_ret
.
is
())
{
#if OSL_DEBUG_LEVEL > 0
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
SAL_WARN_IF
(
(
jstring_to_oustring
(
jni
,
static_cast
<
jstring
>
(
JLocalAutoRef
(
jni
,
compute_oid
(
jni
,
jo_ret
.
get
()))
.
get
()))
!=
that
->
m_oid
),
"bridges"
,
"different oids"
);
// refcount initially 1
uno_Interface
*
pUnoI2
=
new
UNO_proxy
(
jni
,
bridge
,
jo_ret
.
get
(),
...
...
@@ -830,11 +801,7 @@ void SAL_CALL UNO_proxy_dispatch(
::
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
);
#if OSL_DEBUG_LEVEL > 0
OString
cstr_msg2
(
OUStringToOString
(
exc
.
Message
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_TRACE
(
"%s"
,
cstr_msg2
.
getStr
()
);
#endif
SAL_INFO
(
"bridges"
,
exc
.
Message
);
}
catch
(
::
jvmaccess
::
VirtualMachine
::
AttachGuard
::
CreationException
&
)
{
...
...
@@ -845,11 +812,7 @@ void SAL_CALL UNO_proxy_dispatch(
::
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
);
#if OSL_DEBUG_LEVEL > 0
OString
cstr_msg2
(
OUStringToOString
(
exc
.
Message
,
RTL_TEXTENCODING_ASCII_US
)
);
OSL_FAIL
(
cstr_msg2
.
getStr
()
);
#endif
SAL_WARN
(
"bridges"
,
exc
.
Message
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment