bodewig 2003/05/27 02:30:17
Modified: src/main/org/apache/tools/ant/types AbstractFileSet.java
Commandline.java CommandlineJava.java DirSet.java
FileSet.java FilterSet.java Path.java
ZipFileSet.java
Log:
fix the completely broken clone() implementations.
Revision Changes Path
1.20 +13 -0
ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java
Index: AbstractFileSet.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- AbstractFileSet.java 25 May 2003 11:40:54 -0000 1.19
+++ AbstractFileSet.java 27 May 2003 09:30:17 -0000 1.20
@@ -668,4 +668,17 @@
return sb.toString();
}
+ /**
+ * @since Ant 1.6
+ */
+ public Object clone() {
+ try {
+ AbstractFileSet fs = (AbstractFileSet) super.clone();
+ fs.setProject(getProject());
+ return fs;
+ } catch (CloneNotSupportedException e) {
+ throw new BuildException(e);
+ }
+ }
+
}
1.29 +7 -4 ant/src/main/org/apache/tools/ant/types/Commandline.java
Index: Commandline.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Commandline.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Commandline.java 4 Apr 2003 13:51:12 -0000 1.28
+++ Commandline.java 27 May 2003 09:30:17 -0000 1.29
@@ -427,10 +427,13 @@
}
public Object clone() {
- Commandline c = new Commandline();
- c.setExecutable(executable);
- c.addArguments(getArguments());
- return c;
+ try {
+ Commandline c = (Commandline) super.clone();
+ c.arguments = (Vector) arguments.clone();
+ return c;
+ } catch (CloneNotSupportedException e) {
+ throw new BuildException(e);
+ }
}
/**
1.40 +14 -13
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.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- CommandlineJava.java 27 May 2003 08:49:42 -0000 1.39
+++ CommandlineJava.java 27 May 2003 09:30:17 -0000 1.40
@@ -440,20 +440,21 @@
* @return a CommandlineJava object
*/
public Object clone() {
- CommandlineJava c = new CommandlineJava();
- c.vmCommand = (Commandline) vmCommand.clone();
- c.javaCommand = (Commandline) javaCommand.clone();
- c.sysProperties = (SysProperties) sysProperties.clone();
- c.maxMemory = maxMemory;
- if (classpath != null) {
- c.classpath = (Path) classpath.clone();
+ try {
+ CommandlineJava c = (CommandlineJava) super.clone();
+ c.vmCommand = (Commandline) vmCommand.clone();
+ c.javaCommand = (Commandline) javaCommand.clone();
+ c.sysProperties = (SysProperties) sysProperties.clone();
+ if (classpath != null) {
+ c.classpath = (Path) classpath.clone();
+ }
+ if (bootclasspath != null) {
+ c.bootclasspath = (Path) bootclasspath.clone();
+ }
+ return c;
+ } catch (CloneNotSupportedException e) {
+ throw new BuildException(e);
}
- if (bootclasspath != null) {
- c.bootclasspath = (Path) bootclasspath.clone();
- }
- c.vmVersion = vmVersion;
- c.executeJar = executeJar;
- return c;
}
/**
1.9 +3 -3 ant/src/main/org/apache/tools/ant/types/DirSet.java
Index: DirSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/DirSet.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DirSet.java 10 Feb 2003 14:14:30 -0000 1.8
+++ DirSet.java 27 May 2003 09:30:17 -0000 1.9
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -76,9 +76,9 @@
*/
public Object clone() {
if (isReference()) {
- return new DirSet((DirSet) getRef(getProject()));
+ return ((DirSet) getRef(getProject())).clone();
} else {
- return new DirSet(this);
+ return super.clone();
}
}
1.33 +3 -3 ant/src/main/org/apache/tools/ant/types/FileSet.java
Index: FileSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/FileSet.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- FileSet.java 7 Mar 2003 11:23:07 -0000 1.32
+++ FileSet.java 27 May 2003 09:30:17 -0000 1.33
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -81,9 +81,9 @@
*/
public Object clone() {
if (isReference()) {
- return new FileSet((FileSet) getRef(getProject()));
+ return ((FileSet) getRef(getProject())).clone();
} else {
- return new FileSet(this);
+ return super.clone();
}
}
1.20 +9 -2 ant/src/main/org/apache/tools/ant/types/FilterSet.java
Index: FilterSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/FilterSet.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FilterSet.java 10 Feb 2003 14:14:30 -0000 1.19
+++ FilterSet.java 27 May 2003 09:30:17 -0000 1.20
@@ -487,9 +487,16 @@
public Object clone() throws BuildException {
if (isReference()) {
- return new FilterSet(getRef());
+ return ((FilterSet) getRef()).clone();
} else {
- return new FilterSet(this);
+ try {
+ FilterSet fs = (FilterSet) super.clone();
+ fs.filters = (Vector) getFilters().clone();
+ fs.setProject(getProject());
+ return fs;
+ } catch (CloneNotSupportedException e) {
+ throw new BuildException(e);
+ }
}
}
1.49 +7 -3 ant/src/main/org/apache/tools/ant/types/Path.java
Index: Path.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Path.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- Path.java 4 Apr 2003 13:51:12 -0000 1.48
+++ Path.java 27 May 2003 09:30:17 -0000 1.49
@@ -457,9 +457,13 @@
* Return a Path that holds the same elements as this instance.
*/
public Object clone() {
- Path p = new Path(getProject());
- p.append(this);
- return p;
+ try {
+ Path p = (Path) super.clone();
+ p.elements = (Vector) elements.clone();
+ return p;
+ } catch (CloneNotSupportedException e) {
+ throw new BuildException(e);
+ }
}
/**
1.20 +2 -2 ant/src/main/org/apache/tools/ant/types/ZipFileSet.java
Index: ZipFileSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/ZipFileSet.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ZipFileSet.java 23 Apr 2003 07:20:17 -0000 1.19
+++ ZipFileSet.java 27 May 2003 09:30:17 -0000 1.20
@@ -310,9 +310,9 @@
*/
public Object clone() {
if (isReference()) {
- return new ZipFileSet((ZipFileSet) getRef(getProject()));
+ return ((ZipFileSet) getRef(getProject())).clone();
} else {
- return new ZipFileSet(this);
+ return super.clone();
}
}
}