From 29fface4fb93fb33b33c86124a168c04779271c0 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Wed, 23 Aug 2006 12:36:25 +0000 Subject: [PATCH] bug ID#38732 , rmic task doesn't work with -Xnew and JDK 6.0 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-ffa450edef68 --- WHATSNEW | 9 ++++-- docs/manual/CoreTasks/rmic.html | 13 +++++--- src/etc/testcases/taskdefs/rmic/rmic.xml | 23 ++++++++++++-- .../ant/taskdefs/rmic/ForkingSunRmic.java | 13 ++++++-- .../ant/taskdefs/rmic/RmicAdapterFactory.java | 31 ++++++++++++------- .../tools/ant/taskdefs/RmicAdvancedTest.java | 19 +++++++++++- 6 files changed, 85 insertions(+), 23 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 7bb216fa4..434c6c0de 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -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 API allowed creation of directories in file-only archives; a habitual offender was the subclassed , which included META-INF/ in the destination file regardless of whether filesonly was set to true. + +* 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. diff --git a/docs/manual/CoreTasks/rmic.html b/docs/manual/CoreTasks/rmic.html index c2da73f86..a97b31dfb 100644 --- a/docs/manual/CoreTasks/rmic.html +++ b/docs/manual/CoreTasks/rmic.html @@ -40,8 +40,11 @@ attribute.
  • sun (the standard compiler of the JDK)
  • kaffe (the standard compiler of Kaffe)
  • weblogic
  • -
  • forking - the sun compiler forked into a separate process
  • -
  • "" (empty string). This has the same behaviour as not setting the compiler attribute. +
  • forking - the sun compiler forked into a separate process (since Ant 1.7)
  • +
  • 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
  • +
  • "" (empty string). This has the same behaviour as not setting the compiler attribute. First the value of build.rmic 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.

    stubversion 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.
    + Since Ant1.7, if you do not specify a version, and do not ask + for iiop or idl files, "compat" is selected. No, default="compat" @@ -245,7 +250,7 @@ files below ${build}/classes whose classname starts with ${build}/classes.


    -

    Copyright © 2000-2005 The Apache Software Foundation. All rights +

    Copyright © 2000-2006 The Apache Software Foundation. All rights Reserved.

    diff --git a/src/etc/testcases/taskdefs/rmic/rmic.xml b/src/etc/testcases/taskdefs/rmic/rmic.xml index 25b5a971e..149f3e777 100644 --- a/src/etc/testcases/taskdefs/rmic/rmic.xml +++ b/src/etc/testcases/taskdefs/rmic/rmic.xml @@ -108,6 +108,12 @@ + + + + + + @@ -173,6 +179,13 @@ /> + + + + + - + - + + + + + + + diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java index 1e3878f6a..5b1f497fe 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java @@ -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; + } } diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java index ad8365fe2..d6628a067 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java @@ -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); } } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java b/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java index 3490d6677..535a4652d 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java @@ -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. *