Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 776910 - dev-java/zstd-jni-1.4.9.1 does not find jni.h if dev-java/icedtea-bin or dev-java/openjdk-bin is used
Summary: dev-java/zstd-jni-1.4.9.1 does not find jni.h if dev-java/icedtea-bin or dev-...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Java team
URL:
Whiteboard:
Keywords: PullRequest
: 802261 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-03-17 09:20 UTC by Toralf Förster
Modified: 2021-08-01 08:16 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge-info.txt (emerge-info.txt,14.91 KB, text/plain)
2021-03-17 09:20 UTC, Toralf Förster
Details
dev-java:zstd-jni-1.4.9.1:20210317-090750.log (dev-java:zstd-jni-1.4.9.1:20210317-090750.log,36.47 KB, text/plain)
2021-03-17 09:20 UTC, Toralf Förster
Details
emerge-history.txt (emerge-history.txt,30.70 KB, text/plain)
2021-03-17 09:20 UTC, Toralf Förster
Details
environment (environment,151.92 KB, text/plain)
2021-03-17 09:20 UTC, Toralf Förster
Details
etc.portage.tar.bz2 (etc.portage.tar.bz2,12.04 KB, application/x-bzip)
2021-03-17 09:20 UTC, Toralf Förster
Details
logs.tar.bz2 (logs.tar.bz2,4.39 KB, application/x-bzip)
2021-03-17 09:20 UTC, Toralf Förster
Details
temp.tar.bz2 (temp.tar.bz2,34.76 KB, application/x-bzip)
2021-03-17 09:20 UTC, Toralf Förster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2021-03-17 09:20:06 UTC
/var/tmp/portage/dev-java/zstd-jni-1.4.9.1/work/zstd-jni-1.4.9-1/src/main/native/jni_directbuffercompress_zstd.c:1:10: fatal error: jni.h: No such file or directory
    1 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.

  -------------------------------------------------------------------

  This is an unstable amd64 chroot image at a tinderbox (==build bot)
  name: 17.1_hardened-20210316-095736

  -------------------------------------------------------------------

gcc-config -l:
 [1] x86_64-pc-linux-gnu-10.2.0 *
clang version 11.1.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/11/bin
/usr/lib/llvm/11
11.1.0
Python 3.8.8
Available Rust versions:
  [1]   rust-1.50.0 *
The following VMs are available for generation-2:
*)	AdoptOpenJDK 8.282_p08 [openjdk-bin-8]
Available Java Virtual Machines:
  [1]   openjdk-bin-8  system-vm


  timestamp(s) of HEAD at this tinderbox image:
/var/db/repos/gentoo	Wed Mar 17 08:36:04 UTC 2021

emerge -qpvO dev-java/zstd-jni
[ebuild  N    ] dev-java/zstd-jni-1.4.9.1
Comment 1 Toralf Förster gentoo-dev 2021-03-17 09:20:08 UTC
Created attachment 692103 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2021-03-17 09:20:09 UTC
Created attachment 692106 [details]
dev-java:zstd-jni-1.4.9.1:20210317-090750.log
Comment 3 Toralf Förster gentoo-dev 2021-03-17 09:20:10 UTC
Created attachment 692109 [details]
emerge-history.txt
Comment 4 Toralf Förster gentoo-dev 2021-03-17 09:20:12 UTC
Created attachment 692112 [details]
environment
Comment 5 Toralf Förster gentoo-dev 2021-03-17 09:20:13 UTC
Created attachment 692115 [details]
etc.portage.tar.bz2
Comment 6 Toralf Förster gentoo-dev 2021-03-17 09:20:14 UTC
Created attachment 692118 [details]
logs.tar.bz2
Comment 7 Toralf Förster gentoo-dev 2021-03-17 09:20:15 UTC
Created attachment 692121 [details]
temp.tar.bz2
Comment 8 Miroslav Šulc gentoo-dev 2021-05-13 13:44:57 UTC
just came across this issue on a server where i try to install this package. the cause is that not every jdk as we have it packaged provides jni.h:

# find /usr/ -name jni.h
/usr/include/libavcodec/jni.h
/usr/lib64/icedtea8/include/jni.h
/usr/lib64/openjdk-11/include/jni.h
/usr/lib64/openjdk-8/include/jni.h

# eselect java-vm list
Available Java Virtual Machines:
  [1]   icedtea-8 
  [2]   icedtea-bin-8 
  [3]   openjdk-8 
  [4]   openjdk-11  system-vm
  [5]   openjdk-bin-8 
  [6]   openjdk-bin-11 

so for some reason -bin versions of jdk do not provide this file.

switching to a non-bin jdk works this issue around.
Comment 9 Georgy Yakovlev archtester gentoo-dev 2021-05-14 02:20:48 UTC
it's located in /opt

/opt/openjdk-bin-8.292_p10/include/jni.h

and accessible via symlink in 

/usr/lib/jvm/openjdk-bin-8/include/jni.h

also via 

/etc/java-config-2/current-system-vm/include/jni.h ( if it's eselected )

so probably package needs to pass something like --includedir ${JAVA_HOME}/include ( that's imaginary option ofc )

so the file is provided, need to modify ebuilds/eclasses/build-systems to be able to look in right place.
Comment 10 Georgy Yakovlev archtester gentoo-dev 2021-05-14 02:25:26 UTC
find -L /usr -name jni.h 2>/dev/null


need that -L for find to show symlinked paths
Comment 11 Miroslav Šulc gentoo-dev 2021-05-14 07:50:55 UTC
thanks, will have to dig into it more why it does not work with if include is symlink
Comment 12 Ionen Wolkens gentoo-dev 2021-07-16 16:46:00 UTC
*** Bug 802261 has been marked as a duplicate of this bug. ***
Comment 13 Yuan Liao (Leo3418) 2021-07-28 05:08:01 UTC
It seems like this issue is related to the 'headless-awt' USE flag of JDK packages. I got the same issue with dev-java/openjdk-bin-8.292_p10 with USE="headless-awt", but once I disabled this USE flag, dev-java/zstd-jni could be compiled without any more errors.

I can find this USE flag enabled in the 'etc.portage.tar.bz2' file you uploaded:

    $ grep -nr headless-awt package.use/
    package.use/23thrown_global_use_flags_from_metadata:2:*/*  editcap -futex g-sorcery glide graphicaleffects headless-awt jbig

When I installed this package with headless-awt enabled, the following line showed up in CMake output:

    -- Could NOT find JNI (missing: JAVA_AWT_LIBRARY)

Then I rebuilt openjdk-bin with the USE flag disabled, and it changed to this:

    -- Found JNI: /opt/openjdk-bin-8.292_p10/jre/lib/amd64/libjawt.so
Comment 14 Volkmar W. Pogatzki 2021-07-28 10:49:29 UTC
(In reply to "Leo" Y. Liao from comment #13)
> It seems like this issue is related to the 'headless-awt' USE flag of JDK
> packages. I got the same issue with dev-java/openjdk-bin-8.292_p10 with
> USE="headless-awt", but once I disabled this USE flag, dev-java/zstd-jni
> could be compiled without any more errors.
> [...]

Sounds very similar to bug #801277 except that dev-java/zstd-jni does not depend on virtual/jdk.  Adding 
>=virtual/jdk-1.8:*[-headless-awt]
Comment 15 Yuan Liao (Leo3418) 2021-07-28 16:30:27 UTC
^

I created a pull request containing a patch that fixes this issue from a different approach.  Although CMake's JNI module (located at /usr/share/cmake/Modules/FindJNI.cmake) requires all components of JNI, including  libjawt.so, for setting JNI_FOUND to TRUE, libjawt.so is actually not used by zstd-jni.  Therefore, it is fine for libjawt.so to be absent, and [-headless-awt] is not necessary.  To trick CMake into thinking that the JNI is complete, it is possible to set JAVA_AWT_LIBRARY to a dummy value.  This will not cause any problem for zstd-jni because it does not uses the AWT library, thus the JAVA_AWT_LIBRARY variable will not be read during the compilation process.
Comment 16 Larry the Git Cow gentoo-dev 2021-07-28 19:53:02 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=16b7cf5e72b6255564733656746c76421b776b0a

commit 16b7cf5e72b6255564733656746c76421b776b0a
Author:     Yuan Liao <liaoyuan@gmail.com>
AuthorDate: 2021-07-28 15:03:03 +0000
Commit:     Florian Schmaus <flow@gentoo.org>
CommitDate: 2021-07-28 19:52:11 +0000

    dev-java/zstd-jni: Allow CMake to find and use JNI without AWT
    
    The AWT library, libjawt.so, is not needed for zstd-jni itself as the
    compilation can finish without it.  But CMake's FindJNI module will
    always try to search for it, and if it is not found, CMake will declare
    everything pertaining to JNI unavailable, even if some of the JNI
    components do exist on the system -- like jni.h, which is required for
    building zstd-jni.  Because the AWT library is actually unused, it is
    safe to set the CMake variable controlling it (JAVA_AWT_LIBRARY) to an
    arbitrary string for deceiving CMake about its existence.
    
    Closes: https://bugs.gentoo.org/776910
    Package-Manager: Portage-3.0.20, Repoman-3.0.2
    Signed-off-by: Yuan Liao <liaoyuan@gmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/21816
    Signed-off-by: Florian Schmaus <flow@gentoo.org>

 dev-java/zstd-jni/zstd-jni-1.4.9.1.ebuild | 3 +++
 dev-java/zstd-jni/zstd-jni-1.5.0.4.ebuild | 3 +++
 2 files changed, 6 insertions(+)