Bug 21410 - javah task doesn't work w/ j2sdk1.4.2
Summary: javah task doesn't work w/ j2sdk1.4.2
Status: RESOLVED DUPLICATE of bug 18667
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.5.3
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-08 15:31 UTC by Kaleb S. KEITHLEY
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaleb S. KEITHLEY 2003-07-08 15:31:45 UTC
The following patch is necessary to use ant with j2sdk1.4.2

This patch just punts the problem by using the "oldjavah" package instead of the
NewAndImproved javah package. The dearth of documentation for the javah package
makes it difficult to know what the correct fix might actually be.

***
apache-ant-1.5.3-1/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java.orig
 Mon Jul  7 15:51:51 2003
---
apache-ant-1.5.3-1/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java  
    Mon Jul  7 16:26:01 2003
***************
*** 347,355 ****
              // dynamically. However, javah has a different interface and this
              // makes it harder, so here's a simple alternative.
              //------------------------------------------------------------------
!             com.sun.tools.javah.Main main
!                 = new com.sun.tools.javah.Main(cmd.getArguments());
!             main.run();
          } catch (Exception ex) {
              if (ex instanceof BuildException) {
                  throw (BuildException) ex;
--- 347,374 ----
              // dynamically. However, javah has a different interface and this
              // makes it harder, so here's a simple alternative.
              //------------------------------------------------------------------
!             Class parameterTypes[] = new Class[1];
!             parameterTypes[0] = new String[0].getClass();
!             Class javahMain = Class.forName("com.sun.tools.javah.Main");
!             java.lang.reflect.Constructor ctor = null;
!             try {
!                 ctor = javahMain.getConstructor(parameterTypes);
!             } catch (NoSuchMethodException nsme) {
!                 javahMain = Class.forName("com.sun.tools.javah.oldjavah.Main");
!                 ctor = javahMain.getConstructor(parameterTypes);
!             }
!
!             Object args[] = new Object[1];
!             args[0] = cmd.getArguments();
!
!             // com.sun.tools.javah.Main main
!                 // = new com.sun.tools.javah.Main(cmd.getArguments());
!             Object main = ctor.newInstance(args);
!
!             // main.run();
!             java.lang.reflect.Method run = javahMain.getMethod("run", new
Class[0]);
!             run.invoke(main, new Object[0]);
!
          } catch (Exception ex) {
              if (ex instanceof BuildException) {
                  throw (BuildException) ex;
Comment 1 peter reilly 2003-07-08 15:34:28 UTC

*** This bug has been marked as a duplicate of 18667 ***