diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/LocalObjectImpl.java | 30 | ||||
-rw-r--r-- | java/src/Ice/ObjectImpl.java | 51 |
2 files changed, 13 insertions, 68 deletions
diff --git a/java/src/Ice/LocalObjectImpl.java b/java/src/Ice/LocalObjectImpl.java index 2e64986a148..939f5b86f65 100644 --- a/java/src/Ice/LocalObjectImpl.java +++ b/java/src/Ice/LocalObjectImpl.java @@ -10,7 +10,7 @@ package Ice; -public abstract class LocalObjectImpl implements LocalObject +public abstract class LocalObjectImpl implements LocalObject, java.lang.Cloneable { public boolean equals(java.lang.Object rhs) @@ -30,33 +30,7 @@ public abstract class LocalObjectImpl implements LocalObject clone() throws java.lang.CloneNotSupportedException { - LocalObject result = null; - - try - { - result = (LocalObject)getClass().newInstance(); - ((LocalObjectImpl)result).ice_copyStateFrom(this); - } - catch(InstantiationException ex) - { - CloneNotSupportedException e = new CloneNotSupportedException(); - e.initCause(ex); - throw e; - } - catch(IllegalAccessException ex) - { - CloneNotSupportedException e = new CloneNotSupportedException(); - e.initCause(ex); - throw e; - } - - return result; - } - - protected void - ice_copyStateFrom(LocalObject obj) - throws java.lang.CloneNotSupportedException - { + return super.clone(); } public int diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java index 724f13c161e..4ee185b34f7 100644 --- a/java/src/Ice/ObjectImpl.java +++ b/java/src/Ice/ObjectImpl.java @@ -10,7 +10,7 @@ package Ice; -public class ObjectImpl implements Object +public class ObjectImpl implements Object, java.lang.Cloneable { public ObjectImpl() @@ -35,57 +35,28 @@ public class ObjectImpl implements Object clone() throws java.lang.CloneNotSupportedException { - Object result = null; - - try - { - result = (Object)getClass().newInstance(); - ((ObjectImpl)result).ice_copyStateFrom(this); - } - catch(InstantiationException ex) - { - CloneNotSupportedException e = new CloneNotSupportedException(); - e.initCause(ex); - throw e; - } - catch(IllegalAccessException ex) - { - CloneNotSupportedException e = new CloneNotSupportedException(); - e.initCause(ex); - throw e; - } - - return result; - } - - protected final void - ice_cloneFacets(Object obj) - throws java.lang.CloneNotSupportedException - { // - // Clone facets. + // Use super.clone() to perform a shallow copy of all members, + // and then clone the facets manually. // - ObjectImpl impl = (ObjectImpl)obj; - synchronized(impl._activeFacetMap) + ObjectImpl result = (ObjectImpl)super.clone(); + + result._activeFacetMap = new java.util.HashMap(); + synchronized(_activeFacetMap) { - if(!impl._activeFacetMap.isEmpty()) + if(!_activeFacetMap.isEmpty()) { - java.util.Iterator p = impl._activeFacetMap.entrySet().iterator(); + java.util.Iterator p = _activeFacetMap.entrySet().iterator(); while(p.hasNext()) { java.util.Map.Entry e = (java.util.Map.Entry)p.next(); Object facet = (Object)e.getValue(); - _activeFacetMap.put(e.getKey(), facet.clone()); + result._activeFacetMap.put(e.getKey(), facet.clone()); } } } - } - protected void - ice_copyStateFrom(Object obj) - throws java.lang.CloneNotSupportedException - { - ice_cloneFacets(obj); + return result; } public int |