Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 157750 - javah task is not defined in ant built with GCJ [patch]
Summary: javah task is not defined in ant built with GCJ [patch]
Alias: None
Product: Fedora
Classification: Fedora
Component: ant
Version: 4
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Gary Benson
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2005-05-14 15:04 UTC by Mary Ellen Foster
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-05-23 13:02:03 UTC

Attachments (Terms of Use)
Ant build file demonstrating the problem (deleted)
2005-05-14 15:10 UTC, Mary Ellen Foster
no flags Details file needed to run the attached build file (deleted)
2005-05-14 15:11 UTC, Mary Ellen Foster
no flags Details
Fixed build.xml (the previous one had a typo) (deleted)
2005-05-14 15:12 UTC, Mary Ellen Foster
no flags Details
Patch to ant's build.xml to make it unconditionally build javah (deleted)
2005-05-18 21:35 UTC, Mary Ellen Foster
no flags Details | Diff
Modified ant.spec to include the previous patch (deleted)
2005-05-18 21:36 UTC, Mary Ellen Foster
no flags Details | Diff

Description Mary Ellen Foster 2005-05-14 15:04:13 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050509 Fedora/1.0.3-5 Firefox/1.0.3

Description of problem:
I just tried compiling some of my Java/JNI stuff on FC4T3. The ant build file uses a "javah" task; this doesn't seem to be defined anywhere in the ant that's installed on FC4T3.

I'll attach a testcase build.xml and source .java file in a second.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Copy the two attachments into a temporary directory
2. Type "ant"  

Actual Results:  BUILD FAILED
/home/mef/bug-tmp/build.xml:4: Could not create task or type of type: javah.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
 - You have misspelt 'javah'.
   Fix: check your spelling.
 - The task needs an external JAR file to execute
     and this is not found at the right place in the classpath.
   Fix: check the documentation for dependencies.
   Fix: declare the task.
 - The task is an Ant optional task and the JAR file and/or libraries
     implementing the functionality were not found at the time you
     yourself built your installation of Ant from the Ant sources.
   Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
     task and make sure it contains more than merely a META-INF/MANIFEST.MF.
     If all it contains is the manifest, then rebuild Ant with the needed
     libraries present in ${ant.home}/lib/optional/ , or alternatively,
     download a pre-built release version from
 - The build file was written for a later version of Ant
   Fix: upgrade to at least the latest release version of Ant
 - The task is not an Ant core or optional task
     and needs to be declared using <taskdef>.
 - You are attempting to use a task defined using
    <presetdef> or <macrodef> but have spelt wrong or not
   defined it at the point of use

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.

Total time: 0 seconds

Expected Results:  It compiles the Java file and then creates the JNI header file.

Additional info:

Comment 1 Mary Ellen Foster 2005-05-14 15:10:43 UTC
Created attachment 114384 [details]
Ant build file demonstrating the problem

Comment 2 Mary Ellen Foster 2005-05-14 15:11:17 UTC
Created attachment 114385 [details] file needed to run the attached build file

Comment 3 Mary Ellen Foster 2005-05-14 15:12:56 UTC
Created attachment 114386 [details]
Fixed build.xml (the previous one had a typo)

Comment 4 Mary Ellen Foster 2005-05-18 21:11:24 UTC
Okay, did a bit more investigating. I went and got ant-1.6.2-3jpp_6fc.src.rpm
and tried rebuilding it on my system, using the JPackage version of Sun Java SDK
1.5.0_02 and 1.4.2_08. I then compared the resulting "ant-nodeps.jar" (inside
the ant-nodeps RPM) to the one I had installed on my system. The following files
and directories are included in ant.jar one I built, but not in the Rawhide one
(or one I built myself with GCJ):

> org/apache/tools/ant/taskdefs/optional/sound/
> org/apache/tools/ant/taskdefs/optional/Javah$ClassArgument.class
> org/apache/tools/ant/taskdefs/optional/Javah.class
> org/apache/tools/ant/taskdefs/optional/Native2Ascii$1.class
> org/apache/tools/ant/taskdefs/optional/Native2Ascii$ExtMapper.class
> org/apache/tools/ant/taskdefs/optional/Native2Ascii.class
> org/apache/tools/ant/taskdefs/optional/depend/Depend$1.class

Investigating the build.xml file for ant, it turns out this is because of the
following check:
  <!-- classes that should be present in Sun based JVMs, but not in
       Kaffe for example -->
  <selector id="">
      <filename name="${optional.package}/Native2Ascii*"/>
      <filename name="${optional.package}/Javah*"/>

This selector gets used when deciding what files to compile, so when ant is
built with GCJ, those classes don't get built.

I understand why this happened now, and I appreciate that you don't want to rely
on closed-source tools like the Sun JDK in Fedora. But this is pretty much a
show-stopper for me with ant, as I'm currently doing a lot of Java Native
Interface development.

At the very least, the fact that javah is not included in Fedora's default ant
installation should definitely be documented somewhere, along with the advice
that people who need it (who are probably using the Sun compiler anyway) should
rebuild their own ant using the Sun compiler or something.

Comment 5 Mary Ellen Foster 2005-05-18 21:33:51 UTC
On further investigation, it looks like has actually already been
modified so that it uses reflection, and actually *doesn't* rely on a Sun VM for
compilation. That check in build.xml is actually not needed. Native2Ascii still
uses a sun.* class directly, though, so it can't be compiled with GJC, but I was
able to create a patch and modify ant.spec to build javah.

I'll attach the patches in a sec. Dunno if this got changed upstream in ant
1.6.3; if so, this is sort of irrelevant, but in the short term it gives me a
version of ant I can use so I'm happy. :)

Comment 6 Mary Ellen Foster 2005-05-18 21:35:37 UTC
Created attachment 114536 [details]
Patch to ant's build.xml to make it unconditionally build javah

Comment 7 Mary Ellen Foster 2005-05-18 21:36:35 UTC
Created attachment 114537 [details]
Modified ant.spec to include the previous patch

Comment 8 Mary Ellen Foster 2005-05-18 23:00:58 UTC
Sorry for the spam ... but I couldn't resist checking the changes in 1.6.3, and
it looks like javah and native2ascii have both been refactored and will compile
with whatever compiler without problems. So my patch can be ignored if 1.6.3 is
going to be added to Fedora/JPackage in the near future.

Comment 9 Mary Ellen Foster 2005-05-19 16:21:42 UTC
... however, there is a different bug in 1.6.3's javah implementation; see

Maybe I should be sending this sort of info to jpackage instead of redhat bugzilla?

Comment 10 Gary Benson 2005-05-23 13:02:03 UTC
Sorry for the delay in responding to this -- I've been on vacation.

I've added your patch and built it as ant-1.6.2-3jpp_7fc.  Thanks for your
detailed attention, it's much appreciated.

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