Browse Source

Bug 41349: rmic should strip out -J compiler args when not forking

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@495229 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 18 years ago
parent
commit
e52b987d30
6 changed files with 99 additions and 3 deletions
  1. +4
    -0
      WHATSNEW
  2. +16
    -0
      src/etc/testcases/taskdefs/rmic/rmic.xml
  3. +41
    -1
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  4. +10
    -0
      src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
  5. +10
    -0
      src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
  6. +18
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java

+ 4
- 0
WHATSNEW View File

@@ -34,6 +34,10 @@ Fixed bugs:
* 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:
--------------



+ 16
- 0
src/etc/testcases/taskdefs/rmic/rmic.xml View File

@@ -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"
@@ -166,6 +174,14 @@
/>
</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">
<base-rmic
compiler="forking"


+ 41
- 1
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -21,6 +21,9 @@ package org.apache.tools.ant.taskdefs.rmic;
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,12 +252,49 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
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
* &quot;niceSourceList&quot;


+ 10
- 0
src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java View File

@@ -100,4 +100,14 @@ public class SunRmic extends DefaultRmicAdapter {
}
}
}


/**
* 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);
}
}

+ 10
- 0
src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java View File

@@ -106,4 +106,14 @@ public class WLRmic extends DefaultRmicAdapter {
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);
}
}

+ 18
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java View File

@@ -65,11 +65,20 @@ public class RmicAdvancedTest extends BuildFileTest {
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,12 +87,19 @@ public class RmicAdvancedTest extends BuildFileTest {
}

/**
* 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");
}

/**
* test the forking compiler
*/


Loading…
Cancel
Save