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 @@
#ifndef INCLUDED_JVMACCESS_CLASSPATH_HXX
#define INCLUDED_JVMACCESS_CLASSPATH_HXX
#include <jvmaccess/jvmaccessdllapi.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
{
class
XComponentContext
;
...
...
@@ -34,103 +37,69 @@ namespace jvmaccess {
/**
Helper functions for class path handling.
*/
class
JVMACCESS_DLLPUBLIC
ClassPath
{
public
:
/**
translates a class path into a java.net.URL[] instance.
@param context
a component context; must not be null.
@param environment
a JNI environment; must not be null.
@param classPath
a list of zero or more internal (see the
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
where any space characters (U+0020) are ignored (and, in particular,
separate adjacent URI references). Any vnd.sun.star.expand URL
references in the list are expanded using the
com.sun.star.util.theMacroExpander singleton of the given context.
@returns
a local reference to a java.net.URL[] instance containing the external
(see the com.sun.star.uri.ExternalUriReferenceTranslator service)
equivalents of all the URI references in the given classPath. If null, a
(still pending) JNI exception occurred.
@throws com::sun::star::uno::RuntimeException
*/
static
inline
::
jobjectArray
translateToUrls
(
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
const
&
context
,
::
JNIEnv
*
environment
,
OUString
const
&
classPath
)
{
return
static_cast
<
::
jobjectArray
>
(
doTranslateToUrls
(
context
,
environment
,
classPath
));
}
/**
loads a class via a java.net.URLClassLoader.
@param context
a component context; must not be null.
@param environment
a JNI environment; must not be null.
@param classPath
a list of zero or more internal (see the
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
where any space characters (U+0020) are ignored (and, in particular,
separate adjacent URI references). Any vnd.sun.star.expand URL
references in the list are expanded using the
com.sun.star.util.theMacroExpander singleton of the given context.
@param name
the Java binary name of the class to load.
@returns
a local reference to a java.lang.Class instance. If null, a (still
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
);
};
*/
namespace
ClassPath
{
/**
translates a class path into a java.net.URL[] instance.
@param context
a component context; must not be null.
@param environment
a JNI environment; must not be null.
@param classPath
a list of zero or more internal (see the
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
where any space characters (U+0020) are ignored (and, in particular, separate
adjacent URI references). Any vnd.sun.star.expand URL references in the list
are expanded using the com.sun.star.util.theMacroExpander singleton of the
given context.
@returns
a local reference to a java.net.URL[] instance containing the external (see
the com.sun.star.uri.ExternalUriReferenceTranslator service) equivalents of
all the URI references in the given classPath. If null, a (still pending)
JNI exception occurred.
@throws com::sun::star::uno::RuntimeException
*/
JVMACCESS_DLLPUBLIC
jobjectArray
translateToUrls
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
JNIEnv
*
environment
,
OUString
const
&
classPath
);
/**
loads a class via a java.net.URLClassLoader.
@param context
a component context; must not be null.
@param environment
a JNI environment; must not be null.
@param classPath
a list of zero or more internal (see the
com.sun.star.uri.ExternalUriReferenceTranslator service) URI references,
where any space characters (U+0020) are ignored (and, in particular, separate
adjacent URI references). Any vnd.sun.star.expand URL references in the list
are expanded using the com.sun.star.util.theMacroExpander singleton of the
given context.
@param name
the Java binary name of the class to load.
@returns
a local reference to a java.lang.Class instance. If null, a (still pending)
JNI exception occurred.
@throws com::sun::star::uno::RuntimeException
*/
JVMACCESS_DLLPUBLIC
jclass
loadClass
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
JNIEnv
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
);
}
}
...
...
jvmaccess/source/classpath.cxx
Dosyayı görüntüle @
37cbbb4b
...
...
@@ -38,18 +38,17 @@
#include "jni.h"
void
*
::
jvmaccess
::
ClassPath
::
doT
ranslateToUrls
(
jobjectArray
jvmaccess
::
ClassPath
::
t
ranslateToUrls
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
void
*
environment
,
OUString
const
&
classPath
)
JNIEnv
*
environment
,
OUString
const
&
classPath
)
{
OSL_ASSERT
(
context
.
is
()
&&
environment
!=
0
);
::
JNIEnv
*
const
env
=
static_cast
<
::
JNIEnv
*
>
(
environment
);
jclass
classUrl
(
env
->
FindClass
(
"java/net/URL"
));
jclass
classUrl
(
environment
->
FindClass
(
"java/net/URL"
));
if
(
classUrl
==
0
)
{
return
0
;
}
jmethodID
ctorUrl
(
env
->
GetMethodID
(
classUrl
,
"<init>"
,
"(Ljava/lang/String;)V"
));
env
ironment
->
GetMethodID
(
classUrl
,
"<init>"
,
"(Ljava/lang/String;)V"
));
if
(
ctorUrl
==
0
)
{
return
0
;
}
...
...
@@ -73,20 +72,20 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls(
}
}
jvalue
arg
;
arg
.
l
=
env
->
NewString
(
arg
.
l
=
env
ironment
->
NewString
(
static_cast
<
jchar
const
*
>
(
url
.
getStr
()),
static_cast
<
jsize
>
(
url
.
getLength
()));
if
(
arg
.
l
==
0
)
{
return
0
;
}
jobject
o
(
env
->
NewObjectA
(
classUrl
,
ctorUrl
,
&
arg
));
jobject
o
(
env
ironment
->
NewObjectA
(
classUrl
,
ctorUrl
,
&
arg
));
if
(
o
==
0
)
{
return
0
;
}
urls
.
push_back
(
o
);
}
}
jobjectArray
result
=
env
->
NewObjectArray
(
jobjectArray
result
=
env
ironment
->
NewObjectArray
(
static_cast
<
jsize
>
(
urls
.
size
()),
classUrl
,
0
);
// static_cast is ok, as each element of urls occupied at least one
// character of the OUString classPath
...
...
@@ -96,49 +95,48 @@ void * ::jvmaccess::ClassPath::doTranslateToUrls(
jsize
idx
=
0
;
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
;
}
void
*
::
jvmaccess
::
ClassPath
::
doL
oadClass
(
jclass
jvmaccess
::
ClassPath
::
l
oadClass
(
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
const
&
context
,
void
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
)
JNIEnv
*
environment
,
OUString
const
&
classPath
,
OUString
const
&
name
)
{
OSL_ASSERT
(
context
.
is
()
&&
environment
!=
0
);
::
JNIEnv
*
const
env
=
static_cast
<
::
JNIEnv
*
>
(
environment
);
jclass
classLoader
(
env
->
FindClass
(
"java/net/URLClassLoader"
));
jclass
classLoader
(
environment
->
FindClass
(
"java/net/URLClassLoader"
));
if
(
classLoader
==
0
)
{
return
0
;
}
jmethodID
ctorLoader
(
env
->
GetMethodID
(
classLoader
,
"<init>"
,
"([Ljava/net/URL;)V"
));
env
ironment
->
GetMethodID
(
classLoader
,
"<init>"
,
"([Ljava/net/URL;)V"
));
if
(
ctorLoader
==
0
)
{
return
0
;
}
jvalue
arg
;
arg
.
l
=
translateToUrls
(
context
,
env
,
classPath
);
arg
.
l
=
translateToUrls
(
context
,
env
ironment
,
classPath
);
if
(
arg
.
l
==
0
)
{
return
0
;
}
jobject
cl
=
env
->
NewObjectA
(
classLoader
,
ctorLoader
,
&
arg
);
jobject
cl
=
env
ironment
->
NewObjectA
(
classLoader
,
ctorLoader
,
&
arg
);
if
(
cl
==
0
)
{
return
0
;
}
jmethodID
methLoadClass
(
env
->
GetMethodID
(
env
ironment
->
GetMethodID
(
classLoader
,
"loadClass"
,
"(Ljava/lang/String;)Ljava/lang/Class;"
));
if
(
methLoadClass
==
0
)
{
return
0
;
}
arg
.
l
=
env
->
NewString
(
arg
.
l
=
env
ironment
->
NewString
(
static_cast
<
jchar
const
*
>
(
name
.
getStr
()),
static_cast
<
jsize
>
(
name
.
getLength
()));
if
(
arg
.
l
==
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: */
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