Bug 498964 - openjdk-devel does not provide jni.h
Summary: openjdk-devel does not provide jni.h
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: java-1.6.0-openjdk
Version: rawhide
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
Assignee: Lillian Angel
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-05-04 15:44 UTC by Stepan Kasal
Modified: 2009-05-11 11:26 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-05-11 11:26:15 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Stepan Kasal 2009-05-04 15:44:57 UTC
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 18:38:34 UTC
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 11:26:15 UTC
(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.