Bug 157750 - javah task is not defined in ant built with GCJ [patch]
javah task is not defined in ant built with GCJ [patch]
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: ant (Show other bugs)
4
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Gary Benson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-05-14 11:04 EDT by Mary Ellen Foster
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-05-23 09:02:03 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)
Ant build file demonstrating the problem (251 bytes, text/xml)
2005-05-14 11:10 EDT, Mary Ellen Foster
no flags Details
Main.java file needed to run the attached build file (142 bytes, text/x-java)
2005-05-14 11:11 EDT, Mary Ellen Foster
no flags Details
Fixed build.xml (the previous one had a typo) (251 bytes, text/xml)
2005-05-14 11:12 EDT, Mary Ellen Foster
no flags Details
Patch to ant's build.xml to make it unconditionally build javah (382 bytes, patch)
2005-05-18 17:35 EDT, Mary Ellen Foster
no flags Details | Diff
Modified ant.spec to include the previous patch (1.08 KB, patch)
2005-05-18 17:36 EDT, Mary Ellen Foster
no flags Details | Diff

  None (edit)
Description Mary Ellen Foster 2005-05-14 11:04:13 EDT
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):
ant-1.6.2-3jpp_6fc

How reproducible:
Always

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 apache.org
 - 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
classpath

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 11:10:43 EDT
Created attachment 114384 [details]
Ant build file demonstrating the problem
Comment 2 Mary Ellen Foster 2005-05-14 11:11:17 EDT
Created attachment 114385 [details]
Main.java file needed to run the attached build file
Comment 3 Mary Ellen Foster 2005-05-14 11:12:56 EDT
Created attachment 114386 [details]
Fixed build.xml (the previous one had a typo)
Comment 4 Mary Ellen Foster 2005-05-18 17:11:24 EDT
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="needs.sun.tools">
    <or>
      <filename name="${optional.package}/Native2Ascii*"/>
      <filename name="${optional.package}/Javah*"/>
    </or>
  </selector>

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 17:33:51 EDT
On further investigation, it looks like Javah.java 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 17:35:37 EDT
Created attachment 114536 [details]
Patch to ant's build.xml to make it unconditionally build javah
Comment 7 Mary Ellen Foster 2005-05-18 17:36:35 EDT
Created attachment 114537 [details]
Modified ant.spec to include the previous patch
Comment 8 Mary Ellen Foster 2005-05-18 19:00:58 EDT
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 12:21:42 EDT
... however, there is a different bug in 1.6.3's javah implementation; see
http://issues.apache.org/bugzilla/show_bug.cgi?id=34681

Maybe I should be sending this sort of info to jpackage instead of redhat bugzilla?
Comment 10 Gary Benson 2005-05-23 09:02:03 EDT
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.