From 2e921b803da0a2e9835be00f976fd306ab70fd98 Mon Sep 17 00:00:00 2001 From: Mike Jensen Date: Wed, 17 Jul 2013 11:53:35 -0600 Subject: [PATCH] Added a simple test to show the original issue --- test/Collections.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/Collections.java diff --git a/test/Collections.java b/test/Collections.java new file mode 100644 index 0000000000..d175318a4f --- /dev/null +++ b/test/Collections.java @@ -0,0 +1,26 @@ +import java.util.Collection; +import java.util.Map; + +public class Collections { + public static void main(String[] args) { + testValues(); + } + + @SuppressWarnings("rawtypes") + private static void testValues() { + Map testMap = java.util.Collections.unmodifiableMap(java.util.Collections.emptyMap()); + Collection values = testMap.values(); + + if (values == null) { + throw new NullPointerException(); + } + + try { + values.clear(); + + throw new IllegalStateException("Object should be immutable, exception should have thrown"); + } catch (Exception e) { + // expected + } + } +}