Bug 498964 - openjdk-devel does not provide jni.h
openjdk-devel does not provide jni.h
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: java-1.6.0-openjdk (Show other bugs)
rawhide
i386 Linux
low Severity medium
: ---
: ---
Assigned To: Lillian Angel
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-04 11:44 EDT by Stepan Kasal
Modified: 2009-05-11 07:26 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-05-11 07:26:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Stepan Kasal 2009-05-04 11:44:57 EDT
When java-1.6.0-oenjdk-devel.i586 is installed and then configure checks for jni.h
(a simple AC_CHECK_HEADER), then is is not found.
In contrast to this, with java-1.5.0-gcj-devel (and thus libgcj-devel), jni.h is immediately available.

Shouldn't openjdk's java-devel provide jni.h as well?
Comment 1 Omair Majid 2009-05-04 14:38:34 EDT
It does:
$ rpm -ql java-1.6.0-openjdk-devel | grep jni
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include/jni.h
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include/linux/jni_md.h

However, java-1.6.0-openjdk doesnt add it to the default search path. AC_CHECK_HEADER uses cpp to find out if the header is available. So cpp needs to be told about java-1.6.0-openjdk's include dir. 

This works for me:
CPPFLAGS="-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include/linux $CPPFLAGS"
CPPFLAGS="-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include $CPPFLAGS"

AC_CHECK_HEADER([jni.h],, [AC_ERROR(jni.h not found)])

Please see this for more information: http://sources.redhat.com/ml/automake/2001-05/msg00012.html
Comment 2 Stepan Kasal 2009-05-11 07:26:15 EDT
(In reply to comment #1)
> CPPFLAGS="-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include/linux $CPPFLAGS"
> CPPFLAGS="-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/include $CPPFLAGS"
> AC_CHECK_HEADER([jni.h],, [AC_ERROR(jni.h not found)])

I do not think that hardwiring these directories to configure.ac is the right solution.

But your advice was the first hint towards the solution; then more hints came from fedora-devel-java-list, see 
http://thread.gmane.org/gmane.linux.redhat.fedora.java/2993/focus=3007

To sum up: even though gcj has jni.h in the default cpp search path, this is not guaranteed by all java implementations.  But every java alternative should place jni.h under the directory /usr/lib/jvm/java, which is maintained by the alternatives utility.

The following seems to be the right bit to make *.spec portable to all archs:

BuildRequires: java-devel
[...]
%build
for i in -I/usr/lib/jvm/java/include{,/linux}; do
      java_inc="$java_inc $i"
done
%configure CPPFLAGS="$java_inc"

Note You need to log in before you can comment on or make changes to this bug.