зеркало из https://github.com/mozilla/pjs.git
Bug 316090 - GREImpl.loadDependentLibraries hardcodes the list, and turn javaxpcom on by default for XULRunner, patch by jhpedemonte and myself with co-review
This commit is contained in:
Родитель
890da04338
Коммит
35d13292bb
|
@ -254,6 +254,10 @@ ifdef MOZ_PREF_EXTENSIONS
|
||||||
tier_50_dirs += extensions/pref
|
tier_50_dirs += extensions/pref
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef MOZ_JAVAXPCOM
|
||||||
|
tier_50_dirs += extensions/java
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef MOZ_XUL_APP
|
ifdef MOZ_XUL_APP
|
||||||
ifndef BUILD_STATIC_LIBS
|
ifndef BUILD_STATIC_LIBS
|
||||||
tier_50_dirs += toolkit/library
|
tier_50_dirs += toolkit/library
|
||||||
|
|
|
@ -1356,6 +1356,17 @@ if [ "$MOZ_XMLEXTRAS" ]; then
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$MOZ_JAVAXPCOM" ]; then
|
||||||
|
MAKEFILES_javaxpcom="
|
||||||
|
extensions/java/Makefile
|
||||||
|
extensions/java/xpcom/Makefile
|
||||||
|
extensions/java/xpcom/interfaces/Makefile
|
||||||
|
extensions/java/xpcom/src/Makefile
|
||||||
|
extensions/java/xpcom/glue/Makefile
|
||||||
|
extensions/java/xpcom/tools/genifaces/Makefile
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
# directory/xpcom
|
# directory/xpcom
|
||||||
if [ "$MOZ_LDAP_XPCOM" ]; then
|
if [ "$MOZ_LDAP_XPCOM" ]; then
|
||||||
MAKEFILES_ldap="
|
MAKEFILES_ldap="
|
||||||
|
@ -1420,13 +1431,6 @@ for extension in $MOZ_EXTENSIONS; do
|
||||||
inspector ) MAKEFILES_extensions="$MAKEFILES_extensions
|
inspector ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||||
$MAKEFILES_inspector"
|
$MAKEFILES_inspector"
|
||||||
;;
|
;;
|
||||||
java ) MAKEFILES_extensions="$MAKEFILES_extensions
|
|
||||||
extensions/java/Makefile
|
|
||||||
extensions/java/xpcom/Makefile
|
|
||||||
extensions/java/xpcom/build/Makefile
|
|
||||||
extensions/java/xpcom/tests/Makefile
|
|
||||||
extensions/java/xpcom/tools/genifaces/Makefile
|
|
||||||
" ;;
|
|
||||||
spatialnavigation ) MAKEFILES_extensions="$MAKEFILES_extensions
|
spatialnavigation ) MAKEFILES_extensions="$MAKEFILES_extensions
|
||||||
$MAKEFILES_spatialnavigation"
|
$MAKEFILES_spatialnavigation"
|
||||||
;;
|
;;
|
||||||
|
@ -1576,7 +1580,7 @@ $MAKEFILES_gfx
|
||||||
$MAKEFILES_accessible
|
$MAKEFILES_accessible
|
||||||
$MAKEFILES_htmlparser
|
$MAKEFILES_htmlparser
|
||||||
$MAKEFILES_intl
|
$MAKEFILES_intl
|
||||||
$MAKEFILES_java_supplement
|
$MAKEFILES_javaxpcom
|
||||||
$MAKEFILES_ldap
|
$MAKEFILES_ldap
|
||||||
$MAKEFILES_leaky
|
$MAKEFILES_leaky
|
||||||
$MAKEFILES_jpeg
|
$MAKEFILES_jpeg
|
||||||
|
|
|
@ -140,7 +140,7 @@ MOZ_NO_XPCOM_OBSOLETE = @MOZ_NO_XPCOM_OBSOLETE@
|
||||||
MOZ_NO_FAST_LOAD = @MOZ_NO_FAST_LOAD@
|
MOZ_NO_FAST_LOAD = @MOZ_NO_FAST_LOAD@
|
||||||
NS_PRINTING = @NS_PRINTING@
|
NS_PRINTING = @NS_PRINTING@
|
||||||
|
|
||||||
MOZ_ENABLE_JAVAXPCOM = @MOZ_ENABLE_JAVAXPCOM@
|
MOZ_JAVAXPCOM = @MOZ_JAVAXPCOM@
|
||||||
JAVA_INCLUDE_PATH=@JAVA_INCLUDE_PATH@
|
JAVA_INCLUDE_PATH=@JAVA_INCLUDE_PATH@
|
||||||
JAVAC=@JAVAC@
|
JAVAC=@JAVAC@
|
||||||
JAR=@JAR@
|
JAR=@JAR@
|
||||||
|
|
108
configure.in
108
configure.in
|
@ -4042,6 +4042,7 @@ MOZ_EXTENSIONS_ALL=" cookie wallet content-packs xml-rpc help p3p venkman inspec
|
||||||
MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
|
MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
|
||||||
MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
|
MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
|
||||||
MOZ_IPCD=
|
MOZ_IPCD=
|
||||||
|
MOZ_JAVAXPCOM=
|
||||||
MOZ_JSDEBUGGER=1
|
MOZ_JSDEBUGGER=1
|
||||||
MOZ_JSLOADER=1
|
MOZ_JSLOADER=1
|
||||||
MOZ_LDAP_XPCOM=
|
MOZ_LDAP_XPCOM=
|
||||||
|
@ -4239,6 +4240,7 @@ xulrunner)
|
||||||
MOZ_XULRUNNER=1
|
MOZ_XULRUNNER=1
|
||||||
MOZ_ENABLE_LIBXUL=1
|
MOZ_ENABLE_LIBXUL=1
|
||||||
MOZ_APP_VERSION=$MOZILLA_VERSION
|
MOZ_APP_VERSION=$MOZILLA_VERSION
|
||||||
|
MOZ_JAVAXPCOM=1
|
||||||
MOZ_EXTENSIONS_DEFAULT=" xml-rpc universalchardet webservices gnomevfs auth"
|
MOZ_EXTENSIONS_DEFAULT=" xml-rpc universalchardet webservices gnomevfs auth"
|
||||||
AC_DEFINE(MOZ_XULRUNNER)
|
AC_DEFINE(MOZ_XULRUNNER)
|
||||||
;;
|
;;
|
||||||
|
@ -4893,6 +4895,61 @@ MOZ_ARG_DISABLE_BOOL(pref-extensions,
|
||||||
MOZ_PREF_EXTENSIONS=,
|
MOZ_PREF_EXTENSIONS=,
|
||||||
MOZ_PREF_EXTENSIONS=1 )
|
MOZ_PREF_EXTENSIONS=1 )
|
||||||
|
|
||||||
|
dnl ========================================================
|
||||||
|
dnl Javaconnect
|
||||||
|
dnl ========================================================
|
||||||
|
MOZ_ARG_ENABLE_BOOL(javaconnect,
|
||||||
|
[ --enable-javaxpcom
|
||||||
|
Enable Java-XPCOM bridge],
|
||||||
|
MOZ_JAVAXPCOM=1,
|
||||||
|
MOZ_JAVAXPCOM= )
|
||||||
|
|
||||||
|
if test -n "${MOZ_JAVAXPCOM}"; then
|
||||||
|
case "$host_os" in
|
||||||
|
cygwin*|msvc*|mks*)
|
||||||
|
if test -n "$JAVA_HOME"; then
|
||||||
|
JAVA_HOME=`cygpath -u \`cygpath -m -s "$JAVA_HOME"\``
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -n "${JAVA_INCLUDE_PATH}"; then
|
||||||
|
dnl Make sure jni.h exists in the given include path.
|
||||||
|
if test ! -f "$JAVA_INCLUDE_PATH/jni.h"; then
|
||||||
|
AC_MSG_ERROR([jni.h was not found in given include path $JAVA_INCLUDE_PATH.])
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
case "$target_os" in
|
||||||
|
darwin*)
|
||||||
|
dnl Default to java system location
|
||||||
|
JAVA_INCLUDE_PATH=/System/Library/Frameworks/JavaVM.framework/Headers
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
dnl Try $JAVA_HOME
|
||||||
|
JAVA_INCLUDE_PATH="$JAVA_HOME/include"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if test ! -f "$JAVA_INCLUDE_PATH/jni.h"; then
|
||||||
|
AC_MSG_ERROR([The header jni.h was not found. Set \$JAVA_HOME or use --with-java-include-path={java-include-dir}.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "${JAVA_BIN_PATH}"; then
|
||||||
|
dnl Look for javac and jar in the specified path.
|
||||||
|
JAVA_PATH="$JAVA_BIN_PATH"
|
||||||
|
else
|
||||||
|
dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
|
||||||
|
JAVA_PATH="$JAVA_HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_PATH_PROG(JAVAC, javac, :, $JAVA_PATH)
|
||||||
|
AC_PATH_PROG(JAR, jar, :, $JAVA_PATH)
|
||||||
|
if test -z "$JAVAC" || test "$JAVAC" = ":" || test -z "$JAR" || test "$JAR" = ":"; then
|
||||||
|
AC_MSG_ERROR([The programs javac and jar were not found. Set \$JAVA_HOME or use --with-java-bin-path={java-bin-dir}.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
dnl = Enable compilation of specific extension modules
|
dnl = Enable compilation of specific extension modules
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
|
@ -4974,54 +5031,9 @@ if test `echo "$MOZ_EXTENSIONS" | grep -c pref` -ne 0; then
|
||||||
MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|pref||g'`
|
MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|pref||g'`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MOZ_ENABLE_JAVAXPCOM=
|
|
||||||
JAVAC=
|
|
||||||
JAR=
|
|
||||||
if test `echo "$MOZ_EXTENSIONS" | grep -c java` -ne 0; then
|
if test `echo "$MOZ_EXTENSIONS" | grep -c java` -ne 0; then
|
||||||
MOZ_ENABLE_JAVAXPCOM=1
|
AC_MSG_WARN([java is no longer an extension, use --enable-javaxpcom to enable.])
|
||||||
|
MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|java||g'`
|
||||||
case "$host_os" in
|
|
||||||
cygwin*|msvc*|mks*)
|
|
||||||
if test -n "$JAVA_HOME"; then
|
|
||||||
JAVA_HOME=`cygpath -u \`cygpath -m -s "$JAVA_HOME"\``
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if test -n "${JAVA_INCLUDE_PATH}"; then
|
|
||||||
dnl Make sure jni.h exists in the given include path.
|
|
||||||
if test ! -f "$JAVA_INCLUDE_PATH/jni.h"; then
|
|
||||||
AC_MSG_ERROR([jni.h was not found in given include path $JAVA_INCLUDE_PATH.])
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
case "$target_os" in
|
|
||||||
darwin*)
|
|
||||||
dnl Default to java system location
|
|
||||||
JAVA_INCLUDE_PATH=/System/Library/Frameworks/JavaVM.framework/Headers
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
dnl Try $JAVA_HOME
|
|
||||||
JAVA_INCLUDE_PATH="$JAVA_HOME/include"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if test ! -f "$JAVA_INCLUDE_PATH/jni.h"; then
|
|
||||||
AC_MSG_ERROR([The header jni.h was not found. Set \$JAVA_HOME or use --with-java-include-path={java-include-dir}.])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -n "${JAVA_BIN_PATH}"; then
|
|
||||||
dnl Look for javac and jar in the specified path.
|
|
||||||
JAVA_PATH="$JAVA_BIN_PATH"
|
|
||||||
else
|
|
||||||
dnl No path specified, so look for javac and jar are in $JAVA_HOME & $PATH.
|
|
||||||
JAVA_PATH="$JAVA_HOME/bin:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_PATH_PROG(JAVAC, javac, :, $JAVA_PATH)
|
|
||||||
AC_PATH_PROG(JAR, jar, :, $JAVA_PATH)
|
|
||||||
if test -z "$JAVAC" || test "$JAVAC" = ":" || test -z "$JAR" || test "$JAR" = ":"; then
|
|
||||||
AC_MSG_ERROR([The programs javac and jar were not found. Set \$JAVA_HOME or use --with-java-bin-path={java-bin-dir}.])
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl Remove dupes
|
dnl Remove dupes
|
||||||
|
@ -6853,7 +6865,7 @@ AC_SUBST(MOZ_PLACES)
|
||||||
AC_SUBST(MOZ_STORAGE)
|
AC_SUBST(MOZ_STORAGE)
|
||||||
AC_SUBST(NS_PRINTING)
|
AC_SUBST(NS_PRINTING)
|
||||||
|
|
||||||
AC_SUBST(MOZ_ENABLE_JAVAXPCOM)
|
AC_SUBST(MOZ_JAVAXPCOM)
|
||||||
AC_SUBST(JAVA_INCLUDE_PATH)
|
AC_SUBST(JAVA_INCLUDE_PATH)
|
||||||
AC_SUBST(JAVAC)
|
AC_SUBST(JAVAC)
|
||||||
AC_SUBST(JAR)
|
AC_SUBST(JAR)
|
||||||
|
|
|
@ -42,7 +42,15 @@ VPATH = @srcdir@
|
||||||
|
|
||||||
include $(DEPTH)/config/autoconf.mk
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
DIRS = tools/genifaces interfaces src
|
DIRS = src
|
||||||
|
|
||||||
|
TOOL_DIRS = \
|
||||||
|
tools/genifaces \
|
||||||
|
interfaces \
|
||||||
|
glue \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
||||||
|
tools::
|
||||||
|
$(MAKE) -C src jarfile
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
# http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
# for the specific language governing rights and limitations under the
|
||||||
|
# License.
|
||||||
|
#
|
||||||
|
# The Original Code is Java XPCOM Bindings.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is
|
||||||
|
# IBM Corporation.
|
||||||
|
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
# IBM Corporation. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
# Javier Pedemonte (jhpedemonte@gmail.com)
|
||||||
|
#
|
||||||
|
# Alternatively, the contents of this file may be used under the terms of
|
||||||
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
# use your version of this file under the terms of the MPL, indicate your
|
||||||
|
# decision by deleting the provisions above and replace them with the notice
|
||||||
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
#
|
||||||
|
# ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
DEPTH = ../../../..
|
||||||
|
topsrcdir = @top_srcdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
|
MODULE = javaxpcomglue
|
||||||
|
LIBRARY_NAME = javaxpcomglue
|
||||||
|
|
||||||
|
# On Mac OS X, JNI libraries must end with a '.jnilib' extension
|
||||||
|
ifeq ($(OS_ARCH),Darwin)
|
||||||
|
DLL_SUFFIX = .jnilib
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPSRCS = nsJavaXPCOMGlue.cpp
|
||||||
|
|
||||||
|
DEFINES += -DXPCOM_GLUE
|
||||||
|
|
||||||
|
LOCAL_INCLUDES = -I$(JAVA_INCLUDE_PATH)
|
||||||
|
|
||||||
|
ifeq ($(OS_ARCH),WINNT)
|
||||||
|
LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/win32
|
||||||
|
else
|
||||||
|
LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/linux
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
|
||||||
|
|
||||||
|
EXTRA_DSO_LDOPTS = \
|
||||||
|
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
|
@ -0,0 +1,285 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Java XPCOM Bindings.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* IBM Corporation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* IBM Corporation. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Javier Pedemonte (jhpedemonte@gmail.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
#include "nsXPCOMPrivate.h" // for XPCOM_DLL defines.
|
||||||
|
#include "nsXPCOMGlue.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define GRE_NATIVE(func) Java_org_mozilla_xpcom_internal_GREImpl_##func
|
||||||
|
#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_internal_XPCOMImpl_##func
|
||||||
|
#define JAVAPROXY_NATIVE(func) \
|
||||||
|
Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_##func
|
||||||
|
|
||||||
|
|
||||||
|
/***********************
|
||||||
|
* JNI Load & Unload
|
||||||
|
***********************/
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jint JNICALL
|
||||||
|
JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||||
|
{
|
||||||
|
// Let the JVM know that we are using JDK 1.2 JNI features.
|
||||||
|
return JNI_VERSION_1_2;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
JNI_OnUnload(JavaVM* vm, void* reserved)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************
|
||||||
|
* Javaconnect JNI interfaces
|
||||||
|
********************************/
|
||||||
|
|
||||||
|
typedef void (*JX_InitEmbeddingFunc) (JNIEnv*, jobject, jobject, jobject,
|
||||||
|
jobject);
|
||||||
|
typedef void (*JX_TermEmbeddingFunc) (JNIEnv*, jobject);
|
||||||
|
typedef jobject (*JX_InitXPCOMFunc) (JNIEnv*, jobject, jobject, jobject);
|
||||||
|
typedef void (*JX_ShutdownXPCOMFunc) (JNIEnv*, jobject, jobject);
|
||||||
|
typedef jobject (*JX_NewLocalFileFunc) (JNIEnv*, jobject, jstring, jboolean);
|
||||||
|
typedef jobject (*JX_GetComponentManagerFunc) (JNIEnv*, jobject);
|
||||||
|
typedef jobject (*JX_GetComponentRegistrarFunc) (JNIEnv*, jobject);
|
||||||
|
typedef jobject (*JX_GetServiceManagerFunc) (JNIEnv*, jobject);
|
||||||
|
typedef jobject (*JX_CallXPCOMMethodFunc) (JNIEnv*, jclass, jobject, jstring,
|
||||||
|
jobjectArray);
|
||||||
|
typedef void (*JX_FinalizeProxyFunc) (JNIEnv*, jclass, jobject);
|
||||||
|
|
||||||
|
JX_InitEmbeddingFunc InitEmbedding;
|
||||||
|
JX_TermEmbeddingFunc TermEmbedding;
|
||||||
|
JX_InitXPCOMFunc InitXPCOM;
|
||||||
|
JX_ShutdownXPCOMFunc ShutdownXPCOM;
|
||||||
|
JX_NewLocalFileFunc NewLocalFile;
|
||||||
|
JX_GetComponentManagerFunc GetComponentManager;
|
||||||
|
JX_GetComponentRegistrarFunc GetComponentRegistrar;
|
||||||
|
JX_GetServiceManagerFunc GetServiceManager;
|
||||||
|
JX_CallXPCOMMethodFunc CallXPCOMMethod;
|
||||||
|
JX_FinalizeProxyFunc FinalizeProxy;
|
||||||
|
|
||||||
|
static nsDynamicFunctionLoad funcs[] = {
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_GREImpl_initEmbedding",
|
||||||
|
(NSFuncPtr*) &InitEmbedding },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_GREImpl_termEmbedding",
|
||||||
|
(NSFuncPtr*) &TermEmbedding },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMImpl_initXPCOM",
|
||||||
|
(NSFuncPtr*) &InitXPCOM },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMImpl_shutdownXPCOM",
|
||||||
|
(NSFuncPtr*) &ShutdownXPCOM },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMImpl_newLocalFile",
|
||||||
|
(NSFuncPtr*) &NewLocalFile },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMImpl_getComponentManager",
|
||||||
|
(NSFuncPtr*) &GetComponentManager },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMImpl_getComponentRegistrar",
|
||||||
|
(NSFuncPtr*) &GetComponentRegistrar },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMImpl_getServiceManager",
|
||||||
|
(NSFuncPtr*) &GetServiceManager },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_callXPCOMMethod",
|
||||||
|
(NSFuncPtr*) &CallXPCOMMethod },
|
||||||
|
{ "Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_finalizeProxy",
|
||||||
|
(NSFuncPtr*) &FinalizeProxy },
|
||||||
|
{ nsnull, nsnull }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get path string from java.io.File object.
|
||||||
|
jstring
|
||||||
|
GetJavaFilePath(JNIEnv* env, jobject aFile)
|
||||||
|
{
|
||||||
|
jclass clazz = env->FindClass("java/io/File");
|
||||||
|
if (clazz) {
|
||||||
|
jmethodID pathMID = env->GetMethodID(clazz, "getCanonicalPath",
|
||||||
|
"()Ljava/lang/String;");
|
||||||
|
if (pathMID) {
|
||||||
|
return (jstring) env->CallObjectMethod(aFile, pathMID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Calls XPCOMGlueStartup using the given java.io.File object, and loads
|
||||||
|
// the Javaconnect methods from the XUL shared library.
|
||||||
|
nsresult
|
||||||
|
Initialize(JNIEnv* env, jobject aXPCOMPath)
|
||||||
|
{
|
||||||
|
jstring pathString = GetJavaFilePath(env, aXPCOMPath);
|
||||||
|
if (!pathString)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
const char* path = env->GetStringUTFChars(pathString, nsnull);
|
||||||
|
if (!path)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
int len = strlen(path);
|
||||||
|
char* xpcomPath = (char*) malloc(len + sizeof(XPCOM_DLL) +
|
||||||
|
sizeof(XPCOM_FILE_PATH_SEPARATOR) + 1);
|
||||||
|
if (!xpcomPath)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
sprintf(xpcomPath, "%s" XPCOM_FILE_PATH_SEPARATOR XPCOM_DLL, path);
|
||||||
|
|
||||||
|
nsresult rv = XPCOMGlueStartup(xpcomPath);
|
||||||
|
free(xpcomPath);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
rv = XPCOMGlueLoadXULFunctions(funcs);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ThrowException(JNIEnv* env, const nsresult aErrorCode, const char* aMessage)
|
||||||
|
{
|
||||||
|
// Only throw this exception if one hasn't already been thrown, so we don't
|
||||||
|
// mask a previous exception/error.
|
||||||
|
if (env->ExceptionCheck())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If the error code we get is for an Out Of Memory error, try to throw an
|
||||||
|
// OutOfMemoryError. The JVM may have enough memory to create this error.
|
||||||
|
if (aErrorCode == NS_ERROR_OUT_OF_MEMORY) {
|
||||||
|
jclass clazz = env->FindClass("java/lang/OutOfMemoryError");
|
||||||
|
if (clazz) {
|
||||||
|
env->ThrowNew(clazz, aMessage);
|
||||||
|
}
|
||||||
|
env->DeleteLocalRef(clazz);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the error was not handled above, then create an XPCOMException with the
|
||||||
|
// given error code.
|
||||||
|
jthrowable throwObj = nsnull;
|
||||||
|
jclass exceptionClass = env->FindClass("org/mozilla/xpcom/XPCOMException");
|
||||||
|
if (exceptionClass) {
|
||||||
|
jmethodID mid = env->GetMethodID(exceptionClass, "<init>",
|
||||||
|
"(JLjava/lang/String;)V");
|
||||||
|
if (mid) {
|
||||||
|
throwObj = (jthrowable) env->NewObject(exceptionClass, mid,
|
||||||
|
(PRInt64) aErrorCode,
|
||||||
|
env->NewStringUTF(aMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NS_ASSERTION(throwObj, "Failed to create XPCOMException object");
|
||||||
|
|
||||||
|
// throw exception
|
||||||
|
if (throwObj) {
|
||||||
|
env->Throw(throwObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
GRE_NATIVE(initEmbeddingNative) (JNIEnv* env, jobject aObject,
|
||||||
|
jobject aLibXULDirectory,
|
||||||
|
jobject aAppDirectory, jobject aAppDirProvider)
|
||||||
|
{
|
||||||
|
nsresult rv = Initialize(env, aLibXULDirectory);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
ThrowException(env, rv, "Initialization failed in initEmbeddingNative");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitEmbedding(env, aObject, aLibXULDirectory, aAppDirectory, aAppDirProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
GRE_NATIVE(termEmbedding) (JNIEnv *env, jobject aObject)
|
||||||
|
{
|
||||||
|
TermEmbedding(env, aObject);
|
||||||
|
XPCOMGlueShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
|
XPCOM_NATIVE(initXPCOMNative) (JNIEnv* env, jobject aObject,
|
||||||
|
jobject aMozBinDirectory,
|
||||||
|
jobject aAppFileLocProvider)
|
||||||
|
{
|
||||||
|
nsresult rv = Initialize(env, aMozBinDirectory);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
ThrowException(env, rv, "Initialization failed in initXPCOMNative");
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
return InitXPCOM(env, aObject, aMozBinDirectory, aAppFileLocProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
XPCOM_NATIVE(shutdownXPCOM) (JNIEnv *env, jobject aObject, jobject aServMgr)
|
||||||
|
{
|
||||||
|
ShutdownXPCOM(env, aObject, aServMgr);
|
||||||
|
XPCOMGlueShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
|
XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jobject aObject, jstring aPath,
|
||||||
|
jboolean aFollowLinks)
|
||||||
|
{
|
||||||
|
return NewLocalFile(env, aObject, aPath, aFollowLinks);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
|
XPCOM_NATIVE(getComponentManager) (JNIEnv *env, jobject aObject)
|
||||||
|
{
|
||||||
|
return GetComponentManager(env, aObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
|
XPCOM_NATIVE(getComponentRegistrar) (JNIEnv *env, jobject aObject)
|
||||||
|
{
|
||||||
|
return GetComponentRegistrar(env, aObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
|
XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jobject aObject)
|
||||||
|
{
|
||||||
|
return GetServiceManager(env, aObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
|
JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
||||||
|
jstring aMethodName, jobjectArray aParams)
|
||||||
|
{
|
||||||
|
return CallXPCOMMethod(env, that, aJavaProxy, aMethodName, aParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
JAVAPROXY_NATIVE(finalizeProxyNative) (JNIEnv *env, jclass that,
|
||||||
|
jobject aJavaProxy)
|
||||||
|
{
|
||||||
|
FinalizeProxy(env, that, aJavaProxy);
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsJavaInterfaces.h"
|
||||||
#include "nsJavaWrapper.h"
|
#include "nsJavaWrapper.h"
|
||||||
#include "nsJavaXPCOMBindingUtils.h"
|
#include "nsJavaXPCOMBindingUtils.h"
|
||||||
#include "nsJavaXPTCStub.h"
|
#include "nsJavaXPTCStub.h"
|
||||||
|
@ -50,9 +51,6 @@
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "nsILocalFile.h"
|
#include "nsILocalFile.h"
|
||||||
|
|
||||||
#define GRE_NATIVE(func) Java_org_mozilla_xpcom_internal_GREImpl_##func
|
|
||||||
#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_internal_XPCOMImpl_##func
|
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
InitEmbedding_Impl(JNIEnv* env, jobject aLibXULDirectory,
|
InitEmbedding_Impl(JNIEnv* env, jobject aLibXULDirectory,
|
||||||
|
@ -89,9 +87,9 @@ InitEmbedding_Impl(JNIEnv* env, jobject aLibXULDirectory,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT void JNICALL
|
extern "C" NS_EXPORT void
|
||||||
GRE_NATIVE(initEmbeddingNative) (JNIEnv* env, jobject, jobject aLibXULDirectory,
|
GRE_NATIVE(initEmbedding) (JNIEnv* env, jobject, jobject aLibXULDirectory,
|
||||||
jobject aAppDirectory, jobject aAppDirProvider)
|
jobject aAppDirectory, jobject aAppDirProvider)
|
||||||
{
|
{
|
||||||
nsresult rv = InitEmbedding_Impl(env, aLibXULDirectory, aAppDirectory,
|
nsresult rv = InitEmbedding_Impl(env, aLibXULDirectory, aAppDirectory,
|
||||||
aAppDirProvider);
|
aAppDirProvider);
|
||||||
|
@ -102,7 +100,7 @@ GRE_NATIVE(initEmbeddingNative) (JNIEnv* env, jobject, jobject aLibXULDirectory,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT void JNICALL
|
extern "C" NS_EXPORT void
|
||||||
GRE_NATIVE(termEmbedding) (JNIEnv *env, jobject)
|
GRE_NATIVE(termEmbedding) (JNIEnv *env, jobject)
|
||||||
{
|
{
|
||||||
// Free globals before calling XRE_TermEmbedding(), since we need some
|
// Free globals before calling XRE_TermEmbedding(), since we need some
|
||||||
|
@ -158,7 +156,7 @@ InitXPCOM_Impl(JNIEnv* env, jobject aMozBinDirectory,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT jobject JNICALL
|
extern "C" NS_EXPORT jobject
|
||||||
XPCOM_NATIVE(initXPCOM) (JNIEnv* env, jobject, jobject aMozBinDirectory,
|
XPCOM_NATIVE(initXPCOM) (JNIEnv* env, jobject, jobject aMozBinDirectory,
|
||||||
jobject aAppFileLocProvider)
|
jobject aAppFileLocProvider)
|
||||||
{
|
{
|
||||||
|
@ -173,7 +171,7 @@ XPCOM_NATIVE(initXPCOM) (JNIEnv* env, jobject, jobject aMozBinDirectory,
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT void JNICALL
|
extern "C" NS_EXPORT void
|
||||||
XPCOM_NATIVE(shutdownXPCOM) (JNIEnv *env, jobject, jobject aServMgr)
|
XPCOM_NATIVE(shutdownXPCOM) (JNIEnv *env, jobject, jobject aServMgr)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
@ -202,7 +200,7 @@ XPCOM_NATIVE(shutdownXPCOM) (JNIEnv *env, jobject, jobject aServMgr)
|
||||||
ThrowException(env, rv, "NS_ShutdownXPCOM failed");
|
ThrowException(env, rv, "NS_ShutdownXPCOM failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT jobject JNICALL
|
extern "C" NS_EXPORT jobject
|
||||||
XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jobject, jstring aPath,
|
XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jobject, jstring aPath,
|
||||||
jboolean aFollowLinks)
|
jboolean aFollowLinks)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +231,7 @@ XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jobject, jstring aPath,
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT jobject JNICALL
|
extern "C" NS_EXPORT jobject
|
||||||
XPCOM_NATIVE(getComponentManager) (JNIEnv *env, jobject)
|
XPCOM_NATIVE(getComponentManager) (JNIEnv *env, jobject)
|
||||||
{
|
{
|
||||||
// Call XPCOM method
|
// Call XPCOM method
|
||||||
|
@ -252,7 +250,7 @@ XPCOM_NATIVE(getComponentManager) (JNIEnv *env, jobject)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT jobject JNICALL
|
extern "C" NS_EXPORT jobject
|
||||||
XPCOM_NATIVE(getComponentRegistrar) (JNIEnv *env, jobject)
|
XPCOM_NATIVE(getComponentRegistrar) (JNIEnv *env, jobject)
|
||||||
{
|
{
|
||||||
// Call XPCOM method
|
// Call XPCOM method
|
||||||
|
@ -271,7 +269,7 @@ XPCOM_NATIVE(getComponentRegistrar) (JNIEnv *env, jobject)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JX_EXPORT jobject JNICALL
|
extern "C" NS_EXPORT jobject
|
||||||
XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jobject)
|
XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jobject)
|
||||||
{
|
{
|
||||||
// Call XPCOM method
|
// Call XPCOM method
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsJavaInterfaces.h"
|
||||||
#include "nsJavaWrapper.h"
|
#include "nsJavaWrapper.h"
|
||||||
#include "nsJavaXPTCStub.h"
|
#include "nsJavaXPTCStub.h"
|
||||||
#include "nsJavaXPCOMBindingUtils.h"
|
#include "nsJavaXPCOMBindingUtils.h"
|
||||||
|
@ -46,9 +47,6 @@
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
|
||||||
#define JAVAPROXY_NATIVE(func) \
|
|
||||||
Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_##func
|
|
||||||
|
|
||||||
static nsID nullID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
static nsID nullID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1383,7 +1381,7 @@ QueryMethodInfo(nsIInterfaceInfo* aIInfo, const char* aMethodName,
|
||||||
/**
|
/**
|
||||||
* org.mozilla.xpcom.XPCOMJavaProxy.internal.callXPCOMMethod
|
* org.mozilla.xpcom.XPCOMJavaProxy.internal.callXPCOMMethod
|
||||||
*/
|
*/
|
||||||
extern "C" JX_EXPORT jobject JNICALL
|
extern "C" NS_EXPORT jobject
|
||||||
JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
||||||
jstring aMethodName, jobjectArray aParams)
|
jstring aMethodName, jobjectArray aParams)
|
||||||
{
|
{
|
||||||
|
@ -1711,11 +1709,10 @@ GetXPCOMInstFromProxy(JNIEnv* env, jobject aJavaObject, void** aResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* org.mozilla.xpcom.internal.XPCOMJavaProxy.finalizeProxyNative
|
* org.mozilla.xpcom.internal.XPCOMJavaProxy.finalizeProxy
|
||||||
*/
|
*/
|
||||||
extern "C" JX_EXPORT void JNICALL
|
extern "C" NS_EXPORT void
|
||||||
JAVAPROXY_NATIVE(finalizeProxyNative) (JNIEnv *env, jclass that,
|
JAVAPROXY_NATIVE(finalizeProxy) (JNIEnv *env, jclass that, jobject aJavaProxy)
|
||||||
jobject aJavaProxy)
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_JAVAXPCOM
|
#ifdef DEBUG_JAVAXPCOM
|
||||||
PRUint32 xpcom_addr = 0;
|
PRUint32 xpcom_addr = 0;
|
||||||
|
|
|
@ -96,24 +96,6 @@ PRBool gJavaXPCOMInitialized = PR_FALSE;
|
||||||
PRLock* gJavaXPCOMLock = nsnull;
|
PRLock* gJavaXPCOMLock = nsnull;
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
|
||||||
* JNI Load & Unload
|
|
||||||
******************************/
|
|
||||||
extern "C" JX_EXPORT jint JNICALL
|
|
||||||
JNI_OnLoad(JavaVM* vm, void* reserved)
|
|
||||||
{
|
|
||||||
// Save pointer to JavaVM, which is valid across threads.
|
|
||||||
gCachedJVM = vm;
|
|
||||||
|
|
||||||
// Let the JVM know that we are using JDK 1.2 JNI features.
|
|
||||||
return JNI_VERSION_1_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" JX_EXPORT void JNICALL
|
|
||||||
JNI_OnUnload(JavaVM* vm, void* reserved)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
* InitializeJavaGlobals
|
* InitializeJavaGlobals
|
||||||
******************************/
|
******************************/
|
||||||
|
@ -123,6 +105,13 @@ InitializeJavaGlobals(JNIEnv *env)
|
||||||
if (gJavaXPCOMInitialized)
|
if (gJavaXPCOMInitialized)
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
|
// Save pointer to JavaVM, which is valid across threads.
|
||||||
|
jint rc = env->GetJavaVM(&gCachedJVM);
|
||||||
|
if (rc != 0) {
|
||||||
|
NS_WARNING("Failed to get JavaVM");
|
||||||
|
goto init_error;
|
||||||
|
}
|
||||||
|
|
||||||
jclass clazz;
|
jclass clazz;
|
||||||
if (!(clazz = env->FindClass("java/lang/Object")) ||
|
if (!(clazz = env->FindClass("java/lang/Object")) ||
|
||||||
!(hashCodeMID = env->GetMethodID(clazz, "hashCode","()I")))
|
!(hashCodeMID = env->GetMethodID(clazz, "hashCode","()I")))
|
||||||
|
@ -912,23 +901,12 @@ ThrowException(JNIEnv* env, const nsresult aErrorCode, const char* aMessage)
|
||||||
|
|
||||||
// Create parameters and method signature. Max of 2 params. The error code
|
// Create parameters and method signature. Max of 2 params. The error code
|
||||||
// comes before the message string.
|
// comes before the message string.
|
||||||
PRUint32 index = 0;
|
PRInt64 errorCode = aErrorCode ? aErrorCode : NS_ERROR_FAILURE;
|
||||||
jvalue* args = new jvalue[2];
|
nsCAutoString methodSig("(J");
|
||||||
if (!args) {
|
jstring message = nsnull;
|
||||||
ThrowException(env, NS_ERROR_OUT_OF_MEMORY,
|
|
||||||
"Out of memory while throwing another exception");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCAutoString methodSig("(");
|
|
||||||
if (aErrorCode) {
|
|
||||||
args[index++].j = aErrorCode;
|
|
||||||
methodSig.Append('J');
|
|
||||||
}
|
|
||||||
if (aMessage) {
|
if (aMessage) {
|
||||||
args[index].l = env->NewStringUTF(aMessage);
|
message = env->NewStringUTF(aMessage);
|
||||||
if (args[index].l == nsnull) {
|
if (!message) {
|
||||||
delete[] args;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
methodSig.AppendLiteral("Ljava/lang/String;");
|
methodSig.AppendLiteral("Ljava/lang/String;");
|
||||||
|
@ -941,8 +919,9 @@ ThrowException(JNIEnv* env, const nsresult aErrorCode, const char* aMessage)
|
||||||
// reset it temporarily in order to throw the appropriate exception.
|
// reset it temporarily in order to throw the appropriate exception.
|
||||||
if (xpcomExceptionClass == nsnull) {
|
if (xpcomExceptionClass == nsnull) {
|
||||||
xpcomExceptionClass = env->FindClass("org/mozilla/xpcom/XPCOMException");
|
xpcomExceptionClass = env->FindClass("org/mozilla/xpcom/XPCOMException");
|
||||||
if (!xpcomExceptionClass)
|
if (!xpcomExceptionClass) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create exception object
|
// create exception object
|
||||||
|
@ -950,7 +929,8 @@ ThrowException(JNIEnv* env, const nsresult aErrorCode, const char* aMessage)
|
||||||
jmethodID mid = env->GetMethodID(xpcomExceptionClass, "<init>",
|
jmethodID mid = env->GetMethodID(xpcomExceptionClass, "<init>",
|
||||||
methodSig.get());
|
methodSig.get());
|
||||||
if (mid) {
|
if (mid) {
|
||||||
throwObj = (jthrowable) env->NewObjectA(xpcomExceptionClass, mid, args);
|
throwObj = (jthrowable) env->NewObject(xpcomExceptionClass, mid, errorCode,
|
||||||
|
message);
|
||||||
}
|
}
|
||||||
NS_ASSERTION(throwObj, "Failed to create XPCOMException object");
|
NS_ASSERTION(throwObj, "Failed to create XPCOMException object");
|
||||||
|
|
||||||
|
@ -958,9 +938,6 @@ ThrowException(JNIEnv* env, const nsresult aErrorCode, const char* aMessage)
|
||||||
if (throwObj) {
|
if (throwObj) {
|
||||||
env->Throw(throwObj);
|
env->Throw(throwObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup
|
|
||||||
delete[] args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAString*
|
nsAString*
|
||||||
|
|
|
@ -45,35 +45,14 @@ public class GREImpl implements IGRE {
|
||||||
|
|
||||||
public void initEmbedding(File aLibXULDirectory, File aAppDirectory,
|
public void initEmbedding(File aLibXULDirectory, File aAppDirectory,
|
||||||
IAppFileLocProvider aAppDirProvider) {
|
IAppFileLocProvider aAppDirProvider) {
|
||||||
loadDependentLibraries(aLibXULDirectory);
|
// load JNI library
|
||||||
initEmbeddingNative(aLibXULDirectory, aAppDirectory, aAppDirProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadDependentLibraries(File binPath) {
|
|
||||||
String path = "";
|
String path = "";
|
||||||
if (binPath != null) {
|
if (aLibXULDirectory != null) {
|
||||||
path = binPath + File.separator;
|
path = aLibXULDirectory + File.separator;
|
||||||
}
|
}
|
||||||
|
System.load(path + System.mapLibraryName("javaxpcomglue"));
|
||||||
|
|
||||||
System.load(path + System.mapLibraryName("nspr4"));
|
initEmbeddingNative(aLibXULDirectory, aAppDirectory, aAppDirProvider);
|
||||||
System.load(path + System.mapLibraryName("plds4"));
|
|
||||||
System.load(path + System.mapLibraryName("plc4"));
|
|
||||||
try {
|
|
||||||
/* try loading Win32 DLL */
|
|
||||||
System.load(path + System.mapLibraryName("js3250"));
|
|
||||||
} catch (UnsatisfiedLinkError e) { }
|
|
||||||
try {
|
|
||||||
/* try loading Linux DLL */
|
|
||||||
System.load(path + System.mapLibraryName("mozjs"));
|
|
||||||
} catch (UnsatisfiedLinkError e) { }
|
|
||||||
System.load(path + System.mapLibraryName("softokn3"));
|
|
||||||
System.load(path + System.mapLibraryName("nss3"));
|
|
||||||
System.load(path + System.mapLibraryName("smime3"));
|
|
||||||
System.load(path + System.mapLibraryName("ssl3"));
|
|
||||||
System.load(path + System.mapLibraryName("xul"));
|
|
||||||
System.load(path + System.mapLibraryName("xpcom"));
|
|
||||||
|
|
||||||
System.load(path + System.mapLibraryName("javaxpcom"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public native void initEmbeddingNative(File aLibXULDirectory,
|
public native void initEmbeddingNative(File aLibXULDirectory,
|
||||||
|
|
|
@ -44,7 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
MODULE = javaxpcom
|
MODULE = javaxpcom
|
||||||
LIBRARY_NAME = javaxpcom
|
LIBRARY_NAME = javaxpcom
|
||||||
MOZILLA_INTERNAL_API = 1
|
LIBXUL_LIBRARY = 1
|
||||||
|
|
||||||
# On Mac OS X, JNI libraries must end with a '.jnilib' extension
|
# On Mac OS X, JNI libraries must end with a '.jnilib' extension
|
||||||
ifeq ($(OS_ARCH),Darwin)
|
ifeq ($(OS_ARCH),Darwin)
|
||||||
|
@ -53,7 +53,6 @@ endif
|
||||||
|
|
||||||
REQUIRES = xpcom \
|
REQUIRES = xpcom \
|
||||||
string \
|
string \
|
||||||
embed_base \
|
|
||||||
xulapp \
|
xulapp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
@ -84,6 +83,9 @@ else
|
||||||
LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/linux
|
LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/linux
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# necessary until we do 'cvs move' to put files in correct directories
|
||||||
|
LOCAL_INCLUDES += -I$(srcdir)
|
||||||
|
|
||||||
EXTRA_DSO_LDOPTS = \
|
EXTRA_DSO_LDOPTS = \
|
||||||
$(LIBS_DIR) \
|
$(LIBS_DIR) \
|
||||||
$(EXTRA_DSO_LIBS) \
|
$(EXTRA_DSO_LIBS) \
|
||||||
|
@ -132,6 +134,8 @@ $(JARFILE): org/mozilla/xpcom/internal/.class_done Makefile
|
||||||
$(JARFILE_SRC): $(JARFILE)
|
$(JARFILE_SRC): $(JARFILE)
|
||||||
$(JAR) cf $@ -C _javagen org
|
$(JAR) cf $@ -C _javagen org
|
||||||
|
|
||||||
libs:: $(JARFILE)
|
#libs:: $(JARFILE)
|
||||||
|
# $(INSTALL) $(IFLAGS1) $^ $(DIST)/bin
|
||||||
|
jarfile:: $(JARFILE)
|
||||||
$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin
|
$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,30 @@ import org.mozilla.xpcom.*;
|
||||||
|
|
||||||
public class XPCOMImpl implements IXPCOM {
|
public class XPCOMImpl implements IXPCOM {
|
||||||
|
|
||||||
|
public nsIServiceManager initXPCOM(File aMozBinDirectory,
|
||||||
|
IAppFileLocProvider aAppFileLocProvider) {
|
||||||
|
// load JNI library
|
||||||
|
String path = "";
|
||||||
|
if (aMozBinDirectory != null) {
|
||||||
|
path = aMozBinDirectory + File.separator;
|
||||||
|
}
|
||||||
|
System.load(path + System.mapLibraryName("javaxpcomglue"));
|
||||||
|
|
||||||
|
return initXPCOMNative(aMozBinDirectory, aAppFileLocProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public native nsIServiceManager initXPCOMNative(File aMozBinDirectory,
|
||||||
|
IAppFileLocProvider aAppFileLocProvider);
|
||||||
|
|
||||||
|
public native void shutdownXPCOM(nsIServiceManager aServMgr);
|
||||||
|
|
||||||
public native nsIComponentManager getComponentManager();
|
public native nsIComponentManager getComponentManager();
|
||||||
|
|
||||||
public native nsIComponentRegistrar getComponentRegistrar();
|
public native nsIComponentRegistrar getComponentRegistrar();
|
||||||
|
|
||||||
public native nsIServiceManager getServiceManager();
|
public native nsIServiceManager getServiceManager();
|
||||||
|
|
||||||
public native nsIServiceManager initXPCOM(File aMozBinDirectory,
|
|
||||||
IAppFileLocProvider aAppFileLocProvider);
|
|
||||||
|
|
||||||
public native nsILocalFile newLocalFile(String aPath, boolean aFollowLinks);
|
public native nsILocalFile newLocalFile(String aPath, boolean aFollowLinks);
|
||||||
|
|
||||||
public native void shutdownXPCOM(nsIServiceManager aServMgr);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Java XPCOM Bindings.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* IBM Corporation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* IBM Corporation. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Javier Pedemonte (jhpedemonte@gmail.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "nsJavaInterfaces.h"
|
||||||
|
|
||||||
|
|
||||||
|
void XXXNeverCalled_javaxpcom()
|
||||||
|
{
|
||||||
|
GRE_NATIVE(initEmbedding) (nsnull, nsnull, nsnull, nsnull, nsnull);
|
||||||
|
|
||||||
|
GRE_NATIVE(termEmbedding) (nsnull, nsnull);
|
||||||
|
|
||||||
|
XPCOM_NATIVE(initXPCOM) (nsnull, nsnull, nsnull, nsnull);
|
||||||
|
|
||||||
|
XPCOM_NATIVE(shutdownXPCOM) (nsnull, nsnull, nsnull);
|
||||||
|
|
||||||
|
XPCOM_NATIVE(newLocalFile) (nsnull, nsnull, nsnull, nsnull);
|
||||||
|
|
||||||
|
XPCOM_NATIVE(getComponentManager) (nsnull, nsnull);
|
||||||
|
|
||||||
|
XPCOM_NATIVE(getComponentRegistrar) (nsnull, nsnull);
|
||||||
|
|
||||||
|
XPCOM_NATIVE(getServiceManager) (nsnull, nsnull);
|
||||||
|
|
||||||
|
JAVAPROXY_NATIVE(callXPCOMMethod) (nsnull, nsnull, nsnull, nsnull, nsnull);
|
||||||
|
|
||||||
|
JAVAPROXY_NATIVE(finalizeProxy) (nsnull, nsnull, nsnull);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is Java XPCOM Bindings.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* IBM Corporation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||||
|
* IBM Corporation. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Javier Pedemonte (jhpedemonte@gmail.com)
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#ifndef _nsJavaInterfaces_h_
|
||||||
|
#define _nsJavaInterfaces_h_
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
#include "nscore.h"
|
||||||
|
|
||||||
|
#define GRE_NATIVE(func) Java_org_mozilla_xpcom_internal_GREImpl_##func
|
||||||
|
#define XPCOM_NATIVE(func) Java_org_mozilla_xpcom_internal_XPCOMImpl_##func
|
||||||
|
#define JAVAPROXY_NATIVE(func) \
|
||||||
|
Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_##func
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT void
|
||||||
|
GRE_NATIVE(initEmbedding) (JNIEnv* env, jobject, jobject aLibXULDirectory,
|
||||||
|
jobject aAppDirectory, jobject aAppDirProvider);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT void
|
||||||
|
GRE_NATIVE(termEmbedding) (JNIEnv *env, jobject);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT jobject
|
||||||
|
XPCOM_NATIVE(initXPCOM) (JNIEnv* env, jobject, jobject aMozBinDirectory,
|
||||||
|
jobject aAppFileLocProvider);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT void
|
||||||
|
XPCOM_NATIVE(shutdownXPCOM) (JNIEnv *env, jobject, jobject aServMgr);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT jobject
|
||||||
|
XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jobject, jstring aPath,
|
||||||
|
jboolean aFollowLinks);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT jobject
|
||||||
|
XPCOM_NATIVE(getComponentManager) (JNIEnv *env, jobject);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT jobject
|
||||||
|
XPCOM_NATIVE(getComponentRegistrar) (JNIEnv *env, jobject);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT jobject
|
||||||
|
XPCOM_NATIVE(getServiceManager) (JNIEnv *env, jobject);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT jobject
|
||||||
|
JAVAPROXY_NATIVE(callXPCOMMethod) (JNIEnv *env, jclass that, jobject aJavaProxy,
|
||||||
|
jstring aMethodName, jobjectArray aParams);
|
||||||
|
|
||||||
|
extern "C" NS_EXPORT void
|
||||||
|
JAVAPROXY_NATIVE(finalizeProxy) (JNIEnv *env, jclass that, jobject aJavaProxy);
|
||||||
|
|
||||||
|
#endif // _nsJavaInterfaces_h_
|
|
@ -228,3 +228,18 @@ ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||||
EXTRA_DSO_LIBS += macmorefiles_s
|
EXTRA_DSO_LIBS += macmorefiles_s
|
||||||
EXTRA_DEPS += $(DIST)/lib/$(LIB_PREFIX)macmorefiles_s.$(LIB_SUFFIX)
|
EXTRA_DEPS += $(DIST)/lib/$(LIB_PREFIX)macmorefiles_s.$(LIB_SUFFIX)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef MOZ_JAVAXPCOM
|
||||||
|
LOCAL_INCLUDES += \
|
||||||
|
-I$(topsrcdir)/extensions/java/xpcom/src \
|
||||||
|
-I$(JAVA_INCLUDE_PATH) \
|
||||||
|
$(NULL)
|
||||||
|
ifeq ($(OS_ARCH),WINNT)
|
||||||
|
CPPSRCS += dlldeps-javaxpcom.cpp
|
||||||
|
LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/win32
|
||||||
|
else
|
||||||
|
LOCAL_INCLUDES += -I$(JAVA_INCLUDE_PATH)/linux
|
||||||
|
endif
|
||||||
|
STATIC_LIBS += javaxpcom
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
|
@ -84,3 +84,11 @@ dlldeps.cpp: $(topsrcdir)/xpcom/build/dlldeps.cpp
|
||||||
|
|
||||||
dlldeps-obs.cpp: $(topsrcdir)/xpcom/obsolete/dlldeps-obs.cpp
|
dlldeps-obs.cpp: $(topsrcdir)/xpcom/obsolete/dlldeps-obs.cpp
|
||||||
$(INSTALL) $^ .
|
$(INSTALL) $^ .
|
||||||
|
|
||||||
|
ifdef MOZ_JAVAXPCOM
|
||||||
|
export:: dlldeps-javaxpcom.cpp
|
||||||
|
|
||||||
|
dlldeps-javaxpcom.cpp: $(topsrcdir)/extensions/java/xpcom/src/dlldeps-javaxpcom.cpp
|
||||||
|
$(INSTALL) $^ .
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче