I've been curious how can a java.lang.InternalError or a java.lang.UnknownError be thrown.
I don't mean simply
throw new InternalError();
throw new UnknownError();
but one thrown by the Java SE library or JVM itself (with recent usual Oracle implementation).
For example, specific codes or circumstances that make ArrayList.clone really throw an InternalError is an answer I want. The following is its source code.
public Object clone() {
try {
ArrayList<?> v = (ArrayList<?>) super.clone();
v.elementData = Arrays.copyOf(elementData, size);
v.modCount = 0;
return v;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError(e);
}
}