diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/resources/SystemRemoteResourceInfo.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/resources/SystemRemoteResourceInfo.java index a727629b43d..59cbc1f6dba 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/resources/SystemRemoteResourceInfo.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/resources/SystemRemoteResourceInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() *******************************************************************************/ package org.eclipse.rse.internal.files.ui.resources; @@ -21,7 +21,7 @@ package org.eclipse.rse.internal.files.ui.resources; * Class that keeps information about a remote resource. Clients should not * use this class. */ -public class SystemRemoteResourceInfo implements Cloneable { +public class SystemRemoteResourceInfo { diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarEntry.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarEntry.java index e31d76e65cb..59302adfee8 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarEntry.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TarEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() *******************************************************************************/ package org.eclipse.rse.internal.services.clientserver.archiveutils; @@ -530,22 +530,22 @@ public class TarEntry implements Cloneable { * @see java.lang.Object#clone() */ public Object clone() throws CloneNotSupportedException { - TarEntry newEntry = new TarEntry(getName()); - newEntry.mode = this.mode; - newEntry.uid = this.uid; - newEntry.gid = this.gid; - newEntry.size = this.size; - newEntry.mtime = this.mtime; - newEntry.chksum = this.chksum; - newEntry.typeflag = this.typeflag; - newEntry.linkname = this.linkname; - newEntry.magic = this.magic; - newEntry.version = this.version; - newEntry.uname = this.uname; - newEntry.gname = this.gname; - newEntry.devmajor = this.devmajor; - newEntry.devminor = this.devminor; - newEntry.prefix = this.prefix; + TarEntry newEntry = (TarEntry)super.clone(); + newEntry.mode = (byte[])this.mode.clone(); + newEntry.uid = (byte[])this.uid.clone(); + newEntry.gid = (byte[])this.gid.clone(); + newEntry.size = (byte[])this.size.clone(); + newEntry.mtime = (byte[])this.mtime.clone(); + newEntry.chksum = (byte[])this.chksum.clone(); + //newEntry.typeflag = this.typeflag; + newEntry.linkname = (byte[])this.linkname.clone(); + newEntry.magic = (byte[])this.magic.clone(); + newEntry.version = (byte[])this.version.clone(); + newEntry.uname = (byte[])this.uname.clone(); + newEntry.gname = (byte[])this.gname.clone(); + newEntry.devmajor = (byte[])this.devmajor.clone(); + newEntry.devminor = (byte[])this.devminor.clone(); + newEntry.prefix = (byte[])this.prefix.clone(); return newEntry; } } diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/processes/HostProcessFilterImpl.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/processes/HostProcessFilterImpl.java index e8e9b89c4eb..b27fadfb1c4 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/processes/HostProcessFilterImpl.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/processes/HostProcessFilterImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() *******************************************************************************/ package org.eclipse.rse.services.clientserver.processes; @@ -36,7 +36,11 @@ import org.eclipse.rse.services.clientserver.NamePatternMatcher; * * * To get the actual filter string back from objects of this class, just call {@link #toString()}. - * + *

+ * Clients may use or subclass this class. When subclassing, clients need to + * ensure that the subclass is always capable of performing a deep clone + * operation with the {@link #clone()} method, so if they add fields of + * complex type, these need to be dealt with by overriding {@link #clone()}. */ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable { @@ -445,6 +449,7 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable public boolean getSpecificState(String stateCode) { + if (anystatus) return true; Boolean state = (Boolean) states.get(stateCode); if (state == null) return false; return state.booleanValue(); @@ -453,6 +458,7 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable public void setSpecificState(String stateCode) { anystatus = false; + initStates(); states.put(stateCode, new Boolean(true)); } @@ -474,4 +480,26 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable } return true; } + + /** + * Return an identical (deep) copy of this filter. + * + * Subclasses must ensure that such a deep copy operation is always + * possible, so their state must always be cloneable. Which should + * always be possible to achieve, since this Object also needs to be + * serializable. + */ + public Object clone() { + HostProcessFilterImpl clone = null; + try { + clone = (HostProcessFilterImpl)super.clone(); + } catch (CloneNotSupportedException e) { + //assert false; //can never happen + throw new RuntimeException(e); + } + if (states!=null) { + clone.states = (HashMap)states.clone(); + } + return clone; + } } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java index c460bf289d1..242372db605 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) - [208951] new priority field * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core.model; @@ -159,7 +160,8 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap return super.clone(); } catch (CloneNotSupportedException e) { - return null; + //assert false; //can never happen + throw new RuntimeException(e); } } } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java index ff2c687b313..1e297d36331 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.model; @@ -405,7 +405,9 @@ public class RemoteFileFilterString implements Cloneable * Clone this into another filter string object with the same attributes. * * Subclasses must ensure that such a deep copy operation is always - * possible, so their state must always be cloneable. + * possible, so their state must always be cloneable. Which should + * always be possible to achieve, since this Object also needs to be + * serializable. */ public Object clone() { diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java index 2f2bb4cf59d..b91cdf79220 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java @@ -18,6 +18,7 @@ * David McKnight (IBM) - [209660] use parent encoding as default, rather than system encoding * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandFilterString.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandFilterString.java index b2876cdb3ae..82e6aa26a2a 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandFilterString.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandFilterString.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() ********************************************************************************/ package org.eclipse.rse.subsystems.shells.core.model; @@ -42,6 +42,11 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystemConf *

* It is invalid to have both a comma and an asterisk in the same filter string. * It is also invalid to have both a comma and a period in the same filter string. + *

+ * Clients may use or subclass this class. When subclassing, clients need to + * ensure that the subclass is always capable of performing a deep clone + * operation with the {@link #clone()} method, so if they add fields of + * complex type, these need to be dealt with by overriding {@link #clone()}. */ public class RemoteCommandFilterString implements Cloneable { @@ -140,7 +145,7 @@ public class RemoteCommandFilterString implements Cloneable } /** - * De-hydrate into a string capturing all the attributes + * Serialize into a string capturing all the attributes */ public String toString() { @@ -149,17 +154,25 @@ public class RemoteCommandFilterString implements Cloneable /** * Clone this into another filter string object with the same attributes. + * + * Subclasses must ensure that such a deep copy operation is always + * possible, so their state must always be cloneable. Which should + * always be possible to achieve, since this Object also needs to be + * serializable. */ public Object clone() { - RemoteCommandFilterString copy = new RemoteCommandFilterString(); - copy.shellStr = shellStr; - copy.filterByTypes = filterByTypes; + RemoteCommandFilterString copy = null; + try { + copy = (RemoteCommandFilterString)super.clone(); + } catch(CloneNotSupportedException e) { + //assert false; //can never happen + throw new RuntimeException(e); + } if (types!=null) { - copy.types = new String[types.length]; - for (int idx=0; idx