Bug 18667 - javah module no longer works with Java 1.4.2
Summary: javah module no longer works with Java 1.4.2
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.5.3
Hardware: PC Linux
: P1 normal (vote)
Target Milestone: 1.5.4
Assignee: Ant Notifications List
URL:
Keywords:
: 20425 20700 20896 21236 21270 21375 21410 21827 21942 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-04-03 20:25 UTC by Calvin Austin
Modified: 2008-02-22 12:18 UTC (History)
10 users (show)



Attachments
Patch to Javah task to support 1.4.2 changes (2.53 KB, patch)
2003-04-07 23:57 UTC, James Allers
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Calvin Austin 2003-04-03 20:25:11 UTC
The javah module uses the old internal interface to javah with entry point Main
and method run() and will generate an error for new JDK releases

java.lang.NoClassDefFoundError: com/sun/tools/javah/Main
 at org.apache.tools.ant.taskdefs.optional.Javah.doClassicCompile(Javah.java:348)
 at org.apache.tools.ant.taskdefs.optional.Javah.execute(Javah.java:318)
 at org.apache.tools.ant.Task.perform(Task.java:319)
 at org.apache.tools.ant.Target.execute(Target.java:309)
 at org.apache.tools.ant.Target.performTasks(Target.java:336)
 at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
 at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
 at org.apache.tools.ant.Main.runBuild(Main.java:610)
 at org.apache.tools.ant.Main.start(Main.java:196)
 at org.apache.tools.ant.Main.main(Main.java:235)

Example test case

<project name="test" default="build" basedir=".">
     <target name="build" >
         <javah destdir="." class="hello">
             <classpath>
                 <pathelement path="classes"/>
             </classpath>
         </javah>
    </target>
</project>
Comment 1 Daniel Dyer 2003-04-04 11:11:04 UTC
I have a similar problem using Ant 1.5.1 on Linux with Java 1.4.2 beta.

java.lang.NoSuchMethodError: com.sun.tools.javah.Main.<init>([Ljava/lang/String;
)V
        at org.apache.tools.ant.taskdefs.optional.Javah.doClassicCompile(Javah.
java:348)
        at org.apache.tools.ant.taskdefs.optional.Javah.execute(Javah.java:318)
        at org.apache.tools.ant.Task.perform(Task.java:319)
        at org.apache.tools.ant.Target.execute(Target.java:309)
        at org.apache.tools.ant.Target.performTasks(Target.java:336)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
        at org.apache.tools.ant.Main.runBuild(Main.java:610)
        at org.apache.tools.ant.Main.start(Main.java:196)
        at org.apache.tools.ant.Main.main(Main.java:235)
Comment 2 Felix Schupp 2003-04-06 20:02:54 UTC
This bug is posted on java.sun.com as bug 4824827

http://developer.java.sun.com/developer/bugParade/bugs/4824827.html

The workaround they suggest is <exec/>
Comment 3 Steve Loughran 2003-04-07 05:39:51 UTC
The sun bug is a bit self centred "Ant will have to check what
version JDK it is running on and use a method present on that JDK.", but of
course there are no stable public methods; this is the whole problem. 

We are going to have to fix this as we'll see the bugreps, but I am miffed at
their attitude. 'yup, we changed stuff without telling you, you will just have
to do a workaround'. Maybe the workaround will have to print out a snide comment in 
return about  Sun's developer team in response, something like "using
nonstandard entrypoint on java1.4.2 because whoever maintains javah doesnt like
Ant". 
Comment 4 Calvin Austin 2003-04-07 15:47:28 UTC
btw I emailed Richard Beton back in February asking if he was still the javah
maintainer because there was an up and coming change to javah. 

I never received a reply
Comment 5 Steve Loughran 2003-04-07 20:23:53 UTC
We can get a patch together if someone can tell us what the new main() class is,
whether any params or exit values have changed. We like an entry point that does
not call System.exit(), incidentally. 
Comment 6 James Allers 2003-04-07 21:18:25 UTC
It looks like javah is now implemented as a doclet. I don't think any of the
arguments hava changed.

com.sun.tools.javah.Main no longer is constructed with the arguments to run against.

The new implementation has a no arg constructor. The new main method verifies
the arguments, appends to more arguments for javadoc("-private" and "-Xclasses",
and invokes javadoc with the following command,

com.sun.tools.javadoc.Main.execute(
    "javadoc",
    "com.sun.tools.javah.MainDoclet",
    args1);

"com.sun.tools.javah.MainDoclet" does not appear to invoke System.exit, and I
think the execute method of com.sun.tools.javadoc.Main will not call System.exit.

I think invoking javadoc with the javah doclet it the way to go for 1.4.2.


Comment 7 Calvin Austin 2003-04-07 21:36:01 UTC
The 'old' interface is still available as 
com.sun.tools.javah.oldjavah.Main.main(args) which should see ant through until
(java) 1.5. This is what the javah binary currently uses
Comment 8 Steve Loughran 2003-04-07 23:13:30 UTC
out of curiosity, why was the old entry point moved? Just to see what broke?
Comment 9 Calvin Austin 2003-04-07 23:46:12 UTC
This was supposed to be some pre work for the up and coming language changes. 
The javah, javap and related tools use a different compiler 'engine' code than
the javac tool. Only one compiler engine would then need to be changed. 

The person who did the change is no longer here.

Comment 10 James Allers 2003-04-07 23:57:48 UTC
Created attachment 5684 [details]
Patch to Javah task to support 1.4.2 changes
Comment 11 Stefan Bodewig 2003-04-09 13:39:08 UTC
Thanks james, patch will be in nightly build 2003-04-10.
Comment 12 Conor MacNeill 2003-06-04 03:26:49 UTC
*** Bug 20425 has been marked as a duplicate of this bug. ***
Comment 13 peter reilly 2003-06-12 07:41:18 UTC
*** Bug 20700 has been marked as a duplicate of this bug. ***
Comment 14 peter reilly 2003-06-19 07:38:47 UTC
*** Bug 20896 has been marked as a duplicate of this bug. ***
Comment 15 Antoine Levy-Lambert 2003-07-01 21:26:06 UTC
*** Bug 21236 has been marked as a duplicate of this bug. ***
Comment 16 Antoine Levy-Lambert 2003-07-02 11:38:09 UTC
*** Bug 21270 has been marked as a duplicate of this bug. ***
Comment 17 peter reilly 2003-07-07 15:00:44 UTC
*** Bug 21375 has been marked as a duplicate of this bug. ***
Comment 18 peter reilly 2003-07-08 15:34:30 UTC
*** Bug 21410 has been marked as a duplicate of this bug. ***
Comment 19 Conor MacNeill 2003-07-23 14:00:33 UTC
*** Bug 21827 has been marked as a duplicate of this bug. ***
Comment 20 Antoine Levy-Lambert 2003-07-28 19:02:56 UTC
*** Bug 21942 has been marked as a duplicate of this bug. ***