openjdk: Hackery to ensure that tools.jar is found

HotSpot uses the absolute path of libjvm.so to determine the java.home
property (ignoring $JAVA_HOME), which is in turn used by
ToolProvider.getSystemJavaCompiler() to load tools.jar.  So we need to
do some trickery to ensure that if java gets invoked from the jdk
output (ratherthan the jre output), it finds libjvm.so in the jdk output.
This commit is contained in:
Eelco Dolstra 2014-01-25 02:29:14 +01:00
parent e07ce3314d
commit 981cac8e10
2 changed files with 31 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, unzip, zip, procps, coreutils, alsaLib, ant, freetype, cups
, which, jdk, nettools, libX11, libXt, libXext, libXrender, libXtst, libXi, libXinerama
, libXcursor, fontconfig, cpio, cacert, perl, setJavaClassPath }:
, which, jdk, nettools, xorg
, fontconfig, cpio, cacert, perl, setJavaClassPath }:
let
@ -33,7 +33,8 @@ stdenv.mkDerivation rec {
buildInputs =
[ unzip procps ant which zip cpio nettools alsaLib
libX11 libXt libXext libXrender libXtst libXi libXinerama libXcursor
xorg.libX11 xorg.libXt xorg.libXext xorg.libXrender xorg.libXtst
xorg.libXi xorg.libXinerama xorg.libXcursor xorg.lndir
fontconfig perl
];
@ -48,7 +49,7 @@ stdenv.mkDerivation rec {
openjdk/{jdk,corba}/make/common/shared/Defs-utils.gmk
'';
patches = [ ./cppflags-include-fix.patch ];
patches = [ ./cppflags-include-fix.patch ./fix-java-home.patch ];
NIX_NO_SELF_RPATH = true;
@ -80,6 +81,9 @@ stdenv.mkDerivation rec {
mv $out/lib/openjdk/include $out/include
mv $out/lib/openjdk/man $out/share/man
# jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/linux/*_md.h $out/include/
# Remove some broken manpages.
rm -rf $out/share/man/ja*
@ -88,10 +92,15 @@ stdenv.mkDerivation rec {
# Move the JRE to a separate output.
mv $out/lib/openjdk/jre $jre/lib/openjdk/
ln -s $jre/lib/openjdk/jre $out/lib/openjdk/jre
mkdir $out/lib/openjdk/jre
lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre
rm -rf $out/lib/openjdk/jre/bin
ln -s $out/lib/openjdk/bin $out/lib/openjdk/jre/bin
# Remove duplicate binaries.
for i in $(cd $out/lib/openjdk/bin && echo *); do
if [ "$i" = java ]; then continue; fi
if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then
ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i
fi

View File

@ -0,0 +1,17 @@
diff -ru -x '*~' openjdk-orig/hotspot/src/os/linux/vm/os_linux.cpp openjdk/hotspot/src/os/linux/vm/os_linux.cpp
--- openjdk-orig/hotspot/src/os/linux/vm/os_linux.cpp 2013-09-06 20:22:03.000000000 +0200
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp 2014-01-24 22:44:08.223857012 +0100
@@ -2358,12 +2358,10 @@
CAST_FROM_FN_PTR(address, os::jvm_path),
dli_fname, sizeof(dli_fname), NULL);
assert(ret, "cannot locate libjvm");
char *rp = NULL;
if (ret && dli_fname[0] != '\0') {
- rp = realpath(dli_fname, buf);
+ snprintf(buf, buflen, "%s", dli_fname);
}
- if (rp == NULL)
- return;
if (Arguments::created_by_gamma_launcher()) {
// Support for the gamma launcher. Typical value for buf is