You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/02/11 00:10:17 UTC

cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/javah SunJavah.java

mbenson     2005/02/10 15:10:17

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/javah
                        SunJavah.java
  Log:
  Ensure the forked VM can find the Sun Javah implementation.
  
  Revision  Changes    Path
  1.2       +12 -6     ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/SunJavah.java
  
  Index: SunJavah.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/SunJavah.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SunJavah.java	4 Feb 2005 08:08:07 -0000	1.1
  +++ SunJavah.java	10 Feb 2005 23:10:17 -0000	1.2
  @@ -16,7 +16,10 @@
    */
   package org.apache.tools.ant.taskdefs.optional.javah;
   
  +import java.io.File;
  +
   import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.launch.Locator;
   import org.apache.tools.ant.taskdefs.ExecuteJava;
   import org.apache.tools.ant.taskdefs.optional.Javah;
   import org.apache.tools.ant.types.Commandline;
  @@ -40,22 +43,25 @@
       public boolean compile(Javah javah) throws BuildException {
           Commandline cmd = setupJavahCommand(javah);
           ExecuteJava ej = new ExecuteJava();
  -
  +        Class c = null;
           try {
               try {
                   // first search for the "old" javah class in 1.4.2 tools.jar
  -                Class.forName("com.sun.tools.javah.oldjavah.Main");
  -                cmd.setExecutable("com.sun.tools.javah.oldjavah.Main");
  +                c = Class.forName("com.sun.tools.javah.oldjavah.Main");
               } catch (ClassNotFoundException cnfe) {
                   // assume older than 1.4.2 tools.jar
  -                Class.forName("com.sun.tools.javah.Main");
  -                cmd.setExecutable("com.sun.tools.javah.Main");
  +                c = Class.forName("com.sun.tools.javah.Main");
               }
           } catch (ClassNotFoundException ex) {
               throw new BuildException("Can't load javah", ex, 
                                        javah.getLocation());
           }
  +        cmd.setExecutable(c.getName());
           ej.setJavaCommand(cmd);
  +        File f = Locator.getClassSource(c);
  +        if (f != null) {
  +            ej.setClasspath(new Path(javah.getProject(), f.getPath()));
  +        }
           return ej.fork(javah) == 0;
       }
   
  @@ -117,4 +123,4 @@
           return cmd;
       }
   
  -}
  \ No newline at end of file
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org