Consider the following code sample:
---
try {
Collections.emptyList().set(10, new Object());
} catch (UnsupportedOperationException e) {
System.err.println("UnsupportedOperationException thrown, telling that the set operation is not supported by this list");
}
Collections.emptyList().replaceAll(e -> e);
---
The output will be just
UnsupportedOperationException thrown, telling that the set operation is not supported by this list
On one hand empty list doesn't throw IndexOutOfBoundsException but throws UOE when calling set explicitly.
On the other hand it allows to call replaceAll() operation.
The following JCK tests will fail:
api/java_util/Collections/empty/EmptyListReplaceAll.html#EmptyListReplaceAll[elementSettingNotSupported]
api/java_util/Collections/empty/EMPTY_LISTReplaceAll.html#EMPTY_LISTReplaceAll[elementSettingNotSupported]
api/java_util/Collections/empty/EMPTY_LISTReplaceAll.html#EMPTY_LISTReplaceAll[elementSettingNotSupported_passingNull]
api/java_util/Collections/empty/EmptyListReplaceAll.html#EmptyListReplaceAll[elementSettingNotSupported_passingNull]