Bug 297282 - java/openjdk25: libjava.so does not find libjvm.so
Summary: java/openjdk25: libjava.so does not find libjvm.so
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-java (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-08-04 19:55 UTC by Thierry Thomas
Modified: 2026-08-17 10:32 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (java)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Thomas freebsd_committer freebsd_triage 2026-08-04 19:55:23 UTC
On 16-CURRENT I'm using openjdk25 installed by pkg:
        FreeBSD_version: 1600019
        build_timestamp: 2026-07-25T01:04:44+0000
        built_by       : poudriere-git-3.4.8
        cpe            : cpe:2.3:a:oracle:openjdk:25.0.3+9.f.1:::::freebsd16:x64
        flavor         : jdk
        port_checkout_unclean: no
        port_git_hash  : a775e64d13a6bb7f4e5133105227f37fdc87a882
        ports_top_checkout_unclean: no
        ports_top_git_hash: 7c53142d6b1d65fc3b37c1ce6ee6b703206261e2
        repo_type      : binary
        repository     : FreeBSD-ports

and it seems linked against openjdk11:

$ ldd /usr/local/openjdk25/lib/libjava.so
/usr/local/openjdk25/lib/libjava.so:
        libjvm.so => /usr/local/openjdk11/lib/server/libjvm.so (0x1290b8e00000)
        libdl.so.1 => /usr/lib/libdl.so.1 (0x1290ba54d000)
        libc.so.7 => /lib/libc.so.7 (0x1290b763b000)
        libm.so.5 => /lib/libm.so.5 (0x1290b6423000)
        libc++.so.1 => /lib/libc++.so.1 (0x1290ba700000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x1290bb289000)
        libthr.so.3 => /lib/libthr.so.3 (0x1290bbe74000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x1290bbf95000)
        libsys.so.7 => /lib/libsys.so.7 (0x1290b7b74000)

Actually, openjdk11 is installed on this machine. After removing it, ldd reports a missing libjvm.so:

$ ldd /usr/local/openjdk25/lib/libjava.so
/usr/local/openjdk25/lib/libjava.so:
        libjvm.so => not found (0)
        libdl.so.1 => /usr/lib/libdl.so.1 (0x3721ac186000)
        libc.so.7 => /lib/libc.so.7 (0x3721ad00c000)

Same thing on another machine running 15.1-RELEASE.

libjvm.so exists for OpenJDK25, it is installed as
/usr/local/openjdk25/lib/server/libjvm.so
but I guess that the linker missed some LDFLAGS with "-Wl,-rpath=$JAVA_HOME/lib/server".

With LD_LIBRARY_PATH=/usr/local/openjdk25/lib/server everything is OK.
Comment 1 Harald Eilertsen freebsd_committer freebsd_triage 2026-08-10 09:44:29 UTC
Thanks for reporting! I'll look into it.
Comment 2 Harald Eilertsen freebsd_committer freebsd_triage 2026-08-12 10:34:07 UTC
The problem seems to be that while libjava.so is located in /usr/local/openjdkXX/lib, libjvm.so is located in /usr/local/openjdkXX/lib/server (assuming the server build, which is the default.)

However, the DT_RUNPATH of libjava.so is set only to `$ORIGIN`, which makes the loader not look in the `server/` directory under it. 

    stigmata% readelf -d /usr/local/openjdk25/lib/libjava.so|grep 'R.*PATH'
      0x000000000000001d (RUNPATH)    Library runpath: [$ORIGIN]

Adding `$ORIGIN/server` to the library runpath seems to solve the issue.

I still don't understand why it insist on picking OpenJDK11 as the default, though.

A bit more work is needed to make the patch more generic, but I hope to be able to update the ports within the week or early next week.
Comment 3 Harald Eilertsen freebsd_committer freebsd_triage 2026-08-14 10:27:24 UTC
Went for a different approach instead, removed the USE_LDCONFIG line from the OpenJDK8 and 11 ports. This will make ldd report that it can't find libjvm.so regardless of which jdk version are installed. Since OpenJDK loads the libs explicitly at runtime, this should not be a problem.
Comment 4 Harald Eilertsen freebsd_committer freebsd_triage 2026-08-14 10:28:05 UTC
Forgot the link to the review: https://reviews.freebsd.org/D58841
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-08-17 10:26:28 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9477c9da0a436a689b99443372a80f20186ee7a9

commit 9477c9da0a436a689b99443372a80f20186ee7a9
Author:     Harald Eilertsen <haraldei@FreeBSD.org>
AuthorDate: 2026-08-14 10:19:14 +0000
Commit:     Harald Eilertsen <haraldei@FreeBSD.org>
CommitDate: 2026-08-17 10:25:52 +0000

    java/openjdk{8,11}: Remove USE_LDCONFIG from ports

    OpenJDK loads the JVM and other JDK libraries explicitly from the
    correct directories, so there's no need for adding them to ldconfig.

    PR:             297282
    Reviewed by:    jrm
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D58841

 java/openjdk11/Makefile | 2 +-
 java/openjdk8/Makefile  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Comment 6 Harald Eilertsen freebsd_committer freebsd_triage 2026-08-17 10:32:00 UTC
This issue should be fixed in the ports main branch now. Let me know if I can close the bug.