summaryrefslogtreecommitdiff
path: root/jvmaccess/source/classpath.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-02-12 07:45:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-02-12 07:49:41 +0100
commit37cbbb4b486c8eeb87f9491e776fc06a234ca6ec (patch)
treee04c14698026fa952fdb1f1cbbb6d5190292e843 /jvmaccess/source/classpath.cxx
parenteccbc97c7c224269fe261b8924e7866c3758ec91 (diff)
jvmaccess doesn't have a stable interface anyway
Change-Id: I681443981a2da8bd3ca0c40965cfee300845c0e9
Diffstat (limited to 'jvmaccess/source/classpath.cxx')
-rw-r--r--jvmaccess/source/classpath.cxx38
1 files changed, 18 insertions, 20 deletions
diff --git a/jvmaccess/source/classpath.cxx b/jvmaccess/source/classpath.cxx
index d01e9cebfb1f..4b653fe5df45 100644
--- a/jvmaccess/source/classpath.cxx
+++ b/jvmaccess/source/classpath.cxx
@@ -38,18 +38,17 @@
#include "jni.h"
-void * ::jvmaccess::ClassPath::doTranslateToUrls(
+jobjectArray jvmaccess::ClassPath::translateToUrls(
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"));
+ environment->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 = environment->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(environment->NewObjectA(classUrl, ctorUrl, &arg));
if (o == 0) {
return 0;
}
urls.push_back(o);
}
}
- jobjectArray result = env->NewObjectArray(
+ jobjectArray result = environment->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);
+ environment->SetObjectArrayElement(result, idx++, *i);
}
return result;
}
-void * ::jvmaccess::ClassPath::doLoadClass(
+jclass jvmaccess::ClassPath::loadClass(
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"));
+ environment->GetMethodID(classLoader, "<init>", "([Ljava/net/URL;)V"));
if (ctorLoader == 0) {
return 0;
}
jvalue arg;
- arg.l = translateToUrls(context, env, classPath);
+ arg.l = translateToUrls(context, environment, classPath);
if (arg.l == 0) {
return 0;
}
- jobject cl = env->NewObjectA(classLoader, ctorLoader, &arg);
+ jobject cl = environment->NewObjectA(classLoader, ctorLoader, &arg);
if (cl == 0) {
return 0;
}
jmethodID methLoadClass(
- env->GetMethodID(
+ environment->GetMethodID(
classLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"));
if (methLoadClass == 0) {
return 0;
}
- arg.l = env->NewString(
+ arg.l = environment->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: */