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
37cbbb4b
Kaydet (Commit)
37cbbb4b
authored
Şub 12, 2015
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
jvmaccess doesn't have a stable interface anyway
Change-Id: I681443981a2da8bd3ca0c40965cfee300845c0e9
üst
eccbc97c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
120 deletions
+87
-120
classpath.hxx
include/jvmaccess/classpath.hxx
+69
-100
classpath.cxx
jvmaccess/source/classpath.cxx
+18
-20
No files found.
include/jvmaccess/classpath.hxx
Dosyayı görüntüle @
37cbbb4b
...
@@ -20,11 +20,14 @@
...
@@ -20,11 +20,14 @@
#ifndef INCLUDED_JVMACCESS_CLASSPATH_HXX
#ifndef INCLUDED_JVMACCESS_CLASSPATH_HXX
#define INCLUDED_JVMACCESS_CLASSPATH_HXX
#define INCLUDED_JVMACCESS_CLASSPATH_HXX
#include <jvmaccess/jvmaccessdllapi.h>
#include <sal/config.h>
#include <sal/config.h>
#include <com/sun/star/uno/Reference.hxx>
#include "jni.h"
#include <jni.h>
#include <com/sun/star/uno/Reference.hxx>
#include <jvmaccess/jvmaccessdllapi.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
uno
{
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
uno
{
class
XComponentContext
;
class
XComponentContext
;
...
@@ -34,103 +37,69 @@ namespace jvmaccess {
...
@@ -34,103 +37,69 @@ namespace jvmaccess {
/**
/**
Helper functions for class path handling.
Helper functions for class path handling.
*/
*/
class
JVMACCESS_DLLPUBLIC
ClassPath
{
namespace
ClassPath
{
public
:
/**
/**
translates a class path into a java.net.URL[] instance.
translates a class path into a java.net.URL[] instance.
@param context
@param context
a component context; must not be null.
a component context; must not be null.
@param environment
@param environment
a JNI environment; must not be null.
a JNI environment; must not be null.
@param classPath
@param classPath
a list of zero or more internal (see the
a list of zero or more internal (see the
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
where any space characters (U+0020) are ignored (and, in particular,
where any space characters (U+0020) are ignored (and, in particular, separate
separate adjacent URI references). Any vnd.sun.star.expand URL
adjacent URI references). Any vnd.sun.star.expand URL references in the list
references in the list are expanded using the
are expanded using the com.sun.star.util.theMacroExpander singleton of the
com.sun.star.util.theMacroExpander singleton of the given context.
given context.
@returns
@returns
a local reference to a java.net.URL[] instance containing the external
a local reference to a java.net.URL[] instance containing the external (see
(see the com.sun.star.uri.ExternalUriReferenceTranslator service)
the com.sun.star.uri.ExternalUriReferenceTranslator service) equivalents of
equivalents of all the URI references in the given classPath. If null, a
all the URI references in the given classPath. If null, a (still pending)
(still pending) JNI exception occurred.
JNI exception occurred.
@throws com::sun::star::uno::RuntimeException
@throws com::sun::star::uno::RuntimeException
*/
*/
static
inline
::
jobjectArray
JVMACCESS_DLLPUBLIC
jobjectArray
translateToUrls
(
translateToUrls
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
::
com
::
sun
::
star
::
uno
::
Reference
<
JNIEnv
*
environment
,
OUString
const
&
classPath
);
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
context
,
::
JNIEnv
*
environment
,
OUString
const
&
classPath
)
/**
{
loads a class via a java.net.URLClassLoader.
return
static_cast
<
::
jobjectArray
>
(
@param context
doTranslateToUrls
(
context
,
environment
,
classPath
));
a component context; must not be null.
}
@param environment
/**
a JNI environment; must not be null.
loads a class via a java.net.URLClassLoader.
@param classPath
@param context
a list of zero or more internal (see the
a component context; must not be null.
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
where any space characters (U+0020) are ignored (and, in particular, separate
@param environment
adjacent URI references). Any vnd.sun.star.expand URL references in the list
a JNI environment; must not be null.
are expanded using the com.sun.star.util.theMacroExpander singleton of the
given context.
@param classPath
a list of zero or more internal (see the
@param name
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
the Java binary name of the class to load.
where any space characters (U+0020) are ignored (and, in particular,
separate adjacent URI references). Any vnd.sun.star.expand URL
@returns
references in the list are expanded using the
a local reference to a java.lang.Class instance. If null, a (still pending)
com.sun.star.util.theMacroExpander singleton of the given context.
JNI exception occurred.
@param name
@throws com::sun::star::uno::RuntimeException
the Java binary name of the class to load.
*/
JVMACCESS_DLLPUBLIC
jclass
loadClass
(
@returns
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
a local reference to a java.lang.Class instance. If null, a (still
JNIEnv
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
);
pending) JNI exception occurred.
}
@throws com::sun::star::uno::RuntimeException
*/
static
inline
::
jclass
loadClass
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
context
,
::
JNIEnv
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
)
{
return
static_cast
<
::
jclass
>
(
doLoadClass
(
context
,
environment
,
classPath
,
name
));
}
private
:
ClassPath
()
SAL_DELETED_FUNCTION
;
//TODO: get rid of this class
ClassPath
(
ClassPath
&
)
SAL_DELETED_FUNCTION
;
~
ClassPath
()
SAL_DELETED_FUNCTION
;
void
operator
=
(
ClassPath
&
)
SAL_DELETED_FUNCTION
;
// Functions that replace JNIEnv, jobjectArray, and jclass with void *, so
// that their mangled C++ names do not depend on the JDK version used at
// compile time:
static
void
*
doTranslateToUrls
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
context
,
void
*
environment
,
OUString
const
&
classPath
);
static
void
*
doLoadClass
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
context
,
void
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
);
};
}
}
...
...
jvmaccess/source/classpath.cxx
Dosyayı görüntüle @
37cbbb4b
...
@@ -38,18 +38,17 @@
...
@@ -38,18 +38,17 @@
#include "jni.h"
#include "jni.h"
void
*
::
jvmaccess
::
ClassPath
::
doT
ranslateToUrls
(
jobjectArray
jvmaccess
::
ClassPath
::
t
ranslateToUrls
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
void
*
environment
,
OUString
const
&
classPath
)
JNIEnv
*
environment
,
OUString
const
&
classPath
)
{
{
OSL_ASSERT
(
context
.
is
()
&&
environment
!=
0
);
OSL_ASSERT
(
context
.
is
()
&&
environment
!=
0
);
::
JNIEnv
*
const
env
=
static_cast
<
::
JNIEnv
*
>
(
environment
);
jclass
classUrl
(
environment
->
FindClass
(
"java/net/URL"
));
jclass
classUrl
(
env
->
FindClass
(
"java/net/URL"
));
if
(
classUrl
==
0
)
{
if
(
classUrl
==
0
)
{
return
0
;
return
0
;
}
}
jmethodID
ctorUrl
(
jmethodID
ctorUrl
(
env
->
GetMethodID
(
classUrl
,
"<init>"
,
"(Ljava/lang/String;)V"
));
env
ironment
->
GetMethodID
(
classUrl
,
"<init>"
,
"(Ljava/lang/String;)V"
));
if
(
ctorUrl
==
0
)
{
if
(
ctorUrl
==
0
)
{
return
0
;
return
0
;
}
}
...
@@ -73,20 +72,20 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls(
...
@@ -73,20 +72,20 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls(
}
}
}
}
jvalue
arg
;
jvalue
arg
;
arg
.
l
=
env
->
NewString
(
arg
.
l
=
env
ironment
->
NewString
(
static_cast
<
jchar
const
*
>
(
url
.
getStr
()),
static_cast
<
jchar
const
*
>
(
url
.
getStr
()),
static_cast
<
jsize
>
(
url
.
getLength
()));
static_cast
<
jsize
>
(
url
.
getLength
()));
if
(
arg
.
l
==
0
)
{
if
(
arg
.
l
==
0
)
{
return
0
;
return
0
;
}
}
jobject
o
(
env
->
NewObjectA
(
classUrl
,
ctorUrl
,
&
arg
));
jobject
o
(
env
ironment
->
NewObjectA
(
classUrl
,
ctorUrl
,
&
arg
));
if
(
o
==
0
)
{
if
(
o
==
0
)
{
return
0
;
return
0
;
}
}
urls
.
push_back
(
o
);
urls
.
push_back
(
o
);
}
}
}
}
jobjectArray
result
=
env
->
NewObjectArray
(
jobjectArray
result
=
env
ironment
->
NewObjectArray
(
static_cast
<
jsize
>
(
urls
.
size
()),
classUrl
,
0
);
static_cast
<
jsize
>
(
urls
.
size
()),
classUrl
,
0
);
// static_cast is ok, as each element of urls occupied at least one
// static_cast is ok, as each element of urls occupied at least one
// character of the OUString classPath
// character of the OUString classPath
...
@@ -96,49 +95,48 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls(
...
@@ -96,49 +95,48 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls(
jsize
idx
=
0
;
jsize
idx
=
0
;
for
(
std
::
vector
<
jobject
>::
iterator
i
(
urls
.
begin
());
i
!=
urls
.
end
();
++
i
)
for
(
std
::
vector
<
jobject
>::
iterator
i
(
urls
.
begin
());
i
!=
urls
.
end
();
++
i
)
{
{
env
->
SetObjectArrayElement
(
result
,
idx
++
,
*
i
);
env
ironment
->
SetObjectArrayElement
(
result
,
idx
++
,
*
i
);
}
}
return
result
;
return
result
;
}
}
void
*
::
jvmaccess
::
ClassPath
::
doL
oadClass
(
jclass
jvmaccess
::
ClassPath
::
l
oadClass
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
void
*
environment
,
OUString
const
&
classPath
,
JNIEnv
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
)
OUString
const
&
name
)
{
{
OSL_ASSERT
(
context
.
is
()
&&
environment
!=
0
);
OSL_ASSERT
(
context
.
is
()
&&
environment
!=
0
);
::
JNIEnv
*
const
env
=
static_cast
<
::
JNIEnv
*
>
(
environment
);
jclass
classLoader
(
environment
->
FindClass
(
"java/net/URLClassLoader"
));
jclass
classLoader
(
env
->
FindClass
(
"java/net/URLClassLoader"
));
if
(
classLoader
==
0
)
{
if
(
classLoader
==
0
)
{
return
0
;
return
0
;
}
}
jmethodID
ctorLoader
(
jmethodID
ctorLoader
(
env
->
GetMethodID
(
classLoader
,
"<init>"
,
"([Ljava/net/URL;)V"
));
env
ironment
->
GetMethodID
(
classLoader
,
"<init>"
,
"([Ljava/net/URL;)V"
));
if
(
ctorLoader
==
0
)
{
if
(
ctorLoader
==
0
)
{
return
0
;
return
0
;
}
}
jvalue
arg
;
jvalue
arg
;
arg
.
l
=
translateToUrls
(
context
,
env
,
classPath
);
arg
.
l
=
translateToUrls
(
context
,
env
ironment
,
classPath
);
if
(
arg
.
l
==
0
)
{
if
(
arg
.
l
==
0
)
{
return
0
;
return
0
;
}
}
jobject
cl
=
env
->
NewObjectA
(
classLoader
,
ctorLoader
,
&
arg
);
jobject
cl
=
env
ironment
->
NewObjectA
(
classLoader
,
ctorLoader
,
&
arg
);
if
(
cl
==
0
)
{
if
(
cl
==
0
)
{
return
0
;
return
0
;
}
}
jmethodID
methLoadClass
(
jmethodID
methLoadClass
(
env
->
GetMethodID
(
env
ironment
->
GetMethodID
(
classLoader
,
"loadClass"
,
"(Ljava/lang/String;)Ljava/lang/Class;"
));
classLoader
,
"loadClass"
,
"(Ljava/lang/String;)Ljava/lang/Class;"
));
if
(
methLoadClass
==
0
)
{
if
(
methLoadClass
==
0
)
{
return
0
;
return
0
;
}
}
arg
.
l
=
env
->
NewString
(
arg
.
l
=
env
ironment
->
NewString
(
static_cast
<
jchar
const
*
>
(
name
.
getStr
()),
static_cast
<
jchar
const
*
>
(
name
.
getStr
()),
static_cast
<
jsize
>
(
name
.
getLength
()));
static_cast
<
jsize
>
(
name
.
getLength
()));
if
(
arg
.
l
==
0
)
{
if
(
arg
.
l
==
0
)
{
return
0
;
return
0
;
}
}
return
env
->
CallObjectMethodA
(
cl
,
methLoadClass
,
&
arg
);
return
static_cast
<
jclass
>
(
environment
->
CallObjectMethodA
(
cl
,
methLoadClass
,
&
arg
));
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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