ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/javah SunJavah.java
Date Mon, 02 May 2005 15:03:17 GMT
bodewig     2005/05/02 08:03:17

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/javah Tag:
                        ANT_16_BRANCH SunJavah.java
  Log:
  Ensure that forked VM can find javah, PR 34681
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.2   +24 -25    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.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SunJavah.java	4 Feb 2005 08:13:47 -0000	1.1.2.1
  +++ SunJavah.java	2 May 2005 15:03:17 -0000	1.1.2.2
  @@ -16,12 +16,15 @@
    */
   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;
   import org.apache.tools.ant.types.Path;
  -import org.apache.tools.ant.util.JavaEnvUtils;
  +
   
   /**
    * Adapter to com.sun.tools.javah.oldjavah.Main or com.sun.tools.javah.Main.
  @@ -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;
       }
   
  @@ -77,25 +83,18 @@
               cmd.createArgument().setPath(javah.getClasspath());
           }
   
  -        // JDK1.1 is rather simpler than JDK1.2
  -        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
  -            if (javah.getVerbose()) {
  -                cmd.createArgument().setValue("-v");
  -            }
  -        } else {
  -            if (javah.getVerbose()) {
  -                cmd.createArgument().setValue("-verbose");
  -            }
  -            if (javah.getOld()) {
  -                cmd.createArgument().setValue("-old");
  -            }
  -            if (javah.getForce()) {
  -                cmd.createArgument().setValue("-force");
  -            }
  -            if (javah.getStubs() && !javah.getOld()) {
  -                throw new BuildException("stubs only available in old mode.", 
  -                                         javah.getLocation());
  -            }
  +        if (javah.getVerbose()) {
  +            cmd.createArgument().setValue("-verbose");
  +        }
  +        if (javah.getOld()) {
  +            cmd.createArgument().setValue("-old");
  +        }
  +        if (javah.getForce()) {
  +            cmd.createArgument().setValue("-force");
  +        }
  +        if (javah.getStubs() && !javah.getOld()) {
  +            throw new BuildException("stubs only available in old mode.", 
  +                                     javah.getLocation());
           }
   
           if (javah.getStubs()) {
  
  
  

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


Mime
View raw message