cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
mbenson 2005/02/07 15:50:16 Modified:src/main/org/apache/tools/ant/types CommandlineJava.java Log: Javadoc Revision ChangesPath 1.68 +101 -105 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- CommandlineJava.java 4 Feb 2005 08:08:59 - 1.67 +++ CommandlineJava.java 7 Feb 2005 23:50:16 - 1.68 @@ -30,9 +30,9 @@ /** * A representation of a Java command line that is - * a composite of 2 ttCommandline/tt. One is used for the + * a composite of 2 ttCommandline/tts. One is used for the * vm/options and one for the classname/arguments. It provides - * specific methods for a java command line. + * specific methods for a Java command line. * */ public class CommandlineJava implements Cloneable { @@ -71,17 +71,17 @@ private boolean cloneVm = false; /** - * Specialized Environment class for System properties + * Specialized Environment class for System properties. */ public static class SysProperties extends Environment implements Cloneable { Properties sys = null; private Vector propertySets = new Vector(); /** - * get the properties as an array; this is an override of the - * superclass, as it evaluates all the properties - * @return the array of definitions; may be null - * @throws BuildException on error + * Get the properties as an array; this is an override of the + * superclass, as it evaluates all the properties. + * @return the array of definitions; may be null. + * @throws BuildException on error. */ public String[] getVariables() throws BuildException { @@ -96,8 +96,8 @@ } /** - * add all definitions (including property sets) to a list - * @param listIt list iterator supporting add method + * Add all definitions (including property sets) to a list. + * @param listIt list iterator supporting add method. */ public void addDefinitionsToList(ListIterator listIt) { String[] props = super.getVariables(); @@ -116,9 +116,9 @@ } /** - * This method gets the size of the sysproperties instance. This merges all + * Get the size of the sysproperties instance. This merges all * property sets, so is not an O(1) operation. - * @return the size of the sysproperties instance + * @return the size of the sysproperties instance. */ public int size() { Properties p = mergePropertySets(); @@ -126,9 +126,9 @@ } /** - * cache the system properties and set the system properties to the - * new values - * @throws BuildException if Security prevented this operation + * Cache the system properties and set the system properties to the + * new values. + * @throws BuildException if Security prevented this operation. */ public void setSystem() throws BuildException { try { @@ -150,9 +150,9 @@ } /** - * restore the system properties to the cached value + * Restore the system properties to the cached value. * @throws BuildException if Security prevented this operation, or - * there was no system properties to restore + * there were no system properties to restore. */ public void restoreSystem() throws BuildException { if (sys == null) { @@ -168,9 +168,9 @@ } /** - * deep clone - * @return a cloned instance of SysProperties - * @exception CloneNotSupportedException for signature + * Create a deep clone. + * @return a cloned instance of SysProperties. + * @exception CloneNotSupportedException for signature. */ public Object clone() throws CloneNotSupportedException { try { @@ -184,16 +184,16 @@ } /** - * add a propertyset to the total set - * @param ps the new property set + * Add a propertyset to the total set. + * @param ps the new property set. */ public void addSyspropertyset(PropertySet ps) { propertySets.addElement(ps); } /** - * add a propertyset to the total set - * @param ps the new property set + * Add a propertyset to the
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
peterreilly2005/01/18 02:51:04 Modified:src/main/org/apache/tools/ant/types CommandlineJava.java Log: trailing space Revision ChangesPath 1.65 +1 -1 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- CommandlineJava.java 18 Jan 2005 08:37:12 - 1.64 +++ CommandlineJava.java 18 Jan 2005 10:51:03 - 1.65 @@ -670,7 +670,7 @@ * @since 1.7 */ private boolean isCloneVm() { -return cloneVm +return cloneVm || true.equals(System.getProperty(ant.build.clonevm)); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
bodewig 2005/01/13 01:05:35 Modified:.WHATSNEW src/main/org/apache/tools/ant/types CommandlineJava.java Log: Try to harmonize bootclasspath and build.sysclasspath a bit more, there are still some more tasks to handle Revision ChangesPath 1.710 +5 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.709 retrieving revision 1.710 diff -u -r1.709 -r1.710 --- WHATSNEW 11 Jan 2005 18:30:34 - 1.709 +++ WHATSNEW 13 Jan 2005 09:05:35 - 1.710 @@ -10,6 +10,11 @@ to upgrade to a newer version of log4j. Bugzilla Report 31951. +* build.sysclasspath now also affects the bootclasspath handling of + spawned Java VMs. If you set build.sysclasspath to anything other + than ignore (or leave it unset, since ignore is the default when + it comes to bootclasspath handling), then the bootclasspath of the + VM running Ant will be added to the bootclasspath you've specified. Fixed bugs: --- 1.62 +25 -32 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- CommandlineJava.java 11 Jan 2005 14:05:01 - 1.61 +++ CommandlineJava.java 13 Jan 2005 09:05:35 - 1.62 @@ -386,13 +386,11 @@ } //boot classpath -if (haveBootclasspath(true)) { -listIterator.add(-Xbootclasspath: + bootclasspath.toString()); -} else if (cloneBootclasspath()) { -listIterator.add(-Xbootclasspath: - + Path.systemBootClasspath.toString()); +Path bcp = calculateBootclasspath(true); +if (bcp.size() 0) { +listIterator.add(-Xbootclasspath: + bcp.toString()); } - + //main classpath if (haveClasspath()) { listIterator.add(-classpath); @@ -493,7 +491,7 @@ size += 2; } // bootclasspath is -Xbootclasspath:classpath - 1 arg -if (haveBootclasspath(true) || cloneBootclasspath()) { +if (calculateBootclasspath(true).size() 0) { size++; } // jar execution requires an additional -jar option @@ -622,37 +620,32 @@ * @since Ant 1.6 */ protected boolean haveBootclasspath(boolean log) { -if (bootclasspath != null - bootclasspath.toString().trim().length() 0) { - -if (!bootclasspath.toString() -.equals(bootclasspath.concatSystemClasspath(ignore) -.toString())) { -if (log) { -bootclasspath.log(Ignoring bootclasspath as - + build.sysclasspath has been set.); -} -} else if (vmVersion.startsWith(1.1)) { -if (log) { -bootclasspath.log(Ignoring bootclasspath as - + the target VM doesn't support it.); -} -} else { -return true; -} -} -return false; +return calculateBootclasspath(log).size() 0; } /** - * Should a bootclasspath argument be created to clone the current - * VM settings? + * Calculate the bootclasspath based on the bootclasspath + * specified, the build.sysclasspath and build.clonevm magic + * properties as well as the cloneVm attribute. * * @since Ant 1.7 */ -private boolean cloneBootclasspath() { -return isCloneVm() !vmVersion.startsWith(1.1) - Path.systemBootClasspath.size() 0; +private Path calculateBootclasspath(boolean log) { +if (vmVersion.startsWith(1.1)) { +if (bootclasspath != null log) { +bootclasspath.log(Ignoring bootclasspath as + + the target VM doesn't support it.); +} +} else { +if (bootclasspath != null) { +return bootclasspath.concatSystemBootClasspath(isCloneVm() + ? last + : ignore); +} else if (isCloneVm()) { +return Path.systemBootClasspath; +} +} +return new Path(null); } /** - To
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
peterreilly2005/01/13 02:10:10 Modified:src/main/org/apache/tools/ant/types CommandlineJava.java Log: javadoc Revision ChangesPath 1.63 +25 -10 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- CommandlineJava.java 13 Jan 2005 09:05:35 - 1.62 +++ CommandlineJava.java 13 Jan 2005 10:10:05 - 1.63 @@ -81,7 +81,7 @@ * get the properties as an array; this is an override of the * superclass, as it evaluates all the properties * @return the array of definitions; may be null - * @throws BuildException + * @throws BuildException on error */ public String[] getVariables() throws BuildException { @@ -170,6 +170,7 @@ /** * deep clone * @return a cloned instance of SysProperties + * @exception CloneNotSupportedException for signature */ public Object clone() throws CloneNotSupportedException { try { @@ -246,16 +247,16 @@ } /** - * set the executable used to start the new JVM - * @param vm + * Set the executable used to start the new JVM. + * @param vm the executable to use */ public void setVm(String vm) { vmCommand.setExecutable(vm); } /** - * set the JVM version required - * @param value + * Set the JVM version required. + * @param value the version required */ public void setVmversion(String value) { vmVersion = value; @@ -265,6 +266,7 @@ * If set, system properties will be copied to the cloned VM - as * well as the bootclasspath unless you have explicitly specified * a bootclaspath. + * @param cloneVm if true copy the system properties * @since Ant 1.7 */ public void setCloneVm(boolean cloneVm) { @@ -328,6 +330,11 @@ return null; } +/** + * Create a classpath. + * @param p the project to use to create the path in + * @return a path to be configured + */ public Path createClasspath(Project p) { if (classpath == null) { classpath = new Path(p); @@ -336,6 +343,9 @@ } /** + * Create a boot classpath. + * @param p the project to use to create the path in + * @return a path to be configured * @since Ant 1.6 */ public Path createBootclasspath(Project p) { @@ -345,6 +355,10 @@ return bootclasspath; } +/** + * Get the vm version. + * @return the vm version + */ public String getVmversion() { return vmVersion; } @@ -390,7 +404,7 @@ if (bcp.size() 0) { listIterator.add(-Xbootclasspath: + bcp.toString()); } - + //main classpath if (haveClasspath()) { listIterator.add(-classpath); @@ -418,6 +432,7 @@ /** * Specify max memory of the JVM * -mx or -Xmx depending on VM version + * @param max the string to pass to the jvm to specifiy the max memory */ public void setMaxmemory(String max) { this.maxMemory = max; @@ -436,7 +451,7 @@ * Returns a String that describes the command and arguments * suitable for verbose output before a call to * codeRuntime.exec(String[])code - * + * @return the description string * @since Ant 1.5 */ public String describeCommand() { @@ -448,7 +463,7 @@ * for in VM executions. * * pThe class name is the executable in this context./p - * + * @return the description string * @since Ant 1.5 */ public String describeJavaCommand() { @@ -599,7 +614,7 @@ /** * Has the classpath been specified and shall it really be used or * will build.sysclasspath null it? - * + * @return true if the classpath is to be used * @since Ant 1.6 */ protected boolean haveClasspath() { @@ -616,7 +631,7 @@ * * @param log whether to log a warning if a bootclasspath has been * specified but will be ignored. - * + * @return true if the bootclasspath is to be used * @since Ant 1.6 */ protected boolean haveBootclasspath(boolean log) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
bodewig 2005/01/11 06:05:01 Modified:src/main/org/apache/tools/ant/types CommandlineJava.java Log: Path is a ProjectComponent - use it for logging Revision ChangesPath 1.61 +3 -7 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- CommandlineJava.java 22 Nov 2004 09:23:36 - 1.60 +++ CommandlineJava.java 11 Jan 2005 14:05:01 - 1.61 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -625,20 +625,16 @@ if (bootclasspath != null bootclasspath.toString().trim().length() 0) { -/* - * XXX - need to log something, but there is no ProjectComponent - * around to log to. - */ if (!bootclasspath.toString() .equals(bootclasspath.concatSystemClasspath(ignore) .toString())) { if (log) { -System.out.println(Ignoring bootclasspath as +bootclasspath.log(Ignoring bootclasspath as + build.sysclasspath has been set.); } } else if (vmVersion.startsWith(1.1)) { if (log) { -System.out.println(Ignoring bootclasspath as +bootclasspath.log(Ignoring bootclasspath as + the target VM doesn't support it.); } } else { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
peterreilly2004/10/28 01:47:26 Modified:.WHATSNEW src/main/org/apache/tools/ant Project.java Diagnostics.java src/main/org/apache/tools/ant/types CommandlineJava.java Log: Properties.propertyNames() should be used instead of .keys(). PR: 27261 Obtained from: Mike Murray Revision ChangesPath 1.678 +3 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.677 retrieving revision 1.678 diff -u -r1.677 -r1.678 --- WHATSNEW 27 Oct 2004 12:48:35 - 1.677 +++ WHATSNEW 28 Oct 2004 08:47:26 - 1.678 @@ -135,6 +135,9 @@ * NPE using XmlLogger and antlib. Bugzilla report 31840. +* Properties.propertyNames() should be used instead of .keys(). + Bugzilla report 27261. + Changes from Ant 1.6.1 to Ant 1.6.2 === 1.175 +2 -2 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.174 retrieving revision 1.175 diff -u -r1.174 -r1.175 --- Project.java 2 Sep 2004 07:51:33 - 1.174 +++ Project.java 28 Oct 2004 08:47:26 - 1.175 @@ -828,7 +828,7 @@ */ public void setSystemProperties() { Properties systemP = System.getProperties(); -Enumeration e = systemP.keys(); +Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { Object name = e.nextElement(); String value = systemP.get(name).toString(); 1.15 +1 -1 ant/src/main/org/apache/tools/ant/Diagnostics.java Index: Diagnostics.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Diagnostics.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- Diagnostics.java 9 Mar 2004 16:47:59 - 1.14 +++ Diagnostics.java 28 Oct 2004 08:47:26 - 1.15 @@ -266,7 +266,7 @@ * @param out the stream to print the properties to. */ private static void doReportSystemProperties(PrintStream out) { -for (Enumeration keys = System.getProperties().keys(); +for (Enumeration keys = System.getProperties().propertyNames(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); out.println(key + : + System.getProperty(key)); 1.57 +1 -1 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- CommandlineJava.java 7 Oct 2004 10:59:45 - 1.56 +++ CommandlineJava.java 28 Oct 2004 08:47:26 - 1.57 @@ -133,7 +133,7 @@ try { sys = System.getProperties(); Properties p = new Properties(); -for (Enumeration e = sys.keys(); e.hasMoreElements();) { +for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { Object o = e.nextElement(); p.put(o, sys.get(o)); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
peterreilly2004/10/28 01:48:48 Modified:.Tag: ANT_16_BRANCH WHATSNEW src/main/org/apache/tools/ant Tag: ANT_16_BRANCH Project.java Diagnostics.java src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH CommandlineJava.java Log: sync Revision ChangesPath No revision No revision 1.503.2.143 +3 -0 ant/WHATSNEW Index: WHATSNEW === RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.142 retrieving revision 1.503.2.143 diff -u -r1.503.2.142 -r1.503.2.143 --- WHATSNEW 27 Oct 2004 12:50:19 - 1.503.2.142 +++ WHATSNEW 28 Oct 2004 08:48:48 - 1.503.2.143 @@ -63,6 +63,9 @@ * NPE using XmlLogger and antlib. Bugzilla report 31840. +* Properties.propertyNames() should be used instead of .keys(). + Bugzilla report 27261. + Changes from Ant 1.6.1 to Ant 1.6.2 === No revision No revision 1.154.2.12 +2 -2 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.154.2.11 retrieving revision 1.154.2.12 diff -u -r1.154.2.11 -r1.154.2.12 --- Project.java 17 Jul 2004 16:34:40 - 1.154.2.11 +++ Project.java 28 Oct 2004 08:48:48 - 1.154.2.12 @@ -824,7 +824,7 @@ */ public void setSystemProperties() { Properties systemP = System.getProperties(); -Enumeration e = systemP.keys(); +Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { Object name = e.nextElement(); String value = systemP.get(name).toString(); 1.10.2.5 +1 -1 ant/src/main/org/apache/tools/ant/Diagnostics.java Index: Diagnostics.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Diagnostics.java,v retrieving revision 1.10.2.4 retrieving revision 1.10.2.5 diff -u -r1.10.2.4 -r1.10.2.5 --- Diagnostics.java 9 Mar 2004 17:01:29 - 1.10.2.4 +++ Diagnostics.java 28 Oct 2004 08:48:48 - 1.10.2.5 @@ -266,7 +266,7 @@ * @param out the stream to print the properties to. */ private static void doReportSystemProperties(PrintStream out) { -for (Enumeration keys = System.getProperties().keys(); +for (Enumeration keys = System.getProperties().propertyNames(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); out.println(key + : + System.getProperty(key)); No revision No revision 1.47.2.7 +1 -1 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.47.2.6 retrieving revision 1.47.2.7 diff -u -r1.47.2.6 -r1.47.2.7 --- CommandlineJava.java 20 Apr 2004 06:53:29 - 1.47.2.6 +++ CommandlineJava.java 28 Oct 2004 08:48:48 - 1.47.2.7 @@ -127,7 +127,7 @@ try { sys = System.getProperties(); Properties p = new Properties(); -for (Enumeration e = sys.keys(); e.hasMoreElements();) { +for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { Object o = e.nextElement(); p.put(o, sys.get(o)); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
peterreilly2004/10/28 02:12:03 Modified:src/main/org/apache/tools/ant Project.java src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java Log: Properties.propertyNames() should be used instead of .keys(): fix for previous fix - use getProperty() and not get() fix for PropertySet PR: 27261 Revision ChangesPath 1.176 +3 -3 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.175 retrieving revision 1.176 diff -u -r1.175 -r1.176 --- Project.java 28 Oct 2004 08:47:26 - 1.175 +++ Project.java 28 Oct 2004 09:12:02 - 1.176 @@ -830,8 +830,8 @@ Properties systemP = System.getProperties(); Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { -Object name = e.nextElement(); -String value = systemP.get(name).toString(); +String name = (String) e.nextElement(); +String value = systemP.getProperty(name); this.setPropertyInternal(name.toString(), value); } } 1.58 +2 -2 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- CommandlineJava.java 28 Oct 2004 08:47:26 - 1.57 +++ CommandlineJava.java 28 Oct 2004 09:12:02 - 1.58 @@ -134,8 +134,8 @@ sys = System.getProperties(); Properties p = new Properties(); for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { -Object o = e.nextElement(); -p.put(o, sys.get(o)); +String name = (String) e.nextElement(); +p.put(name, sys.getProperty(name)); } p.putAll(mergePropertySets()); for (Enumeration e = variables.elements(); e.hasMoreElements();) { 1.16 +16 -1 ant/src/main/org/apache/tools/ant/types/PropertySet.java Index: PropertySet.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/PropertySet.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PropertySet.java 5 Aug 2004 17:14:31 - 1.15 +++ PropertySet.java 28 Oct 2004 09:12:02 - 1.16 @@ -174,6 +174,21 @@ } /** + * Convert the system properties to a hashtable. + * Use propertynames to get the list of properties (including + * default ones). + */ +private Hashtable getAllSystemProperties() { +Hashtable ret = new Hashtable(); +for (Enumeration e = System.getProperties().propertyNames(); + e.hasMoreElements();) { +String name = (String) e.nextElement(); +ret.put(name, System.getProperties().getProperty(name)); +} +return ret; +} + +/** * this is the operation to get the existing or recalculated properties. * @return */ @@ -181,7 +196,7 @@ Set names = null; Project prj = getProject(); Hashtable props = -prj == null ? System.getProperties() : prj.getProperties(); +prj == null ? getAllSystemProperties() : prj.getProperties(); if (getDynamic() || cachedNames == null) { names = new HashSet(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
peterreilly2004/10/28 02:17:49 Modified:src/main/org/apache/tools/ant Tag: ANT_16_BRANCH Project.java src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH CommandlineJava.java PropertySet.java Log: sync Revision ChangesPath No revision No revision 1.154.2.13 +3 -3 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.154.2.12 retrieving revision 1.154.2.13 diff -u -r1.154.2.12 -r1.154.2.13 --- Project.java 28 Oct 2004 08:48:48 - 1.154.2.12 +++ Project.java 28 Oct 2004 09:17:48 - 1.154.2.13 @@ -826,8 +826,8 @@ Properties systemP = System.getProperties(); Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { -Object name = e.nextElement(); -String value = systemP.get(name).toString(); +String name = (String) e.nextElement(); +String value = systemP.getProperty(name); this.setPropertyInternal(name.toString(), value); } } No revision No revision 1.47.2.8 +2 -2 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.47.2.7 retrieving revision 1.47.2.8 diff -u -r1.47.2.7 -r1.47.2.8 --- CommandlineJava.java 28 Oct 2004 08:48:48 - 1.47.2.7 +++ CommandlineJava.java 28 Oct 2004 09:17:49 - 1.47.2.8 @@ -128,8 +128,8 @@ sys = System.getProperties(); Properties p = new Properties(); for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { -Object o = e.nextElement(); -p.put(o, sys.get(o)); +String name = (String) e.nextElement(); +p.put(name, sys.getProperty(name)); } p.putAll(mergePropertySets()); for (Enumeration e = variables.elements(); e.hasMoreElements();) { 1.8.2.6 +21 -1 ant/src/main/org/apache/tools/ant/types/PropertySet.java Index: PropertySet.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/PropertySet.java,v retrieving revision 1.8.2.5 retrieving revision 1.8.2.6 diff -u -r1.8.2.5 -r1.8.2.6 --- PropertySet.java 23 Apr 2004 15:41:38 - 1.8.2.5 +++ PropertySet.java 28 Oct 2004 09:17:49 - 1.8.2.6 @@ -163,11 +163,30 @@ return isReference() ? getRef()._mapper : _mapper; } +/** + * Convert the system properties to a hashtable. + * Use propertynames to get the list of properties (including + * default ones). + */ +private Hashtable getAllSystemProperties() { +Hashtable ret = new Hashtable(); +for (Enumeration e = System.getProperties().propertyNames(); + e.hasMoreElements();) { +String name = (String) e.nextElement(); +ret.put(name, System.getProperties().getProperty(name)); +} +return ret; +} + +/** + * this is the operation to get the existing or recalculated properties. + * @return + */ public Properties getProperties() { Set names = null; Project prj = getProject(); Hashtable props = -prj == null ? System.getProperties() : prj.getProperties(); +prj == null ? getAllSystemProperties() : prj.getProperties(); if (getDynamic() || cachedNames == null) { names = new HashSet(); @@ -200,6 +219,7 @@ mapper = myMapper.getImplementation(); } Properties properties = new Properties(); +//iterate through the names, get the matching values for (Iterator iter = names.iterator(); iter.hasNext();) { String name = (String) iter.next(); String value = (String) props.get(name); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
Stefan Bodewig wrote: On 28 Oct 2004, [EMAIL PROTECTED] wrote: fix for previous fix - use getProperty() and not get() What if the keys/values are not Strings? In this case, the properties are from System.getProperties() and not from Project.getProperties() so they are strings. The issue is that System.getProperties().get() was used rather that System.getProperties().getProperty() get() may bypass the default resolving logic in the jdk (looking at the code, this seems to be the case) Peter There must be a very old bug lurking in Bugzilla that was resolved by not assuming that the Ant properties table only contains Strings. I'm not sure whether the system properties table gets abused in a similar way by anybody. If so, this is a backwards incompatible change, I guess. Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
On Thu, 28 Oct 2004, Peter Reilly [EMAIL PROTECTED] wrote: Stefan Bodewig wrote: What if the keys/values are not Strings? In this case, the properties are from System.getProperties() and not from Project.getProperties() so they are strings. Who is going to prevent System.getProperties().put(Object, Class)? Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
Stefan Bodewig wrote: On Thu, 28 Oct 2004, Peter Reilly [EMAIL PROTECTED] wrote: Stefan Bodewig wrote: What if the keys/values are not Strings? In this case, the properties are from System.getProperties() and not from Project.getProperties() so they are strings. Who is going to prevent System.getProperties().put(Object, Class)? Nothing... However, it is breaking the usage of properties, for example: public class Test { public static void main(String[] args) { Integer i = new Integer(10); System.getProperties().put(i, 10); System.getProperties().list(System.out); } } gets an exception: Caused by: java.lang.ClassCastException: java.lang.Integer at java.util.Properties.enumerate(Properties.java:869) at java.util.Properties.list(Properties.java:823) at Test.main(Unknown Source) We could put a check in, but as it is not in the jdk for (is it 10 years??), it may not be vital... Peter Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
Peter Reilly wrote: Stefan Bodewig wrote: On Thu, 28 Oct 2004, Peter Reilly [EMAIL PROTECTED] wrote: Stefan Bodewig wrote: What if the keys/values are not Strings? In this case, the properties are from System.getProperties() and not from Project.getProperties() so they are strings. Who is going to prevent System.getProperties().put(Object, Class)? Nothing... However, it is breaking the usage of properties, for example: public class Test { public static void main(String[] args) { Integer i = new Integer(10); System.getProperties().put(i, 10); System.getProperties().list(System.out); } } Acutally: Integer i = new Integer(10); System.getProperties().put(i, 10); Enumeration names = System.getProperties().propertyNames(); Also gives the java.lang.ClassCastException exception. Since Properties.propertyNames() is the correct way to retieve the names of the system properties, we cannot check if the user has messed up the contents of the properties (without always iterating over the contents and removing invalid keys and values and *then* calling propertyNames). Peter gets an exception: Caused by: java.lang.ClassCastException: java.lang.Integer at java.util.Properties.enumerate(Properties.java:869) at java.util.Properties.list(Properties.java:823) at Test.main(Unknown Source) We could put a check in, but as it is not in the jdk for (is it 10 years??), it may not be vital... Peter Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
From: Peter Reilly [mailto:[EMAIL PROTECTED] Peter Reilly wrote: Stefan Bodewig wrote: On Thu, 28 Oct 2004, Peter Reilly [EMAIL PROTECTED] wrote: Stefan Bodewig wrote: What if the keys/values are not Strings? In this case, the properties are from System.getProperties() and not from Project.getProperties() so they are strings. Who is going to prevent System.getProperties().put(Object, Class)? Nothing... However, it is breaking the usage of properties, for example: public class Test { public static void main(String[] args) { Integer i = new Integer(10); System.getProperties().put(i, 10); System.getProperties().list(System.out); } } Acutally: Integer i = new Integer(10); System.getProperties().put(i, 10); Enumeration names = System.getProperties().propertyNames(); Also gives the java.lang.ClassCastException exception. Since Properties.propertyNames() is the correct way to retieve the names of the system properties, we cannot check if the user has messed up the contents of the properties (without always iterating over the contents and removing invalid keys and values and *then* calling propertyNames). Peter gets an exception: Caused by: java.lang.ClassCastException: java.lang.Integer at java.util.Properties.enumerate(Properties.java:869) at java.util.Properties.list(Properties.java:823) at Test.main(Unknown Source) We could put a check in, but as it is not in the jdk for (is it 10 years??), it may not be vital... The only thing we need to be sure is that is such exception occurs, then ANT ends throwing a BuildException. We are not suppose to fence for every bad API use of every user or every IDE. Jose Alberto - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
On Thu, 28 Oct 2004, Peter Reilly [EMAIL PROTECTED] wrote: However, it is breaking the usage of properties, for example: I know. But still people abused Ant's properties that way, so I wonder whether we need to expect people doing the same with system properties. Stefan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
How about we just call toString() on every value; its a no-op on all strings, and robust on odd stuff? -steve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
because it is in the root class Object. -Original Message- From: Steve Loughran [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 6:05 PM To: Ant Developers List Subject: Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java How about we just call toString() on every value; its a no-op on all strings, and robust on odd stuff? -steve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
Steve Loughran wrote: How about we just call toString() on every value; its a no-op on all strings, and robust on odd stuff? This will not work, as we need to call properties.propertyNames() to get the names. propertyNames will trigger the Cast exception. Peter -steve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
bodewig 2004/02/20 07:13:22 Modified:src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java src/main/org/apache/tools/ant/types CommandlineJava.java Log: Allow subclasses of junit to plug in command lines of their own. Submitted by: Mariano Benitez mariano at fuegolabs dot com Revision ChangesPath 1.93 +28 -18 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Index: JUnitTask.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v retrieving revision 1.92 retrieving revision 1.93 diff -u -r1.92 -r1.93 --- JUnitTask.java9 Feb 2004 21:05:32 - 1.92 +++ JUnitTask.java20 Feb 2004 15:13:21 - 1.93 @@ -123,7 +123,7 @@ */ public class JUnitTask extends Task { -private CommandlineJava commandline = new CommandlineJava(); +private CommandlineJava commandline; private Vector tests = new Vector(); private Vector batchTests = new Vector(); private Vector formatters = new Vector(); @@ -338,7 +338,7 @@ * @since Ant 1.2 */ public void setMaxmemory(String max) { -commandline.setMaxmemory(max); +getCommandline().setMaxmemory(max); } /** @@ -352,7 +352,7 @@ * @since Ant 1.2 */ public void setJvm(String value) { -commandline.setVm(value); +getCommandline().setVm(value); } /** @@ -365,7 +365,7 @@ * @since Ant 1.2 */ public Commandline.Argument createJvmarg() { -return commandline.createVmArgument(); +return getCommandline().createVmArgument(); } /** @@ -390,7 +390,7 @@ */ public void addSysproperty(Environment.Variable sysp) { -commandline.addSysproperty(sysp); +getCommandline().addSysproperty(sysp); } /** @@ -405,7 +405,7 @@ // see bugzilla report 21684 String testString = sysp.getContent(); getProject().log(sysproperty added : + testString, Project.MSG_DEBUG); -commandline.addSysproperty(sysp); +getCommandline().addSysproperty(sysp); } /** @@ -419,7 +419,7 @@ * @since Ant 1.6 */ public void addSyspropertyset(PropertySet sysp) { -commandline.addSyspropertyset(sysp); +getCommandline().addSyspropertyset(sysp); } /** @@ -429,7 +429,7 @@ * @since Ant 1.2 */ public Path createClasspath() { -return commandline.createClasspath(getProject()).createPath(); +return getCommandline().createClasspath(getProject()).createPath(); } /** @@ -438,7 +438,7 @@ * @since Ant 1.6 */ public Path createBootclasspath() { -return commandline.createBootclasspath(getProject()).createPath(); +return getCommandline().createBootclasspath(getProject()).createPath(); } /** @@ -532,10 +532,10 @@ * @param asserts assertion set */ public void addAssertions(Assertions asserts) { -if (commandline.getAssertions() != null) { +if (getCommandline().getAssertions() != null) { throw new BuildException(Only one assertion declaration is allowed); } -commandline.setAssertions(asserts); +getCommandline().setAssertions(asserts); } /** @@ -560,7 +560,7 @@ * @since Ant 1.7 */ public void setCloneVm(boolean cloneVm) { -commandline.setCloneVm(cloneVm); +getCommandline().setCloneVm(cloneVm); } /** @@ -570,7 +570,7 @@ * @since Ant 1.2 */ public JUnitTask() throws Exception { -commandline +getCommandline() .setClassname(org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner); } @@ -688,7 +688,7 @@ log(Permissions ignored when running in forked mode!, Project.MSG_WARN); } -CommandlineJava cmd = (CommandlineJava) commandline.clone(); +CommandlineJava cmd = (CommandlineJava) getCommandline().clone(); cmd.setClassname(org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner); cmd.createArgument().setValue(test.getName()); @@ -916,13 +916,13 @@ + the same VM., Project.MSG_WARN); } -if (commandline.getBootclasspath() != null) { +if (getCommandline().getBootclasspath() != null) { log(bootclasspath is ignored if running in the same VM., Project.MSG_WARN); } CommandlineJava.SysProperties sysProperties = -
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java Path.java PropertySet.java
bodewig 2003/12/12 01:41:46 Modified:src/main/org/apache/tools/ant/taskdefs Java.java src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java src/main/org/apache/tools/ant/types CommandlineJava.java Path.java PropertySet.java Log: Add a cloneVm attribute to CommandlineJava and java and junit. If set, the forked VM will be configured to match the currently running VM closely. This involves: * copying of all system properties. * copying of the bootclasspath - only if no bootclasspath has been specified explicitly or build.sysclasspath has been set to only. This is accompanied by a magic system property build.clonevm that can be used to force the attribute to be set. It has to be a system property as CommandlineJava doesn't know about project instances. PR: 25327 Revision ChangesPath 1.79 +13 -0 ant/src/main/org/apache/tools/ant/taskdefs/Java.java Index: Java.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v retrieving revision 1.78 retrieving revision 1.79 diff -u -r1.78 -r1.79 --- Java.java 23 Sep 2003 06:31:46 - 1.78 +++ Java.java 12 Dec 2003 09:41:46 - 1.79 @@ -330,6 +330,19 @@ } /** + * If set, system properties will be copied to the cloned VM - as + * well as the bootclasspath unless you have explicitly specified + * a bootclaspath. + * + * pDoesn't have any effect unless fork is true./p + * + * @since Ant 1.7 + */ +public void setCloneVm(boolean cloneVm) { +cmdl.setCloneVm(cloneVm); +} + +/** * Adds a command-line argument. * * @return created argument 1.89 +14 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Index: JUnitTask.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- JUnitTask.java22 Oct 2003 14:38:50 - 1.88 +++ JUnitTask.java12 Dec 2003 09:41:46 - 1.89 @@ -588,6 +588,19 @@ } /** + * If set, system properties will be copied to the cloned VM - as + * well as the bootclasspath unless you have explicitly specified + * a bootclaspath. + * + * pDoesn't have any effect unless fork is true./p + * + * @since Ant 1.7 + */ +public void setCloneVm(boolean cloneVm) { +commandline.setCloneVm(cloneVm); +} + +/** * Creates a new JUnitRunner and enables fork of a new Java VM. * * @throws Exception under ??? circumstances 1.48 +58 -2 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- CommandlineJava.java 21 Sep 2003 20:20:02 - 1.47 +++ CommandlineJava.java 12 Dec 2003 09:41:46 - 1.48 @@ -105,6 +105,12 @@ private boolean executeJar = false; /** + * Whether system properties and bootclasspath shall be cloned. + * @since Ant 1.7 + */ +private boolean cloneVm = false; + +/** * Specialized Environment class for System properties */ public static class SysProperties extends Environment implements Cloneable { @@ -294,6 +300,15 @@ vmVersion = value; } +/** + * If set, system properties will be copied to the cloned VM - as + * well as the bootclasspath unless you have explicitly specified + * a bootclaspath. + * @since Ant 1.7 + */ +public void setCloneVm(boolean cloneVm) { +this.cloneVm = cloneVm; +} /** * get the current assertions @@ -397,10 +412,26 @@ getActualVMCommand().addCommandToList(listIterator); // properties are part of the vm options... sysProperties.addDefinitionsToList(listIterator); + +if (isCloneVm()) { +SysProperties clonedSysProperties = new SysProperties(); +PropertySet ps = new PropertySet(); +PropertySet.BuiltinPropertySetName sys = +new PropertySet.BuiltinPropertySetName(); +sys.setValue(system); +ps.appendBuiltin(sys); +clonedSysProperties.addSyspropertyset(ps); +
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java
bodewig 2003/05/27 02:43:22 Modified:src/main/org/apache/tools/ant/types CommandlineJava.java Log: Remove split System.arraycopy that is a leftover from times where we forced the -jar argument to be the first on the command line. Revision ChangesPath 1.41 +2 -6 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java === RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- CommandlineJava.java 27 May 2003 09:30:17 - 1.40 +++ CommandlineJava.java 27 May 2003 09:43:22 - 1.41 @@ -293,12 +293,8 @@ String[] result = new String[size()]; int pos = 0; String[] vmArgs = getActualVMCommand().getCommandline(); -// first argument is the java.exe path... -result[pos++] = vmArgs[0]; - -// next follows the vm options -System.arraycopy(vmArgs, 1, result, pos, vmArgs.length - 1); -pos += vmArgs.length - 1; +System.arraycopy(vmArgs, 0, result, pos, vmArgs.length); +pos += vmArgs.length; // properties are part of the vm options... if (sysProperties.size() 0) { System.arraycopy(sysProperties.getVariables(), 0,