ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r495229 - in /ant/core/trunk: ./ src/etc/testcases/taskdefs/rmic/ src/main/org/apache/tools/ant/taskdefs/rmic/ src/tests/junit/org/apache/tools/ant/taskdefs/
Date Thu, 11 Jan 2007 14:02:51 GMT
Author: stevel
Date: Thu Jan 11 06:02:50 2007
New Revision: 495229

URL: http://svn.apache.org/viewvc?view=rev&rev=495229
Log:
Bug 41349: rmic should strip out -J compiler args when not forking

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/etc/testcases/taskdefs/rmic/rmic.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=495229&r1=495228&r2=495229
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Jan 11 06:02:50 2007
@@ -34,6 +34,10 @@
 * Regression: NPE was thrown when using <pathconvert> against a
   (third-party instantiated) fileset with null Project reference.
 
+* Strip out all -J arguments to non forking rmic adapters, specifically
+  the Sun and Weblogic compilers.
+  Bug report 41349  
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/etc/testcases/taskdefs/rmic/rmic.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/rmic/rmic.xml?view=diff&rev=495229&r1=495228&r2=495229
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/rmic/rmic.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/rmic/rmic.xml Thu Jan 11 06:02:50 2007
@@ -153,6 +153,14 @@
     <assertBaseCompiled/>
   </target>
 
+
+  <target name="testRmicJArg" if="rmic.present" depends="init">
+    <base-rmic compiler="sun">
+      <compilerarg value="-J-mx256m" />
+    </base-rmic>
+    <assertBaseCompiled/>
+  </target>
+
   <target name="testKaffe" if="kaffe.present" depends="init">
     <base-rmic
       compiler="kaffe"
@@ -164,6 +172,14 @@
     <base-rmic
       compiler="weblogic"
       />
+  </target>
+
+  <target name="testWlrmicJArg" if="wlrmic.present" depends="init">
+    <base-rmic
+        compiler="weblogic"
+        >
+      <compilerarg value="-J-mx256m" />
+    </base-rmic>
   </target>
 
   <target name="testForking" if="rmic.present" depends="init">

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java?view=diff&rev=495229&r1=495228&r2=495229
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java Thu
Jan 11 06:02:50 2007
@@ -21,6 +21,9 @@
 import java.io.File;
 import java.util.Random;
 import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
+
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Rmic;
 import org.apache.tools.ant.types.Commandline;
@@ -249,11 +252,48 @@
             cmd.createArgument().setValue("-g");
         }
 
-        cmd.addArguments(attributes.getCurrentCompilerArgs());
+        String[] compilerArgs = attributes.getCurrentCompilerArgs();
+        compilerArgs = preprocessCompilerArgs(compilerArgs);
+        cmd.addArguments(compilerArgs);
 
         logAndAddFilesToCompile(cmd);
         return cmd;
      }
+
+    /**
+     * Preprocess the compiler arguments in any way you see fit.
+     * This is to allow compiler adapters to validate or filter the arguments.
+     * The base implementation returns the original compiler arguments unchanged.
+     * @param compilerArgs the original compiler arguments
+     * @return the filtered set.
+     */
+    protected String[] preprocessCompilerArgs(String[] compilerArgs) {
+        return compilerArgs;
+    }
+
+
+    /**
+     * Strip out all -J args from the command list. Invoke this from
+     * {@link #preprocessCompilerArgs(String[])} if you have a non-forking
+     * compiler. 
+     * @param compilerArgs the original compiler arguments
+     * @return the filtered set.
+     */
+    protected String[] filterJvmCompilerArgs(String[] compilerArgs) {
+        int len = compilerArgs.length;
+        List args=new ArrayList(len);
+        for(int i=0;i<len;i++) {
+            String arg=compilerArgs[i];
+            if(!arg.startsWith("-J")) {
+                args.add(arg);
+            } else {
+                attributes.log("Dropping "+arg+" from compiler arguments");
+            }
+        }
+        int count=args.size();
+        return (String[]) args.toArray(new String[count]);
+    }
+
 
     /**
      * Logs the compilation parameters, adds the files to compile and logs the

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java?view=diff&rev=495229&r1=495228&r2=495229
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java Thu Jan 11 06:02:50
2007
@@ -100,4 +100,14 @@
             }
         }
     }
+
+
+    /**
+     * Strip out all -J args from the command list.
+     * @param compilerArgs the original compiler arguments
+     * @return the filtered set.
+     */
+    protected String[] preprocessCompilerArgs(String[] compilerArgs) {
+        return filterJvmCompilerArgs(compilerArgs);
+    }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java?view=diff&rev=495229&r1=495228&r2=495229
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java Thu Jan 11 06:02:50
2007
@@ -106,4 +106,14 @@
     public String getSkelClassSuffix() {
         return WL_RMI_SKEL_SUFFIX;
     }
+
+    /**
+     * Strip out all -J args from the command list.
+     *
+     * @param compilerArgs the original compiler arguments
+     * @return the filtered set.
+     */
+    protected String[] preprocessCompilerArgs(String[] compilerArgs) {
+        return filterJvmCompilerArgs(compilerArgs);
+    }    
 }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java?view=diff&rev=495229&r1=495228&r2=495229
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java Thu
Jan 11 06:02:50 2007
@@ -65,11 +65,20 @@
         executeTarget("testEmpty");
     }
     /**
-     * A unit test for JUnit
+     * test sun's rmic compiler
      */
     public void testRmic() throws Exception {
         executeTarget("testRmic");
     }
+
+    /**
+     * test sun's rmic compiler strips
+     * out -J arguments when not forking
+     */
+    public void testRmicJArg() throws Exception {
+        executeTarget("testRmicJArg");
+    }
+
     /**
      * A unit test for JUnit
      */
@@ -78,10 +87,17 @@
     }
 
     /**
-     * A unit test for JUnit
+     * test weblogic
      */
     public void testWlrmic() throws Exception {
         executeTarget("testWlrmic");
+    }
+
+    /**
+     *  test weblogic's stripping of -J args
+     */
+    public void testWlrmicJArg() throws Exception {
+        executeTarget("testWlrmicJArg");
     }
 
     /**



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


Mime
View raw message