This fix was contributed by
* Jason Mawdsley <jason@macadamian.com> * Louis-Philippe Gagnon <louisphilippe@macadamian.com> It enables webclient to be built and run under JDK1.1.x. Note that JavaDOM does not work under jdk1.1.x. The fix consists of two elements: On the Java side, replace all JDK1.2 specific calls with JDK1.1.x equivalents. On the native side use pre-processer macro for JNI_VERSION, like this: #ifdef JNI_VERSION_1_2 #ifndef JNI_VERSION #define JNI_VERSION JNI_VERSION_1_2 #endif #else #ifndef JNI_VERSION_1_1 #define JNI_VERSION_1_1 0x00010001 #endif #ifndef JNI_VERSION #define JNI_VERSION JNI_VERSION_1_1 #endif #endif // END: JNI_VERSION_1_2 This fix has been tested on win32, solaris, and linux. The following files are in this fix: M webclient/classes_spec/org/mozilla/webclient/test/DOMTreeModel.java M webclient/classes_spec/org/mozilla/webclient/test/DOMViewerFrame.java M webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java M webclient/classes_spec/org/mozilla/webclient/wrapper_native/BookmarksImpl.java M webclient/classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java M webclient/src_moz/CBrowserContainer.cpp M webclient/src_moz/nsActions.cpp M webclient/src_share/jni_util.cpp M webclient/src_share/jni_util.h M webclient/src_share/jni_util_export.cpp git-svn-id: svn://10.0.0.236/trunk@79490 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
* Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Igor Kushnirskiy <idk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
@@ -35,7 +38,8 @@ class DOMTreeModel implements TreeModel, DOMTreeNotifier {
|
||||
rootNode = node;
|
||||
}
|
||||
public void addTreeModelListener(TreeModelListener l) {
|
||||
treeModelListeners.add(l);
|
||||
// use addElement instead of add for jdk1.1.x compatibility.
|
||||
treeModelListeners.addElement(l);
|
||||
}
|
||||
public void removeTreeModelListener(TreeModelListener l) {
|
||||
treeModelListeners.removeElement(l);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
@@ -55,7 +57,7 @@ import java.util.Stack;
|
||||
* A dom viewer Frame
|
||||
|
||||
*
|
||||
* @version $Id: DOMViewerFrame.java,v 1.4 2000-07-15 18:56:30 edburns%acm.org Exp $
|
||||
* @version $Id: DOMViewerFrame.java,v 1.5 2000-09-19 00:18:13 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
|
||||
@@ -188,7 +190,8 @@ protected void selectNodeInTree(Node node)
|
||||
}
|
||||
|
||||
if (null != pathStack) {
|
||||
pathStack.clear();
|
||||
// use removeAllElements instead of clear for jdk1.1.x compatibility.
|
||||
pathStack.removeAllElements();
|
||||
}
|
||||
populatePathStackFromNode(node);
|
||||
if (null == pathStack || pathStack.isEmpty()) {
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.w3c.dom.Document;
|
||||
* This is a test application for using the BrowserControl.
|
||||
|
||||
*
|
||||
* @version $Id: EMWindow.java,v 1.19 2000-09-15 00:15:01 ashuk%eng.sun.com Exp $
|
||||
* @version $Id: EMWindow.java,v 1.20 2000-09-19 00:18:13 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
|
||||
@@ -220,7 +220,6 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
|
||||
}
|
||||
});
|
||||
|
||||
// pack();
|
||||
show();
|
||||
toFront();
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
@@ -177,7 +179,8 @@ public BookmarkEntry newBookmarkEntry(String url)
|
||||
System.out.println("debug: edburns: BookmarksImpl.newBookmarkEntry: url:" + url);
|
||||
if (-1 != (newNode = nativeNewRDFNode(url, false))) {
|
||||
result = new BookmarkEntryImpl(newNode, null);
|
||||
result.getProperties().setProperty(BookmarkEntry.URL, url);
|
||||
// use put instead of setProperty for jdk1.1.x compatibility.
|
||||
result.getProperties().put(BookmarkEntry.URL, url);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -193,7 +196,7 @@ public BookmarkEntry newBookmarkFolder(String name)
|
||||
System.out.println("debug: edburns: BookmarksImpl.newBookmarkFolder: name:" + name);
|
||||
if (-1 != (newNode = nativeNewRDFNode(name, true))) {
|
||||
result = new BookmarkEntryImpl(newNode, null);
|
||||
result.getProperties().setProperty(BookmarkEntry.NAME, name);
|
||||
result.getProperties().put(BookmarkEntry.NAME, name);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -225,7 +228,7 @@ public static void main(String [] args)
|
||||
|
||||
Log.setApplicationName("BookmarksImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BookmarksImpl.java,v 1.5 2000-07-22 02:48:25 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: BookmarksImpl.java,v 1.6 2000-09-19 00:18:14 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
@@ -233,7 +235,9 @@ public void run()
|
||||
nativeAddListener(nativeWebShell,tempListener.listener,
|
||||
tempListener.listenerClassName);
|
||||
}
|
||||
listenersToAdd.clear();
|
||||
// use removeAllElements instead of clear for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToAdd.removeAllElements();
|
||||
}
|
||||
doRemoveListeners();
|
||||
|
||||
@@ -278,7 +282,9 @@ private void doRemoveListeners()
|
||||
|
||||
}
|
||||
}
|
||||
listenersToRemove.clear();
|
||||
// use removeAllElements instead of clear for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.removeAllElements();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +316,9 @@ void addListener(WCEventListenerWrapper newListener)
|
||||
if (null == listenersToAdd) {
|
||||
listenersToAdd = new Vector();
|
||||
}
|
||||
listenersToAdd.add(newListener);
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToAdd.addElement(newListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,10 +341,14 @@ void removeListener(WCEventListenerWrapper newListener)
|
||||
}
|
||||
if (null == newListener) {
|
||||
String all = "all";
|
||||
listenersToRemove.add(all);
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.addElement(all);
|
||||
}
|
||||
else {
|
||||
listenersToRemove.add(newListener);
|
||||
// use addElement instead of add for jdk1.1.x
|
||||
// compatibility.
|
||||
listenersToRemove.addElement(newListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*
|
||||
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -68,7 +70,7 @@ CBrowserContainer::~CBrowserContainer()
|
||||
mMouseTarget = nsnull;
|
||||
mDomEventTarget = nsnull;
|
||||
inverseDepth = -1;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
if (properties) {
|
||||
::util_DeleteGlobalRef(env, properties);
|
||||
}
|
||||
@@ -645,7 +647,7 @@ CBrowserContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL,
|
||||
// IMPORTANT: do not use initContext->env here since it comes
|
||||
// from another thread. Use JNU_GetEnv instead.
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
aURL->GetSpec(&urlStr);
|
||||
if (nsnull != urlStr) {
|
||||
@@ -782,7 +784,7 @@ CBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader,
|
||||
// IMPORTANT: do not use initContext->env here since it comes
|
||||
// from another thread. Use JNU_GetEnv instead.
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
jstring statusMessage = ::util_NewString(env, (const jchar *)
|
||||
aMsg.GetUnicode(), length);
|
||||
|
||||
@@ -877,7 +879,7 @@ CBrowserContainer::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY,
|
||||
ONE_VALUE, (jobject)
|
||||
&(mInitContext->shareContext));
|
||||
@@ -902,7 +904,7 @@ CBrowserContainer::MouseDblClick(nsIDOMEvent* aMouseEvent)
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY,
|
||||
TWO_VALUE, (jobject)
|
||||
&(mInitContext->shareContext));
|
||||
@@ -1001,7 +1003,7 @@ NS_IMETHODIMP CBrowserContainer::RemoveMouseListener()
|
||||
}
|
||||
|
||||
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2), mMouseTarget);
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION), mMouseTarget);
|
||||
mMouseTarget = nsnull;
|
||||
return rv;
|
||||
}
|
||||
@@ -1013,7 +1015,7 @@ NS_IMETHODIMP CBrowserContainer::RemoveDocumentLoadListener()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2), mDocTarget);
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION), mDocTarget);
|
||||
mDocTarget = nsnull;
|
||||
return rv;
|
||||
}
|
||||
@@ -1030,8 +1032,8 @@ NS_IMETHODIMP CBrowserContainer::RemoveAllListeners()
|
||||
mDomEventTarget = nsnull;
|
||||
}
|
||||
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2), mDocTarget);
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2), mMouseTarget);
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION), mDocTarget);
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION), mMouseTarget);
|
||||
|
||||
mMouseTarget = nsnull;
|
||||
mDocTarget = nsnull;
|
||||
@@ -1080,7 +1082,7 @@ jobject JNICALL CBrowserContainer::getPropertiesFromEvent(nsIDOMEvent *event)
|
||||
return properties;
|
||||
}
|
||||
inverseDepth = 0;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
if (properties) {
|
||||
util_ClearPropertiesObject(env, properties, (jobject)
|
||||
@@ -1122,7 +1124,7 @@ void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMous
|
||||
PRBool boolVal;
|
||||
char buf[20];
|
||||
jstring strVal;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
// PENDING(edburns): perhaps use a macro to speed this up?
|
||||
rv = mouseEvent->GetScreenX(&intVal);
|
||||
@@ -1223,7 +1225,7 @@ nsresult JNICALL CBrowserContainer::takeActionOnNode(nsCOMPtr<nsIDOMNode> curren
|
||||
CBrowserContainer *curThis = nsnull;
|
||||
const PRUint32 depthStrLen = 20;
|
||||
// char depthStr[depthStrLen];
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
PR_ASSERT(nsnull != myObject);
|
||||
curThis = (CBrowserContainer *) myObject;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
* Mark Lin <mark.lin@eng.sun.com>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -718,7 +720,7 @@ wsDeallocateInitContextEvent::handleEvent ()
|
||||
mInitContext->embeddedThread = nsnull;
|
||||
mInitContext->env = nsnull;
|
||||
if (nsnull != mInitContext->nativeEventThread) {
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2),
|
||||
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION),
|
||||
mInitContext->nativeEventThread);
|
||||
mInitContext->nativeEventThread = nsnull;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ann Sunhachawee
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
#include "jni_util.h"
|
||||
@@ -247,7 +249,7 @@ void util_SendEventToJava(JNIEnv *yourEnv, jobject nativeEventThread,
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
if (nsnull == env) {
|
||||
return;
|
||||
@@ -451,7 +453,7 @@ void util_SetIntValueForInstance(JNIEnv *env, jobject obj,
|
||||
}
|
||||
|
||||
env->SetIntField(obj, fieldID, newValue);
|
||||
#endif;
|
||||
#endif
|
||||
}
|
||||
|
||||
jobject util_CreatePropertiesObject(JNIEnv *env, jobject initContextObj)
|
||||
@@ -598,8 +600,13 @@ JNU_CallMethodByNameV(JNIEnv *env,
|
||||
|
||||
result.i = 0;
|
||||
|
||||
#ifdef JNI_VERSION_1_2
|
||||
|
||||
if (env->EnsureLocalCapacity(3) < 0)
|
||||
goto done2;
|
||||
|
||||
#endif
|
||||
|
||||
clazz = env->GetObjectClass(obj);
|
||||
mid = env->GetMethodID(clazz, name, signature);
|
||||
if (mid == 0)
|
||||
@@ -643,8 +650,19 @@ JNU_CallMethodByNameV(JNIEnv *env,
|
||||
env->DeleteLocalRef(clazz);
|
||||
done2:
|
||||
if (hasException) {
|
||||
#ifdef JNI_VERSION_1_2
|
||||
*hasException = env->ExceptionCheck();
|
||||
}
|
||||
#else
|
||||
jthrowable exception = env->ExceptionOccurred();
|
||||
if ( exception != NULL ) {
|
||||
*hasException = true;
|
||||
env->DeleteLocalRef( exception );
|
||||
}
|
||||
else {
|
||||
*hasException = false;
|
||||
}
|
||||
#endif
|
||||
} // END
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -656,7 +674,14 @@ JNU_GetEnv(JavaVM *vm, jint version)
|
||||
JNIEnv *result = nsnull;
|
||||
#ifdef BAL_INTERFACE
|
||||
#else
|
||||
|
||||
#ifdef JNI_VERSION_1_2
|
||||
vm->AttachCurrentThread((void **)&result, (void *) version);
|
||||
#else
|
||||
vm->AttachCurrentThread( &result, ( void * )version);
|
||||
+
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ann Sunhachawee
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -38,6 +40,28 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
|
||||
//
|
||||
// added for 1.1.x compatibility
|
||||
//
|
||||
#ifdef JNI_VERSION_1_2
|
||||
|
||||
#ifndef JNI_VERSION
|
||||
#define JNI_VERSION JNI_VERSION_1_2
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef JNI_VERSION_1_1
|
||||
#define JNI_VERSION_1_1 0x00010001
|
||||
#endif
|
||||
|
||||
#ifndef JNI_VERSION
|
||||
#define JNI_VERSION JNI_VERSION_1_1
|
||||
#endif
|
||||
|
||||
#endif // END: JNI_VERSION_1_2
|
||||
|
||||
//
|
||||
// String constants, defined in jni_util.cpp
|
||||
//
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
* Jason Mawdsley <jason@macadamian.com>
|
||||
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -201,7 +203,7 @@ util_InitializeEventMaskValuesFromClass(const char *className,
|
||||
}
|
||||
|
||||
if (nsnull != gVm) {
|
||||
env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
}
|
||||
|
||||
jclass clazz = ::util_FindClass(env, className);
|
||||
|
||||
Reference in New Issue
Block a user