Subject: Sun JDK 1.5.0 and Mozilla plug-in
To: None <netbsd-java@netbsd.org>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: netbsd-java
Date: 02/16/2007 18:11:01
I was encountering SIGSEGVs using the scsl-j{re,dk}15 packages due
to a call to inflate_fast. Turns out that this problem arises as
the JDK bundles an older version of zlib as libzip.so, but neglects
to conceal all the zlib's exported symbols, which causes a conflict
when using any other libraries linking to the system's libz.so (Sun
bug #4953050). After lots of digging, it turns out the only way
to rectify this is to rebuild from source, and cause the build to use
the system's zlib. So I did.
While I was at it, I also looked into what would be necessary to
get the Mozilla/Firefox plugin to work. It turns out to be
surprisingly simple.
I've attached patches that, on top of Todd's and the BSD Java
patchset 4, will build the JDK and Mozilla/Firefox plugin. If you
want to build it yourself, here are the steps:
1. Fetch both the JDK Sources (jdk-1_5_0-src-scsl.zip) and Binaries
(jdk-1_5_0-bin-scsl.zip) from Sun
<http://www.sun.com/software/communitysource/j2se/java2/download.xml>
2. Fetch the FreeBSD JDK patchset #4 from
http://www.eyesbeyond.com/freebsddom/java/jdk15.html
3. Fetch Todd's patches from <http://www.duh.org/NetBSD/java2/>
(labelled `Local-patch-duh1').
4. Unzip the jdk-1_5_0-src-scsl.zip and jdk-1_5_0-bin-scsl.zip in
a directory somewhere (referenced as JDKDIR).
5. Untar the FreeBSD JDK patchset #4; the actual patchfile is
called jdk15.patches. Run the following from your JDKDIR:
patch -p0 < .../jdk15.patches
This should apply cleanly (`echo $?' should be 0)
6. Apply Todd's patches in a similar fashion:
zcat duh-jdk15-patches-1.bz2 | patch -N -p0
This patchset will not apply cleanly. The first patch, to
awt_motif21.c, was incorporated into the FreeBSD JDK patchset #4.
The last patch to the ns7-adapter/Makefile will have its second
chunk fail: one of the patches appended below fix this.
7. Apply the patches below.
8. Return to the JDKDIR, and run the following (with suitable
replacements for your JDK, browser):
unset LANG
unset JAVA_HOME
unset CLASSPATH
unset LD_LIBRARY_PATH
export ALT_MOTIF_DIR=/usr/pkg
export ALT_MOZILLA_HEADERS_PATH=/usr/pkg/include/firefox2
export ALT_BOOTDIR=/usr/pkg/java/sun-1.5/
export BROWSER=firefox
export HOTSPOT_BUILD_JOBS=3
export ALT_CACERTS_FILE=/usr/pkg/java/sun-1.5/lib/security/cacerts
# these are optional
export SKIP_COMPARE_IMAGES=YES
export DONT_ENABLE_IPV6=YES
cd control/make && gmake || exit
Assuming it all works, you should find the result in
control/build/<platform> (my platform was bsd-i586). There
are three directories of interest: j2sdk-image, j2re-image,
and j2sdk-debug-image. You should be able to do something
like:
$ cd control/build/<platform>/j2sdk-image/demo/jfc/Java2D
$ ../../../bin/java -jar Java2Demo.jar"
Assuming that runs, copy the j2sdk-image directory somewhere.
Put a symbolic link to jre/plugin/i386/ns7/libjavaplugin_oji.so
in your /usr/pkg/lib/firefox2/plugin/ directory, restart your
browser, and you should be set.
Thanks to Todd for packaging the native Sun JDK together in the
first place, and to the groups who did all the hard work in porting
the JDK to BSD!
Brian.
--- ./j2se/make/common/Defs-bsd.gmk.orig 2007-02-16 10:46:08.000000000 -0600
+++ ./j2se/make/common/Defs-bsd.gmk 2007-02-16 10:45:00.000000000 -0600
@@ -491,6 +491,10 @@
SYSTEM_ZLIB = true
endif
+ifeq ($(TRUE_PLATFORM), NetBSD)
+ SYSTEM_ZLIB = true
+endif
+
#
# Japanese manpages
#
--- ./deploy/make/common/Sanity.gmk.bak 2007-02-16 16:34:46.000000000 -0600
+++ ./deploy/make/common/Sanity.gmk 2007-02-16 16:36:43.000000000 -0600
@@ -181,18 +181,18 @@
fi
else
ifeq ($(PLATFORM), bsd)
- @if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_ns7/nsIPlugin.h ]; then \
+ @if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin/nsIPlugin.h ]; then \
$(ECHO) "ERROR: You do not have access to valid Mozilla header files. \n" \
" Please check your access to \n" \
- " $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_ns7/nsIPlugin.h \n" \
+ " $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin/nsIPlugin.h \n" \
" and/or check your value of ALT_MOZILLA_PATH, ALT_MOZILLA_HEADERS_PATH, \n" \
"" >> $(ERROR_FILE) ; \
fi
else
- @if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_ns7/bool.h ]; then \
+ @if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/java/bool.h ]; then \
$(ECHO) "ERROR: You do not have access to valid Mozilla header files. \n" \
" Please check your access to \n" \
- " $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_ns7/bool.h \n" \
+ " $(subst \,/,$(MOZILLA_HEADERS_PATH))/java/bool.h \n" \
" and/or check your value of ALT_MOZILLA_PATH, ALT_MOZILLA_HEADERS_PATH, \n" \
"" >> $(ERROR_FILE) ; \
fi
--- deploy/make/plugin/adapter/ns7-adapter/Makefile.orig 2007-02-08 19:39:26.000000000 -0600
+++ deploy/make/plugin/adapter/ns7-adapter/Makefile 2007-02-08 18:41:56.000000000 -0600
@@ -65,7 +65,14 @@
COREDIR = $(PLUGIN_TOP)/src/plugin/solaris/nscore
COMMONDIR= $(PLUGIN_TOP)/src/plugin/solaris/common
ifeq ($(PLATFORM), bsd)
-MOZHDRDIR = $(subst \,/,$(MOZILLA_HEADERS_PATH)/mozilla_headers_ns7)
+MOZHDRDIR = $(subst \,/,$(MOZILLA_HEADERS_PATH)/) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/plugin) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/xpcom) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/nspr) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/caps) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/liveconnect) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/oji) \
+ $(subst \,/,$(MOZILLA_HEADERS_PATH)/js)
X11HDRDIR = /usr/X11R6/include
ICONVHDRDIR = /usr/local/include
NSPRHDRDIR = $(NSPR_HEADERS_PATH)
--- deploy/src/plugin/share/adapter/ns7/CNS7Adapter_PluginServiceProvider.cpp.bak 2007-02-16 14:13:44.000000000 -0600
+++ deploy/src/plugin/share/adapter/ns7/CNS7Adapter_PluginServiceProvider.cpp 2007-02-16 14:13:52.000000000 -0600
@@ -27,6 +27,7 @@
#include "nsIJVMManager.h"
#include "nsILiveconnect.h"
#include "nsIObserverService.h"
+#include "nsIComponentManager.h"
#include "nsIJVMAuthTools.h"
#include "CNSAdapter_JVMManager.h"
#include "CNSAdapter_PluginManager.h"
@@ -65,6 +65,16 @@
static JD_DEFINE_CID(jIBrowserAuthenticatorCID, IBROWSERAUTHENTICATOR_IID);
+#ifndef NS_COMPONENTMANAGER_CID
+#define NS_COMPONENTMANAGER_CID \
+{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
+ 0x91775d60, \
+ 0xd5dc, \
+ 0x11d2, \
+ {0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
+}
+#endif
+
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
static NS_DEFINE_CID(kCJVMManagerCID, NS_JVMMANAGER_CID);
static NS_DEFINE_CID(kCLiveConnectCID, NS_CLIVECONNECT_CID);
--
Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
"Amusement to an observing mind is study." - Benjamin Disraeli