Clean up CloneNotSupportedException handling in Cloneables.
Wrap it in an AssertionError. I looked to Java sources to see what the best practice was: Sometimes it's ignored, sometimes an InternalError is thrown, sometimes an AssertionError without the "cause", but sometimes this pattern, which is clearly the best of those. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2660 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -144,7 +144,7 @@ public class FieldMask
|
||||
mask._modified = new boolean[_modified.length];
|
||||
return mask;
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
throw new RuntimeException("Oh god, the clones!");
|
||||
throw new AssertionError(cnse); // won't happen; we're Cloneable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ public class ArrayIntSet extends AbstractIntSet
|
||||
return nset;
|
||||
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
throw new RuntimeException("Internal clone error.");
|
||||
throw new AssertionError(cnse); // won't happen; we're Cloneable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ import java.util.RandomAccess;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
|
||||
/**
|
||||
* Provides a base for extending the standard Java {@link ArrayList}
|
||||
* functionality (which we'd just extend directly if those pig fuckers hadn't
|
||||
@@ -177,8 +175,7 @@ public abstract class BaseArrayList<E> extends AbstractList<E>
|
||||
return dup;
|
||||
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
log.warning("clone failed", cnse); // won't happen.
|
||||
return null;
|
||||
throw new AssertionError(cnse); // won't happen; we are Cloneable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
|
||||
return result;
|
||||
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
throw new RuntimeException(cnse); // won't happen
|
||||
throw new AssertionError(cnse); // won't happen; we're Cloneable
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ public class HashIntMap<V> extends AbstractMap<Integer,V>
|
||||
return result;
|
||||
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
throw new RuntimeException(cnse); // won't happen
|
||||
throw new AssertionError(cnse); // won't happen; we are Cloneable.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user