Java 1.8.0_311 on Solaris 9 returns 重定位错误,未找到符号 unsetenv 和 sema_timedwait

Java 1.8.0_311 on Solaris 9 returns relocation error, symbols unsetenv and sema_timedwait not found

这类似于this question about Java 1.6。作为该问题的 OP,我在 SPARC v9 架构(物理 SUN Fire V445)上有一个 Solaris:

-bash-4.4$ cat /etc/release 
                      Solaris 9 9/05 HW s9s_u9wos_06b SPARC
           Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                           Assembled 25 September 2006
-bash-4.4$ isainfo -v
64-bit sparcv9 applications
32-bit sparc applications

从最新的 Oracle 分布式 Java 8 for SPARC 64 位调用 java 让我得到这个:

-bash-4.4$ /usr/jdk/instances/jdk1.8.0_311/bin/java -version
Error: dl failure on line 893
Error: failed /export/home1/java/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so, because ld.so.1: java: fatal: relocation error: file /export/home1/java/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so: symbol unsetenv: referenced symbol not found

仔细观察libjvm.so,不仅缺少unsetenv:

-bash-4.4$ ldd -rv /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so

   find object=libsocket.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libsocket.so.1 =>        /usr/lib/64/libsocket.so.1

   find object=libsched.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libsched.so.1 =>         /usr/lib/64/libsched.so.1

   find object=libdl.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libdl.so.1 =>    /usr/lib/64/libdl.so.1

   find object=libm.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libm.so.1 =>     /usr/lib/64/libm.so.1

   find object=libCrun.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libCrun.so.1 =>  /usr/lib/64/libCrun.so.1

   find object=libthread.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libthread.so.1 =>        /usr/lib/64/libthread.so.1

   find object=libdoor.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libdoor.so.1 =>  /usr/lib/64/libdoor.so.1

   find object=libc.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libc.so.1 =>     /usr/lib/64/libc.so.1

   find object=libdemangle.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libdemangle.so.1 =>      /usr/lib/64/libdemangle.so.1

   find object=libkstat.so.1; required by /usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so
        libkstat.so.1 =>         /usr/lib/64/libkstat.so.1

   find object=libnsl.so.1; required by /usr/lib/64/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/64/libnsl.so.1
   find version=libnsl.so.1
        libnsl.so.1 (SUNW_1.7) =>        /usr/lib/64/libnsl.so.1
        libnsl.so.1 (SUNWprivate_1.1) =>         /usr/lib/64/libnsl.so.1

   find object=libc.so.1; required by /usr/lib/64/libsocket.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_1.19) =>         /usr/lib/64/libc.so.1
        libc.so.1 (SUNWprivate_1.1) =>   /usr/lib/64/libc.so.1

   find object=libc.so.1; required by /usr/lib/64/libsched.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_0.8) =>  /usr/lib/64/libc.so.1
        libc.so.1 (SUNWprivate_1.1) =>   /usr/lib/64/libc.so.1

   find object=libc.so.1; required by /usr/lib/64/libm.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_0.7) =>  /usr/lib/64/libc.so.1

   find object=libc.so.1; required by /usr/lib/64/libCrun.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_1.1) =>  /usr/lib/64/libc.so.1
        libc.so.1 (SUNWprivate_1.1) =>   /usr/lib/64/libc.so.1

   find object=libc.so.1; required by /usr/lib/64/libthread.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_1.21.2) =>       /usr/lib/64/libc.so.1
        libc.so.1 (SUNWprivate_1.1) =>   /usr/lib/64/libc.so.1

   find object=libdl.so.1; required by /usr/lib/64/libthread.so.1
   find version=libdl.so.1
        libdl.so.1 (SUNWprivate_1.1) =>  /usr/lib/64/libdl.so.1

   find object=libc.so.1; required by /usr/lib/64/libdoor.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_1.1) =>  /usr/lib/64/libc.so.1
        libc.so.1 (SUNWprivate_1.1) =>   /usr/lib/64/libc.so.1

   find object=libdl.so.1; required by /usr/lib/64/libc.so.1
   find version=libdl.so.1
        libdl.so.1 (SUNW_1.4) =>         /usr/lib/64/libdl.so.1
        libdl.so.1 (SUNWprivate_1.1) =>  /usr/lib/64/libdl.so.1

   find object=libc.so.1; required by /usr/lib/64/libdemangle.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_0.8) =>  /usr/lib/64/libc.so.1

   find object=libc.so.1; required by /usr/lib/64/libkstat.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_0.9) =>  /usr/lib/64/libc.so.1

   find object=libdl.so.1; required by /usr/lib/64/libnsl.so.1
   find version=libdl.so.1
        libdl.so.1 (SUNW_0.7) =>         /usr/lib/64/libdl.so.1

   find object=libc.so.1; required by /usr/lib/64/libnsl.so.1
   find version=libc.so.1
        libc.so.1 (SUNW_1.21) =>         /usr/lib/64/libc.so.1
        libc.so.1 (SUNWprivate_1.2) =>   /usr/lib/64/libc.so.1

   find object=libmp.so.2; required by /usr/lib/64/libnsl.so.1
        libmp.so.2 =>    /usr/lib/64/libmp.so.2
   find version=libmp.so.2
        libmp.so.2 (SUNW_1.1) =>         /usr/lib/64/libmp.so.2
        libmp.so.2 (SUNWprivate_1.1) =>  /usr/lib/64/libmp.so.2

   find object=libc.so.1; required by /usr/lib/64/libmp.so.2
   find version=libc.so.1
        libc.so.1 (SUNW_0.7) =>  /usr/lib/64/libc.so.1

   object=/usr/lib/64/libc.so.1; filter for /usr/platform/$PLATFORM/lib/sparcv9/libc_psr.so.1

   find object=/usr/platform/SUNW,Sun-Fire-V445/lib/sparcv9/libc_psr.so.1; required by /usr/lib/64/libc.so.1
        /usr/platform/SUNW,Sun-Fire-V445/lib/sparcv9/libc_psr.so.1

   object=/usr/lib/64/libdl.so.1; filter for /usr/lib/sparcv9/ld.so.1
        symbol not found: unsetenv              (/usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so)
        symbol not found: sema_timedwait                (/usr/jdk/instances/jdk1.8.0_311/jre/lib/sparcv9/server/libjvm.so)

我假设timedwait信号量应该由librt实​​现,但它不是:

-bash-4.4$ nm -gD /usr/lib/64/librt.so | grep sema
                 w _libthread_sema_wait
                 U _lwp_sema_init
                 U _lwp_sema_post
                 U _lwp_sema_trywait
                 U _lwp_sema_wait
                 U sema_destroy
                 U sema_init
                 U sema_post
                 U sema_trywait
                 U sema_wait

看来,我被困在这里了,因为那是那台机器上唯一可用的 librt.so。有人知道如何让它工作吗? (我知道,sunos5.9 一个垂死的平台,但 Oracle 仍在为该平台分发,我只是希望在那里也能使用它。)

谢谢!

您需要将系统升级到更高版本的 Solaris。 Java 8 is not supported on Solaris 9:

System Requirements

This version of the JDK is supported on the Oracle Solaris 10 Update 9 or later OS, Oracle Solaris 11 Express OS, and Oracle Solaris 11 OS. ...

Solaris 9 没有 unsetenv() 功能。 basic library functions documented in the Solaris 9 man page only lists the following u*() functions:

U

ualarm(3C)- schedule signal after interval in microseconds
ulckpwdf(3C)- manipulate shadow password database lock file
ulltostr(3C)- string conversion routines
ungetc(3C)- push byte back into input stream
ungetwc(3C)- push wide-character code back into input stream
unlockpt(3C)- unlock a pseudo-terminal master/slave pair
unordered(3C)- determine type of floating-point number
updwtmp(3C)- user accounting database functions
updwtmpx(3C)- user accounting database functions
usleep(3C)- suspend execution for interval in microseconds
utmpname(3C)- user accounting database functions
utmpxname(3C)- user accounting database functions

Solaris 9 中唯一的环境处理函数是putenv():

NAME

putenv- change or add value to environment

SYNOPSIS

#include <stdlib.h>

int putenv(char *string);

同样,"S" section of the Threads and Realtime Library Functions man pages section 3 documentation中没有sema_timedwait():

S

   .
   .
   .
sem_unlink — remove a named semaphore ( Index Term Link )
sem_wait — acquire or wait for a semaphore ( Index Term Link )
sema_destroy() — destroy a semaphore ( Index Term Link )
sema_init() — initialize a semaphore ( Index Term Link )
sema_post() — increment a semaphore ( Index Term Link )
sema_trywait() — decrement a semaphore ( Index Term Link )
sema_wait() — decrement a semaphore ( Index Term Link )
semaphore ...