Fixed by writing a new adapter, xnew, that extends the forking adapter and sets the -Xnew argument. Tests supplied, though the old test, the one that would fail on java1.6, is still there. Also made the name matching code of rmic locale-independent. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@434029 13f79535-47bb-0310-9956-ffa450edef68master
@@ -71,6 +71,8 @@ Changes that could break older environments: | |||
IE (Windows) or Gnome2 (Unix/Linux) proxy settings. This may break any build | |||
file that somehow relied on content outside the firewall being unreachable: | |||
use the -noproxy command-line option to disable this new feature. | |||
Note that the Java1.5 proxy configuration system still does not appear to work | |||
reliably on Windows or Linux. | |||
* A bug in SQLExec would prevent the execution of trailing, | |||
non-semicolon-delimited statements. Bugzilla Report 37764. | |||
@@ -97,7 +99,7 @@ Changes that could break older environments: | |||
* Ant launcher program prints errors to stderr, and exits with a 2 exit code | |||
value if, for any reason, it cannot actually start Ant proper. This will only | |||
affect programs/scripts that called the launcher and which did not want to | |||
receive an error if ant itself would not start | |||
receive an error if Ant itself would not start | |||
Fixed bugs: | |||
----------- | |||
@@ -264,6 +266,9 @@ Fixed bugs: | |||
* The <zip> API allowed creation of directories in file-only archives; a | |||
habitual offender was the subclassed <jar>, which included META-INF/ in | |||
the destination file regardless of whether filesonly was set to true. | |||
* <rmic> has a new adapter, xnew, to use the -XNew back end on java1.5+. | |||
By forking rmic, this works on java1.6+. Bugzilla report 38732. | |||
Other changes: | |||
-------------- | |||
@@ -271,7 +276,7 @@ Other changes: | |||
* InputHandler implementations may now call InputRequest.getDefaultValue() | |||
if they wish. The default handler uses this also. Bugzilla report 28621. | |||
* Took in bugzilla report 39320. | |||
* Took in bugzilla report 39320, "Simple code cleanups" | |||
* Improve compatibility with GNU Classpath and java versions prior to 1.5. Bugzilla 39027. | |||
@@ -40,8 +40,11 @@ attribute. | |||
<li>sun (the standard compiler of the JDK)</li> | |||
<li>kaffe (the standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> | |||
<li>weblogic</li> | |||
<li>forking - the sun compiler forked into a separate process</li> | |||
<li> "" (empty string). This has the same behaviour as not setting the compiler attribute. | |||
<li>forking - the sun compiler forked into a separate process (since Ant 1.7)</li> | |||
<li>xnew - the sun compiler forked into a separate process, | |||
with the -Xnew option (since Ant 1.7). | |||
This is the most reliable way to use -Xnew</li> | |||
<li> "" (empty string). This has the same behaviour as not setting the compiler attribute. | |||
First the value of <tt>build.rmic</tt> is used if defined, and if not, the default | |||
for the platform is chosen. If build.rmic is set to this, you get the default. | |||
@@ -83,7 +86,9 @@ please consult miniRMI's documentation to learn how to use it.</p> | |||
<td valign="top">stubversion</td> | |||
<td valign="top">Specify the JDK version for the generated stub code. | |||
Specify "1.1" to pass the "-v1.1" option to rmic, | |||
"1.2" for -v12, compat for -vcompat. | |||
"1.2" for -v12, compat for -vcompat. <br> | |||
Since Ant1.7, if you do not specify a version, and do not ask | |||
for iiop or idl files, "compat" is selected. | |||
</td> | |||
<td align="center" valign="top">No, default="compat"</td> | |||
@@ -245,7 +250,7 @@ files below <code>${build}/classes</code> whose classname starts with | |||
<code>${build}/classes</code>.</p> | |||
<hr> | |||
<p align="center">Copyright © 2000-2005 The Apache Software Foundation. All rights | |||
<p align="center">Copyright © 2000-2006 The Apache Software Foundation. All rights | |||
Reserved.</p> | |||
</body> | |||
@@ -108,6 +108,12 @@ | |||
<available property="kaffe.present" classname="jkaffe.rmi.rmic.RMIC"/> | |||
<available property="rmic.present" classname="sun.rmi.rmic.Main"/> | |||
<available property="wlrmic.present" classname="weblogic.rmic"/> | |||
<condition property="rmic5.present"> | |||
<and> | |||
<isset property="rmic.present"/> | |||
<available classname="java.net.Proxy"/> | |||
</and> | |||
</condition> | |||
<condition property="rmic6.present"> | |||
<and> | |||
<isset property="rmic.present"/> | |||
@@ -173,6 +179,13 @@ | |||
/> | |||
</target> | |||
<target name="testExplicitClass" if="rmic.present" depends="init"> | |||
<base-rmic | |||
compiler="org.apache.tools.ant.taskdefs.rmic.SunRmic" | |||
/> | |||
<assertBaseCompiled/> | |||
</target> | |||
<target name="testWrongClass" if="rmic.present" depends="init"> | |||
<base-rmic | |||
compiler="org.apache.tools.ant.BuildException" | |||
@@ -249,20 +262,26 @@ | |||
<assertBaseCompiled/> | |||
</target> | |||
<target name="testXnew" if="rmic6.present" depends="init"> | |||
<target name="testXnew" if="rmic5.present" depends="init"> | |||
<base-rmic compiler="sun"> | |||
<compilerarg value="-Xnew"/> | |||
</base-rmic> | |||
<assertBaseCompiled/> | |||
</target> | |||
<target name="testXnewForked" if="rmic6.present" depends="init"> | |||
<target name="testXnewForked" if="rmic5.present" depends="init"> | |||
<base-rmic compiler="forking"> | |||
<compilerarg value="-Xnew"/> | |||
</base-rmic> | |||
<assertBaseCompiled/> | |||
</target> | |||
<target name="testXnewCompiler" if="rmic5.present" depends="init"> | |||
<base-rmic compiler="xnew"> | |||
</base-rmic> | |||
<assertBaseCompiled/> | |||
</target> | |||
<target name="testIDL" depends="init"> | |||
<base-rmic compiler="default" idl="true"/> | |||
<assertFileCreated file="RemoteTimestamp.idl"/> | |||
@@ -34,6 +34,7 @@ import java.io.IOException; | |||
* compiler you can have multiple copies compiling different bits of your project | |||
* at the same time. Which, on a multi-cpu system results in significant speedups. | |||
* | |||
* Also, Java1.6 behaves oddly with -XNew, so we switch it on here if needed. | |||
* @since ant1.7 | |||
*/ | |||
public class ForkingSunRmic extends DefaultRmicAdapter { | |||
@@ -53,7 +54,7 @@ public class ForkingSunRmic extends DefaultRmicAdapter { | |||
Commandline cmd = setupRmicCommand(); | |||
Project project = owner.getProject(); | |||
//rely on RMIC being on the path | |||
cmd.setExecutable(JavaEnvUtils.getJdkExecutable(SunRmic.RMIC_EXECUTABLE)); | |||
cmd.setExecutable(JavaEnvUtils.getJdkExecutable(getExecutableName())); | |||
//set up the args | |||
String[] args = cmd.getCommandline(); | |||
@@ -68,8 +69,16 @@ public class ForkingSunRmic extends DefaultRmicAdapter { | |||
exe.execute(); | |||
return !exe.isFailure(); | |||
} catch (IOException exception) { | |||
throw new BuildException("Error running " + SunRmic.RMIC_EXECUTABLE | |||
throw new BuildException("Error running " + getExecutableName() | |||
+ " -maybe it is not on the path", exception); | |||
} | |||
} | |||
/** | |||
* Override point. | |||
* @return | |||
*/ | |||
protected String getExecutableName() { | |||
return SunRmic.RMIC_EXECUTABLE; | |||
} | |||
} |
@@ -19,7 +19,11 @@ package org.apache.tools.ant.taskdefs.rmic; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.taskdefs.Rmic; | |||
import org.apache.tools.ant.util.ClasspathUtils; | |||
import org.apache.tools.ant.util.JavaEnvUtils; | |||
import java.util.Locale; | |||
/** | |||
@@ -63,24 +67,27 @@ public final class RmicAdapterFactory { | |||
*/ | |||
public static RmicAdapter getRmic(String rmicType, Task task) | |||
throws BuildException { | |||
//convert to lower case in the English locale, | |||
String compiler = rmicType.toLowerCase(Locale.ENGLISH); | |||
//handle default specially. | |||
if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.length() == 0) { | |||
String adapter = KaffeRmic.isAvailable() | |||
//handle default specially by choosing the sun or kaffe compiler | |||
if (DEFAULT_COMPILER.equals(compiler) || compiler.length() == 0) { | |||
compiler = KaffeRmic.isAvailable() | |||
? KaffeRmic.COMPILER_NAME | |||
: SunRmic.COMPILER_NAME; | |||
return getRmic(adapter, task); | |||
} | |||
if (SunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { | |||
if (SunRmic.COMPILER_NAME.equals(compiler)) { | |||
return new SunRmic(); | |||
} else if (KaffeRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { | |||
} else if (KaffeRmic.COMPILER_NAME.equals(compiler)) { | |||
return new KaffeRmic(); | |||
} else if (WLRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { | |||
} else if (WLRmic.COMPILER_NAME.equals(compiler)) { | |||
return new WLRmic(); | |||
} else if (ForkingSunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { | |||
} else if (ForkingSunRmic.COMPILER_NAME.equals(compiler)) { | |||
return new ForkingSunRmic(); | |||
} else if (XNewRmic.COMPILER_NAME.equals(compiler)) { | |||
return new XNewRmic(); | |||
} | |||
//no match? ask for the non-lower-cased type | |||
return resolveClassName(rmicType); | |||
} | |||
@@ -93,8 +100,8 @@ public final class RmicAdapterFactory { | |||
* isn't an instance of RmicAdapter. | |||
*/ | |||
private static RmicAdapter resolveClassName(String className) | |||
throws BuildException { | |||
return (RmicAdapter) ClasspathUtils.newInstance(className, | |||
RmicAdapterFactory.class.getClassLoader(), RmicAdapter.class); | |||
throws BuildException { | |||
return (RmicAdapter) ClasspathUtils.newInstance(className, | |||
RmicAdapterFactory.class.getClassLoader(), RmicAdapter.class); | |||
} | |||
} |
@@ -38,7 +38,8 @@ public class RmicAdvancedTest extends BuildFileTest { | |||
/** | |||
* The JUnit setup method | |||
*/ | |||
public void setUp() { | |||
public void setUp() throws Exception { | |||
super.setUp(); | |||
configureProject(TASKDEFS_DIR + "rmic.xml"); | |||
} | |||
@@ -112,6 +113,13 @@ public class RmicAdvancedTest extends BuildFileTest { | |||
RmicAdapterFactory.ERROR_UNKNOWN_COMPILER); | |||
} | |||
/** | |||
* load an adapter by name | |||
*/ | |||
public void testExplicitClass() throws Exception { | |||
executeTarget("testExplicitClass"); | |||
} | |||
/** | |||
* A unit test for JUnit | |||
*/ | |||
@@ -212,6 +220,15 @@ public class RmicAdvancedTest extends BuildFileTest { | |||
executeTarget("testXnewForked"); | |||
} | |||
/** | |||
* test that runs the new xnew compiler adapter. | |||
* | |||
* @throws Exception | |||
*/ | |||
public void testXnewCompiler() throws Exception { | |||
executeTarget("testXnewCompiler"); | |||
} | |||
/** | |||
* test that verifies that IDL compiles. | |||
* | |||