diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic')
8 files changed, 0 insertions, 1191 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java deleted file mode 100644 index bb2cfaab..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.rmic; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.Vector; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Rmic; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.StringUtils; - -/** - * This is the default implementation for the RmicAdapter interface. - * Currently, this is a cut-and-paste of the original rmic task and - * DefaultCompilerAdapter. - * - * @since Ant 1.4 - */ -public abstract class DefaultRmicAdapter implements RmicAdapter { - - private Rmic attributes; - private FileNameMapper mapper; - private static final Random RAND = new Random(); - /** suffix denoting a stub file: {@value} */ - public static final String RMI_STUB_SUFFIX = "_Stub"; - /** suffix denoting a skel file: {@value} */ - public static final String RMI_SKEL_SUFFIX = "_Skel"; - /** suffix denoting a tie file: {@value} */ - public static final String RMI_TIE_SUFFIX = "_Tie"; - /** arg for compat: {@value} */ - public static final String STUB_COMPAT = "-vcompat"; - /** arg for 1.1: {@value} */ - public static final String STUB_1_1 = "-v1.1"; - /** arg for 1.2: {@value} */ - public static final String STUB_1_2 = "-v1.2"; - - /** - * option for stub 1.1 in the rmic task: {@value} - */ - public static final String STUB_OPTION_1_1 = "1.1"; - /** - * option for stub 1.2 in the rmic task: {@value} - */ - public static final String STUB_OPTION_1_2 = "1.2"; - /** - * option for stub compat in the rmic task: {@value} - */ - public static final String STUB_OPTION_COMPAT = "compat"; - - /** - * Default constructor - */ - public DefaultRmicAdapter() { - } - - /** - * Sets Rmic attributes - * @param attributes the rmic attributes - */ - public void setRmic(final Rmic attributes) { - this.attributes = attributes; - mapper = new RmicFileNameMapper(); - } - - /** - * Get the Rmic attributes - * @return the attributes as a Rmic taskdef - */ - public Rmic getRmic() { - return attributes; - } - - /** - * Gets the stub class suffix - * @return the stub suffix "_Stub" - */ - protected String getStubClassSuffix() { - return RMI_STUB_SUFFIX; - } - - /** - * Gets the skeleton class suffix - * @return the skeleton suffix "_Skel" - */ - protected String getSkelClassSuffix() { - return RMI_SKEL_SUFFIX; - } - - /** - * Gets the tie class suffix - * @return the tie suffix "_Tie" - */ - protected String getTieClassSuffix() { - return RMI_TIE_SUFFIX; - } - - /** - * This implementation returns a mapper that may return up to two - * file names. - * - * <ul> - * <li>for JRMP it will return *_getStubClassSuffix (and - * *_getSkelClassSuffix if JDK 1.1 is used)</li> - * - * <li>for IDL it will return a random name, causing <rmic> to - * always recompile.</li> - * - * <li>for IIOP it will return _*_getStubClassSuffix for - * interfaces and _*_getStubClassSuffix for non-interfaces (and - * determine the interface and create _*_Stub from that).</li> - * </ul> - * @return a <code>FileNameMapper</code> - */ - public FileNameMapper getMapper() { - return mapper; - } - - /** - * Gets the CLASSPATH this rmic process will use. - * @return the classpath - */ - public Path getClasspath() { - return getCompileClasspath(); - } - - /** - * Builds the compilation classpath. - * @return the classpath - */ - protected Path getCompileClasspath() { - Path classpath = new Path(attributes.getProject()); - // add dest dir to classpath so that previously compiled and - // untouched classes are on classpath - classpath.setLocation(attributes.getBase()); - - // Combine the build classpath with the system classpath, in an - // order determined by the value of build.sysclasspath - - Path cp = attributes.getClasspath(); - if (cp == null) { - cp = new Path(attributes.getProject()); - } - if (attributes.getIncludeantruntime()) { - classpath.addExisting(cp.concatSystemClasspath("last")); - } else { - classpath.addExisting(cp.concatSystemClasspath("ignore")); - } - - if (attributes.getIncludejavaruntime()) { - classpath.addJavaRuntime(); - } - return classpath; - } - - /** - * Setup rmic argument for rmic. - * @return the command line - */ - protected Commandline setupRmicCommand() { - return setupRmicCommand(null); - } - - /** - * Setup rmic argument for rmic. - * @param options additional parameters needed by a specific - * implementation. - * @return the command line - */ - protected Commandline setupRmicCommand(String[] options) { - Commandline cmd = new Commandline(); - - if (options != null) { - for (int i = 0; i < options.length; i++) { - cmd.createArgument().setValue(options[i]); - } - } - - Path classpath = getCompileClasspath(); - - cmd.createArgument().setValue("-d"); - cmd.createArgument().setFile(attributes.getOutputDir()); - - if (attributes.getExtdirs() != null) { - cmd.createArgument().setValue("-extdirs"); - cmd.createArgument().setPath(attributes.getExtdirs()); - } - - cmd.createArgument().setValue("-classpath"); - cmd.createArgument().setPath(classpath); - String stubOption = addStubVersionOptions(); - if (stubOption != null) { - //set the non-null stubOption - cmd.createArgument().setValue(stubOption); - } - - - if (null != attributes.getSourceBase()) { - cmd.createArgument().setValue("-keepgenerated"); - } - - if (attributes.getIiop()) { - attributes.log("IIOP has been turned on.", Project.MSG_INFO); - cmd.createArgument().setValue("-iiop"); - if (attributes.getIiopopts() != null) { - attributes.log("IIOP Options: " + attributes.getIiopopts(), - Project.MSG_INFO); - cmd.createArgument().setValue(attributes.getIiopopts()); - } - } - - if (attributes.getIdl()) { - cmd.createArgument().setValue("-idl"); - attributes.log("IDL has been turned on.", Project.MSG_INFO); - if (attributes.getIdlopts() != null) { - cmd.createArgument().setValue(attributes.getIdlopts()); - attributes.log("IDL Options: " + attributes.getIdlopts(), - Project.MSG_INFO); - } - } - - if (attributes.getDebug()) { - cmd.createArgument().setValue("-g"); - } - - String[] compilerArgs = attributes.getCurrentCompilerArgs(); - compilerArgs = preprocessCompilerArgs(compilerArgs); - cmd.addArguments(compilerArgs); - - logAndAddFilesToCompile(cmd); - return cmd; - } - - /** - * This is an override point; get the stub version off the rmic command and - * translate that into a compiler-specific argument - * @return a string to use for the stub version; can be null - * @since Ant1.7.1 - */ - protected String addStubVersionOptions() { - //handle the many different stub options. - String stubVersion = attributes.getStubVersion(); - //default is compatibility - String stubOption = null; - if (null != stubVersion) { - if (STUB_OPTION_1_1.equals(stubVersion)) { - stubOption = STUB_1_1; - } else if (STUB_OPTION_1_2.equals(stubVersion)) { - stubOption = STUB_1_2; - } else if (STUB_OPTION_COMPAT.equals(stubVersion)) { - stubOption = STUB_COMPAT; - } else { - //anything else - attributes.log("Unknown stub option " + stubVersion); - //do nothing with the value? or go -v+stubVersion?? - } - } - //for java1.5+, we generate compatible stubs, that is, unless - //the caller asked for IDL or IIOP support. - if (stubOption == null - && !attributes.getIiop() - && !attributes.getIdl()) { - stubOption = STUB_COMPAT; - } - return stubOption; - } - - /** - * 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 - * "niceSourceList" - * @param cmd the commandline args - */ - protected void logAndAddFilesToCompile(Commandline cmd) { - Vector compileList = attributes.getCompileList(); - - attributes.log("Compilation " + cmd.describeArguments(), - Project.MSG_VERBOSE); - - StringBuffer niceSourceList = new StringBuffer("File"); - int cListSize = compileList.size(); - if (cListSize != 1) { - niceSourceList.append("s"); - } - niceSourceList.append(" to be compiled:"); - - for (int i = 0; i < cListSize; i++) { - String arg = (String) compileList.elementAt(i); - cmd.createArgument().setValue(arg); - niceSourceList.append(" "); - niceSourceList.append(arg); - } - - attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE); - } - - /** - * Mapper that may return up to two file names. - * - * <ul> - * <li>for JRMP it will return *_getStubClassSuffix (and - * *_getSkelClassSuffix if JDK 1.1 is used)</li> - * - * <li>for IDL it will return a random name, causing <rmic> to - * always recompile.</li> - * - * <li>for IIOP it will return _*_getStubClassSuffix for - * interfaces and _*_getStubClassSuffix for non-interfaces (and - * determine the interface and create _*_Stub from that).</li> - * </ul> - */ - private class RmicFileNameMapper implements FileNameMapper { - - RmicFileNameMapper() { - } - - /** - * Empty implementation. - */ - public void setFrom(String s) { - } - /** - * Empty implementation. - */ - public void setTo(String s) { - } - - public String[] mapFileName(String name) { - if (name == null - || !name.endsWith(".class") - || name.endsWith(getStubClassSuffix() + ".class") - || name.endsWith(getSkelClassSuffix() + ".class") - || name.endsWith(getTieClassSuffix() + ".class")) { - // Not a .class file or the one we'd generate - return null; - } - - // we know that name.endsWith(".class") - String base = StringUtils.removeSuffix(name, ".class"); - - String classname = base.replace(File.separatorChar, '.'); - if (attributes.getVerify() - && !attributes.isValidRmiRemote(classname)) { - return null; - } - - /* - * fallback in case we have trouble loading the class or - * don't know how to handle it (there is no easy way to - * know what IDL mode would generate. - * - * This is supposed to make Ant always recompile the - * class, as a file of that name should not exist. - */ - String[] target = new String[] {name + ".tmp." + RAND.nextLong()}; - - if (!attributes.getIiop() && !attributes.getIdl()) { - // JRMP with simple naming convention - if (STUB_OPTION_1_2.equals(attributes.getStubVersion())) { - target = new String[] { - base + getStubClassSuffix() + ".class" - }; - } else { - target = new String[] { - base + getStubClassSuffix() + ".class", - base + getSkelClassSuffix() + ".class", - }; - } - } else if (!attributes.getIdl()) { - int lastSlash = base.lastIndexOf(File.separatorChar); - - String dirname = ""; - /* - * I know, this is not necessary, but I prefer it explicit (SB) - */ - int index = -1; - if (lastSlash == -1) { - // no package - index = 0; - } else { - index = lastSlash + 1; - dirname = base.substring(0, index); - } - - String filename = base.substring(index); - - try { - Class c = attributes.getLoader().loadClass(classname); - - if (c.isInterface()) { - // only stub, no tie - target = new String[] { - dirname + "_" + filename + getStubClassSuffix() - + ".class" - }; - } else { - /* - * stub is derived from implementation, - * tie from interface name. - */ - Class interf = attributes.getRemoteInterface(c); - String iName = interf.getName(); - String iDir = ""; - int iIndex = -1; - int lastDot = iName.lastIndexOf("."); - if (lastDot == -1) { - // no package - iIndex = 0; - } else { - iIndex = lastDot + 1; - iDir = iName.substring(0, iIndex); - iDir = iDir.replace('.', File.separatorChar); - } - - target = new String[] { - dirname + "_" + filename + getTieClassSuffix() - + ".class", - iDir + "_" + iName.substring(iIndex) - + getStubClassSuffix() + ".class" - }; - } - } catch (ClassNotFoundException e) { - attributes.log("Unable to verify class " + classname - + ". It could not be found.", - Project.MSG_WARN); - } catch (NoClassDefFoundError e) { - attributes.log("Unable to verify class " + classname - + ". It is not defined.", Project.MSG_WARN); - } catch (Throwable t) { - attributes.log("Unable to verify class " + classname - + ". Loading caused Exception: " - + t.getMessage(), Project.MSG_WARN); - } - } - return target; - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java deleted file mode 100644 index 81bd7971..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -package org.apache.tools.ant.taskdefs.rmic; - -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Execute; -import org.apache.tools.ant.taskdefs.LogStreamHandler; -import org.apache.tools.ant.taskdefs.Rmic; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * This is an extension of the sun rmic compiler, which forks rather than - * executes it inline. Why so? Because rmic is dog slow, but if you fork the - * 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 { - - /** - * the name of this adapter for users to select - */ - public static final String COMPILER_NAME = "forking"; - - /** - * exec by creating a new command - * @return true if the command ran successfully - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - Rmic owner = getRmic(); - Commandline cmd = setupRmicCommand(); - Project project = owner.getProject(); - String executable = owner.getExecutable(); - if (executable == null) { - // no explicitly specified executable - // rely on RMIC being on the path - executable = JavaEnvUtils.getJdkExecutable(getExecutableName()); - } - cmd.setExecutable(executable); - - //set up the args - String[] args = cmd.getCommandline(); - - try { - Execute exe = new Execute(new LogStreamHandler(owner, - Project.MSG_INFO, - Project.MSG_WARN)); - exe.setAntRun(project); - exe.setWorkingDirectory(project.getBaseDir()); - exe.setCommandline(args); - exe.execute(); - return !exe.isFailure(); - } catch (IOException exception) { - throw new BuildException("Error running " + getExecutableName() - + " -maybe it is not on the path", exception); - } - } - - /** - * Override point. - * @return the executable name. - */ - protected String getExecutableName() { - return SunRmic.RMIC_EXECUTABLE; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java deleted file mode 100644 index 2108a68b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.rmic; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.ExecuteJava; -import org.apache.tools.ant.types.Commandline; - -/** - * The implementation of the rmic for Kaffe - * - * @since Ant 1.4 - */ -public class KaffeRmic extends DefaultRmicAdapter { - // sorted by newest Kaffe version first - private static final String[] RMIC_CLASSNAMES = new String[] { - "gnu.classpath.tools.rmi.rmic.RMIC", - // pre Kaffe 1.1.5 - "gnu.java.rmi.rmic.RMIC", - // pre Kaffe 1.1.2 - "kaffe.rmi.rmic.RMIC", - }; - - /** - * the name of this adapter for users to select - */ - public static final String COMPILER_NAME = "kaffe"; - - /** {@inheritDoc} */ - public boolean execute() throws BuildException { - getRmic().log("Using Kaffe rmic", Project.MSG_VERBOSE); - Commandline cmd = setupRmicCommand(); - - Class c = getRmicClass(); - if (c == null) { - StringBuffer buf = new StringBuffer("Cannot use Kaffe rmic, as it" - + " is not available. None" - + " of "); - for (int i = 0; i < RMIC_CLASSNAMES.length; i++) { - if (i != 0) { - buf.append(", "); - } - - buf.append(RMIC_CLASSNAMES[i]); - } - buf.append(" have been found. A common solution is to set the" - + " environment variable JAVA_HOME or CLASSPATH."); - throw new BuildException(buf.toString(), - getRmic().getLocation()); - } - - cmd.setExecutable(c.getName()); - if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { - // only supported since Kaffe 1.1.2 - cmd.createArgument().setValue("-verbose"); - getRmic().log(Commandline.describeCommand(cmd)); - } - ExecuteJava ej = new ExecuteJava(); - ej.setJavaCommand(cmd); - return ej.fork(getRmic()) == 0; - } - - /** - * test for kaffe being on the system - * @return true if kaffe is on the current classpath - */ - public static boolean isAvailable() { - return getRmicClass() != null; - } - - /** - * tries to load Kaffe RMIC and falls back to the older class name - * if necessary. - * - * @return null if neither class can get loaded. - */ - private static Class getRmicClass() { - for (int i = 0; i < RMIC_CLASSNAMES.length; i++) { - try { - return Class.forName(RMIC_CLASSNAMES[i]); - } catch (ClassNotFoundException cnfe) { - // Ignore - } - } - return null; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java deleted file mode 100644 index 2cabe2fa..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.rmic; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.Rmic; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.FileNameMapper; - -/** - * The interface that all rmic adapters must adhere to. - * - * <p>A rmic adapter is an adapter that interprets the rmic's - * parameters in preparation to be passed off to the compiler this - * adapter represents. As all the necessary values are stored in the - * Rmic task itself, the only thing all adapters need is the rmic - * task, the execute command and a parameterless constructor (for - * reflection).</p> - * - * @since Ant 1.4 - */ - -public interface RmicAdapter { - - /** - * Sets the rmic attributes, which are stored in the Rmic task. - * @param attributes the rmic attributes to use - */ - void setRmic(Rmic attributes); - - /** - * Call the rmic compiler. - * - * @return true if has the compilation been successful - * @throws BuildException on error - */ - boolean execute() throws BuildException; - - /** - * Maps source class files to the files generated by this rmic - * implementation. - * @return the filename mapper used by this implementation - */ - FileNameMapper getMapper(); - - /** - * The CLASSPATH this rmic process will use. - * @return the classpath this rmic process will use - */ - Path getClasspath(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java deleted file mode 100644 index 4a2708c7..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.rmic; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.ClasspathUtils; - -/** - * Creates the necessary rmic adapter, given basic criteria. - * - * @since 1.4 - */ -public final class RmicAdapterFactory { - /** The error message to be used when the compiler cannot be found. */ - public static final String ERROR_UNKNOWN_COMPILER = "Class not found: "; - - /** The error message to be used when the class is not an rmic adapter. */ - public static final String ERROR_NOT_RMIC_ADAPTER = "Class of unexpected Type: "; - - /** If the compiler has this name use a default compiler. */ - public static final String DEFAULT_COMPILER = "default"; - - /** This is a singleton -- can't create instances!! */ - private RmicAdapterFactory() { - } - - /** - * Based on the parameter passed in, this method creates the necessary - * factory desired. - * - * <p>The current mapping for rmic names are as follows:</p> - * <ul><li>sun = SUN's rmic - * <li>kaffe = Kaffe's rmic - * <li><i>a fully qualified classname</i> = the name of a rmic - * adapter - * <li>weblogic = weblogic compiler - * <li>forking = Sun's RMIC by forking a new JVM - * </ul> - * - * @param rmicType either the name of the desired rmic, or the - * full classname of the rmic's adapter. - * @param task a task to log through. - * @return the compiler adapter - * @throws BuildException if the rmic type could not be resolved into - * a rmic adapter. - */ - public static RmicAdapter getRmic(String rmicType, Task task) - throws BuildException { - return getRmic(rmicType, task, null); - } - - /** - * Based on the parameter passed in, this method creates the necessary - * factory desired. - * - * <p>The current mapping for rmic names are as follows:</p> - * <ul><li>sun = SUN's rmic - * <li>kaffe = Kaffe's rmic - * <li><i>a fully qualified classname</i> = the name of a rmic - * adapter - * <li>weblogic = weblogic compiler - * <li>forking = Sun's RMIC by forking a new JVM - * </ul> - * - * @param rmicType either the name of the desired rmic, or the - * full classname of the rmic's adapter. - * @param task a task to log through. - * @param classpath the classpath to use when looking up an - * adapter class - * @return the compiler adapter - * @throws BuildException if the rmic type could not be resolved into - * a rmic adapter. - * @since Ant 1.8.0 - */ - public static RmicAdapter getRmic(String rmicType, Task task, - Path classpath) - throws BuildException { - //handle default specially by choosing the sun or kaffe compiler - if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.length() == 0) { - rmicType = KaffeRmic.isAvailable() - ? KaffeRmic.COMPILER_NAME - : SunRmic.COMPILER_NAME; - } - if (SunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { - return new SunRmic(); - } else if (KaffeRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { - return new KaffeRmic(); - } else if (WLRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { - return new WLRmic(); - } else if (ForkingSunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { - return new ForkingSunRmic(); - } else if (XNewRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) { - return new XNewRmic(); - } - //no match? - return resolveClassName(rmicType, - // Memory leak in line below - task.getProject().createClassLoader(classpath)); - } - - /** - * Tries to resolve the given classname into a rmic adapter. - * Throws a fit if it can't. - * - * @param className The fully qualified classname to be created. - * @param loader the classloader to use - * @throws BuildException This is the fit that is thrown if className - * isn't an instance of RmicAdapter. - */ - private static RmicAdapter resolveClassName(String className, - ClassLoader loader) - throws BuildException { - return (RmicAdapter) ClasspathUtils.newInstance(className, - loader != null ? loader : - RmicAdapterFactory.class.getClassLoader(), RmicAdapter.class); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java deleted file mode 100644 index 07cbd306..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.rmic; - -import java.io.IOException; -import java.io.OutputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.LogOutputStream; -import org.apache.tools.ant.types.Commandline; - -/** - * The implementation of the rmic for SUN's JDK. - * - * @since Ant 1.4 - */ -public class SunRmic extends DefaultRmicAdapter { - - /** - * name of the class - */ - public static final String RMIC_CLASSNAME = "sun.rmi.rmic.Main"; - - /** - * the name of this adapter for users to select - */ - public static final String COMPILER_NAME = "sun"; - - /** - * name of the executable - */ - public static final String RMIC_EXECUTABLE = "rmic"; - /** Error message to use with the sun rmic is not the classpath. */ - public static final String ERROR_NO_RMIC_ON_CLASSPATH = "Cannot use SUN rmic, as it is not " - + "available. A common solution is to " - + "set the environment variable " - + "JAVA_HOME"; - /** Error message to use when there is an error starting the sun rmic compiler */ - public static final String ERROR_RMIC_FAILED = "Error starting SUN rmic: "; - - /** - * Run the rmic compiler. - * @return true if the compilation succeeded - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - getRmic().log("Using SUN rmic compiler", Project.MSG_VERBOSE); - Commandline cmd = setupRmicCommand(); - - // Create an instance of the rmic, redirecting output to - // the project log - LogOutputStream logstr = new LogOutputStream(getRmic(), - Project.MSG_WARN); - - try { - Class c = Class.forName(RMIC_CLASSNAME); - Constructor cons - = c.getConstructor(new Class[] {OutputStream.class, String.class}); - Object rmic = cons.newInstance(new Object[] {logstr, "rmic"}); - - Method doRmic = c.getMethod("compile", - new Class [] {String[].class}); - Boolean ok = - (Boolean) doRmic.invoke(rmic, - (new Object[] {cmd.getArguments()})); - return ok.booleanValue(); - } catch (ClassNotFoundException ex) { - throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH, - getRmic().getLocation()); - } catch (Exception ex) { - if (ex instanceof BuildException) { - throw (BuildException) ex; - } else { - throw new BuildException(ERROR_RMIC_FAILED, - ex, getRmic().getLocation()); - } - } finally { - try { - logstr.close(); - } catch (IOException e) { - throw new BuildException(e); - } - } - } - - - /** - * 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); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java deleted file mode 100644 index 3b1f2a19..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.rmic; - -import java.lang.reflect.Method; - -import org.apache.tools.ant.AntClassLoader; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Commandline; - -/** - * The implementation of the rmic for WebLogic - * - * @since Ant 1.4 - */ -public class WLRmic extends DefaultRmicAdapter { - /** The classname of the weblogic rmic */ - public static final String WLRMIC_CLASSNAME = "weblogic.rmic"; - /** - * the name of this adapter for users to select - */ - public static final String COMPILER_NAME = "weblogic"; - - /** The error string to use if not able to find the weblogic rmic */ - public static final String ERROR_NO_WLRMIC_ON_CLASSPATH = - "Cannot use WebLogic rmic, as it is not " - + "available. Add it to Ant's classpath with the -lib option"; - - /** The error string to use if not able to start the weblogic rmic */ - public static final String ERROR_WLRMIC_FAILED = "Error starting WebLogic rmic: "; - /** The stub suffix */ - public static final String WL_RMI_STUB_SUFFIX = "_WLStub"; - /** The skeleton suffix */ - public static final String WL_RMI_SKEL_SUFFIX = "_WLSkel"; - /** unsupported error message */ - public static final String UNSUPPORTED_STUB_OPTION = "Unsupported stub option: "; - - /** - * Carry out the rmic compilation. - * @return true if the compilation succeeded - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE); - Commandline cmd = setupRmicCommand(new String[] {"-noexit"}); - - AntClassLoader loader = null; - try { - // Create an instance of the rmic - Class c = null; - if (getRmic().getClasspath() == null) { - c = Class.forName(WLRMIC_CLASSNAME); - } else { - loader - = getRmic().getProject().createClassLoader(getRmic().getClasspath()); - c = Class.forName(WLRMIC_CLASSNAME, true, loader); - } - Method doRmic = c.getMethod("main", - new Class [] {String[].class}); - doRmic.invoke(null, new Object[] {cmd.getArguments()}); - return true; - } catch (ClassNotFoundException ex) { - throw new BuildException(ERROR_NO_WLRMIC_ON_CLASSPATH, getRmic().getLocation()); - } catch (Exception ex) { - if (ex instanceof BuildException) { - throw (BuildException) ex; - } else { - throw new BuildException(ERROR_WLRMIC_FAILED, ex, - getRmic().getLocation()); - } - } finally { - if (loader != null) { - loader.cleanup(); - } - } - } - - /** - * Get the suffix for the rmic stub classes - * @return the stub suffix - */ - public String getStubClassSuffix() { - return WL_RMI_STUB_SUFFIX; - } - - /** - * Get the suffix for the rmic skeleton classes - * @return the skeleton suffix - */ - 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); - } - - /** - * This is an override point; no stub version is returned. If any - * stub option is set, a warning is printed. - * @return null, for no stub version - */ - protected String addStubVersionOptions() { - //handle the many different stub options. - String stubVersion = getRmic().getStubVersion(); - if (null != stubVersion) { - getRmic().log(UNSUPPORTED_STUB_OPTION + stubVersion, - Project.MSG_WARN); - } - return null; - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java deleted file mode 100644 index 559c7698..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.rmic; - -import org.apache.tools.ant.types.Commandline; - -/** - * Run rmic in a new process with -Xnew set. - * This switches rmic to use a new compiler, one that doesn't work in-process - * on ant on java1.6. - * see: <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=38732"> - * http://issues.apache.org/bugzilla/show_bug.cgi?id=38732</a> - */ -public class XNewRmic extends ForkingSunRmic { - - /** - * the name of this adapter for users to select - */ - public static final String COMPILER_NAME = "xnew"; - - /** No-arg constructor. */ - public XNewRmic() { - } - - /** - * Create a normal command line, then with -Xnew at the front - * @return a command line that hands off to thw - */ - protected Commandline setupRmicCommand() { - String[] options = new String[] { - "-Xnew" - }; - Commandline commandline = super.setupRmicCommand(options); - return commandline; - } - -} |