Bug 498964

Summary: openjdk-devel does not provide jni.h
Product: [Fedora] Fedora Reporter: Stepan Kasal <kasal>
Component: java-1.6.0-openjdkAssignee: Lillian Angel <langel>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: dbhole, langel, lkundrak, mjw, omajid
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-05-11 11:26:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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"