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/native2ascii SunNative2Ascii.java
Date Tue, 01 Feb 2005 07:50:21 GMT
bodewig     2005/01/31 23:50:21

  Modified:    .        build.xml
               src/main/org/apache/tools/ant/taskdefs/optional/native2ascii
                        SunNative2Ascii.java
  Log:
  Use refelection to completely decouple Native2Ascii from Sun's implementation
  
  Revision  Changes    Path
  1.452     +0 -1      ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ant/build.xml,v
  retrieving revision 1.451
  retrieving revision 1.452
  diff -u -r1.451 -r1.452
  --- build.xml	31 Jan 2005 11:48:24 -0000	1.451
  +++ build.xml	1 Feb 2005 07:50:21 -0000	1.452
  @@ -163,7 +163,6 @@
     <selector id="needs.sun.tools">
       <or>
         <filename name="${optional.package}/Javah*"/>
  -      <filename name="${optional.package}/native2ascii/Sun*"/>
       </or>
     </selector>
   
  
  
  
  1.2       +20 -2     ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/SunNative2Ascii.java
  
  Index: SunNative2Ascii.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/SunNative2Ascii.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SunNative2Ascii.java	31 Jan 2005 11:48:25 -0000	1.1
  +++ SunNative2Ascii.java	1 Feb 2005 07:50:21 -0000	1.2
  @@ -16,6 +16,7 @@
    */
   package org.apache.tools.ant.taskdefs.optional.native2ascii;
   
  +import java.lang.reflect.Method;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.ProjectComponent;
   import org.apache.tools.ant.taskdefs.optional.Native2Ascii;
  @@ -43,7 +44,24 @@
   
       protected boolean run(Commandline cmd, ProjectComponent log)
           throws BuildException {
  -        sun.tools.native2ascii.Main n2a = new sun.tools.native2ascii.Main();
  -        return n2a.convert(cmd.getArguments());
  +        try {
  +            Class n2aMain = Class.forName("sun.tools.native2ascii.Main");
  +            Class[] param = new Class[] {String[].class};
  +            Method convert = n2aMain.getMethod("convert", param);
  +            if (convert == null) {
  +                throw new BuildException("Could not find convert() method in "
  +                                         + "sun.tools.native2ascii.Main");
  +            }
  +            Object o = n2aMain.newInstance();
  +            return ((Boolean) convert.invoke(o, 
  +                                             new Object[] {cmd.getArguments()})
  +                    ).booleanValue();
  +        } catch (BuildException ex) {
  +            //rethrow
  +            throw ex;
  +        } catch (Exception ex) {
  +            //wrap
  +           throw new BuildException("Error starting Sun's native2ascii: ", ex);
  +        }
       }
   }
  \ 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


Mime
View raw message