31 |
|
import java.util.*; |
32 |
|
|
33 |
|
public class WrappedNull { |
34 |
< |
public static void main(String argv[]) throws Exception { |
35 |
< |
boolean testSucceeded = false; |
36 |
< |
try { |
37 |
< |
List l = Arrays.asList(null); |
38 |
< |
} |
39 |
< |
catch (NullPointerException e) { |
40 |
< |
testSucceeded = true; |
41 |
< |
} |
42 |
< |
if (!testSucceeded) |
43 |
< |
throw new Exception("Arrays.asList"); |
44 |
< |
|
45 |
< |
testSucceeded = false; |
46 |
< |
try { |
47 |
< |
Collection c = Collections.unmodifiableCollection(null); |
48 |
< |
} |
49 |
< |
catch (NullPointerException e) { |
50 |
< |
testSucceeded = true; |
51 |
< |
} |
52 |
< |
if (!testSucceeded) |
53 |
< |
throw new Exception("unmodifiableCollection"); |
54 |
< |
|
55 |
< |
testSucceeded = false; |
56 |
< |
try { |
57 |
< |
Set c = Collections.unmodifiableSet(null); |
58 |
< |
} |
59 |
< |
catch (NullPointerException e) { |
60 |
< |
testSucceeded = true; |
61 |
< |
} |
62 |
< |
if (!testSucceeded) |
63 |
< |
throw new Exception("unmodifiableSet"); |
64 |
< |
|
65 |
< |
testSucceeded = false; |
66 |
< |
try { |
67 |
< |
List c = Collections.unmodifiableList(null); |
68 |
< |
} |
69 |
< |
catch (NullPointerException e) { |
70 |
< |
testSucceeded = true; |
71 |
< |
} |
72 |
< |
if (!testSucceeded) |
73 |
< |
throw new Exception("unmodifiableList"); |
74 |
< |
|
75 |
< |
testSucceeded = false; |
76 |
< |
try { |
77 |
< |
Map c = Collections.unmodifiableMap(null); |
78 |
< |
} |
79 |
< |
catch (NullPointerException e) { |
80 |
< |
testSucceeded = true; |
81 |
< |
} |
82 |
< |
if (!testSucceeded) |
83 |
< |
throw new Exception("unmodifiableMap"); |
84 |
< |
|
85 |
< |
testSucceeded = false; |
86 |
< |
try { |
87 |
< |
SortedSet c = Collections.unmodifiableSortedSet(null); |
88 |
< |
} |
89 |
< |
catch (NullPointerException e) { |
90 |
< |
testSucceeded = true; |
91 |
< |
} |
92 |
< |
if (!testSucceeded) |
93 |
< |
throw new Exception("unmodifiableSortedSet"); |
94 |
< |
|
95 |
< |
testSucceeded = false; |
96 |
< |
try { |
97 |
< |
SortedMap c = Collections.unmodifiableSortedMap(null); |
98 |
< |
} |
99 |
< |
catch (NullPointerException e) { |
100 |
< |
testSucceeded = true; |
101 |
< |
} |
102 |
< |
if (!testSucceeded) |
103 |
< |
throw new Exception("unmodifiableSortedMap"); |
104 |
< |
|
105 |
< |
testSucceeded = false; |
106 |
< |
try { |
107 |
< |
Collection c = Collections.synchronizedCollection(null); |
108 |
< |
} |
109 |
< |
catch (NullPointerException e) { |
110 |
< |
testSucceeded = true; |
111 |
< |
} |
112 |
< |
if (!testSucceeded) |
113 |
< |
throw new Exception("synchronizedCollection"); |
114 |
< |
|
115 |
< |
testSucceeded = false; |
116 |
< |
try { |
117 |
< |
Set c = Collections.synchronizedSet(null); |
118 |
< |
} |
119 |
< |
catch (NullPointerException e) { |
120 |
< |
testSucceeded = true; |
121 |
< |
} |
122 |
< |
if (!testSucceeded) |
123 |
< |
throw new Exception("synchronizedSet"); |
124 |
< |
|
125 |
< |
testSucceeded = false; |
126 |
< |
try { |
127 |
< |
List c = Collections.synchronizedList(null); |
128 |
< |
} |
129 |
< |
catch (NullPointerException e) { |
130 |
< |
testSucceeded = true; |
131 |
< |
} |
132 |
< |
if (!testSucceeded) |
133 |
< |
throw new Exception("synchronizedList"); |
134 |
< |
|
135 |
< |
testSucceeded = false; |
136 |
< |
try { |
137 |
< |
Map c = Collections.synchronizedMap(null); |
138 |
< |
} |
139 |
< |
catch (NullPointerException e) { |
140 |
< |
testSucceeded = true; |
141 |
< |
} |
142 |
< |
if (!testSucceeded) |
143 |
< |
throw new Exception("synchronizedMap"); |
144 |
< |
|
145 |
< |
testSucceeded = false; |
146 |
< |
try { |
147 |
< |
SortedSet c = Collections.synchronizedSortedSet(null); |
148 |
< |
} |
149 |
< |
catch (NullPointerException e) { |
150 |
< |
testSucceeded = true; |
151 |
< |
} |
152 |
< |
if (!testSucceeded) |
153 |
< |
throw new Exception("synchronizedSortedSet"); |
154 |
< |
|
155 |
< |
testSucceeded = false; |
156 |
< |
try { |
157 |
< |
SortedMap c = Collections.synchronizedSortedMap(null); |
158 |
< |
} |
159 |
< |
catch (NullPointerException e) { |
160 |
< |
testSucceeded = true; |
161 |
< |
} |
162 |
< |
if (!testSucceeded) |
163 |
< |
throw new Exception("synchronizedSortedMap"); |
164 |
< |
|
165 |
< |
// Make sure that non-null arguments don't throw exc. |
166 |
< |
List l = Arrays.asList(new Object[0]); |
167 |
< |
Collection c = Collections.unmodifiableCollection( |
168 |
< |
Collections.EMPTY_SET); |
169 |
< |
Set s = Collections.unmodifiableSet(Collections.EMPTY_SET); |
170 |
< |
l = Collections.unmodifiableList(Collections.EMPTY_LIST); |
171 |
< |
Map m = Collections.unmodifiableMap(Collections.EMPTY_MAP); |
172 |
< |
SortedSet ss = Collections.unmodifiableSortedSet(new TreeSet()); |
173 |
< |
SortedMap sm = Collections.unmodifiableSortedMap(new TreeMap()); |
174 |
< |
|
175 |
< |
c = Collections.synchronizedCollection(Collections.EMPTY_SET); |
176 |
< |
s = Collections.synchronizedSet(Collections.EMPTY_SET); |
177 |
< |
l = Collections.synchronizedList(Collections.EMPTY_LIST); |
178 |
< |
m = Collections.synchronizedMap(Collections.EMPTY_MAP); |
179 |
< |
ss = Collections.synchronizedSortedSet(new TreeSet()); |
180 |
< |
sm = Collections.synchronizedSortedMap(new TreeMap()); |
181 |
< |
} |
34 |
> |
public static void main(String argv[]) throws Exception { |
35 |
> |
boolean testSucceeded = false; |
36 |
> |
try { |
37 |
> |
List l = Arrays.asList(null); |
38 |
> |
} |
39 |
> |
catch (NullPointerException e) { |
40 |
> |
testSucceeded = true; |
41 |
> |
} |
42 |
> |
if (!testSucceeded) |
43 |
> |
throw new Exception("Arrays.asList"); |
44 |
> |
|
45 |
> |
testSucceeded = false; |
46 |
> |
try { |
47 |
> |
Collection c = Collections.unmodifiableCollection(null); |
48 |
> |
} |
49 |
> |
catch (NullPointerException e) { |
50 |
> |
testSucceeded = true; |
51 |
> |
} |
52 |
> |
if (!testSucceeded) |
53 |
> |
throw new Exception("unmodifiableCollection"); |
54 |
> |
|
55 |
> |
testSucceeded = false; |
56 |
> |
try { |
57 |
> |
Set c = Collections.unmodifiableSet(null); |
58 |
> |
} |
59 |
> |
catch (NullPointerException e) { |
60 |
> |
testSucceeded = true; |
61 |
> |
} |
62 |
> |
if (!testSucceeded) |
63 |
> |
throw new Exception("unmodifiableSet"); |
64 |
> |
|
65 |
> |
testSucceeded = false; |
66 |
> |
try { |
67 |
> |
List c = Collections.unmodifiableList(null); |
68 |
> |
} |
69 |
> |
catch (NullPointerException e) { |
70 |
> |
testSucceeded = true; |
71 |
> |
} |
72 |
> |
if (!testSucceeded) |
73 |
> |
throw new Exception("unmodifiableList"); |
74 |
> |
|
75 |
> |
testSucceeded = false; |
76 |
> |
try { |
77 |
> |
Map c = Collections.unmodifiableMap(null); |
78 |
> |
} |
79 |
> |
catch (NullPointerException e) { |
80 |
> |
testSucceeded = true; |
81 |
> |
} |
82 |
> |
if (!testSucceeded) |
83 |
> |
throw new Exception("unmodifiableMap"); |
84 |
> |
|
85 |
> |
testSucceeded = false; |
86 |
> |
try { |
87 |
> |
SortedSet c = Collections.unmodifiableSortedSet(null); |
88 |
> |
} |
89 |
> |
catch (NullPointerException e) { |
90 |
> |
testSucceeded = true; |
91 |
> |
} |
92 |
> |
if (!testSucceeded) |
93 |
> |
throw new Exception("unmodifiableSortedSet"); |
94 |
> |
|
95 |
> |
testSucceeded = false; |
96 |
> |
try { |
97 |
> |
SortedMap c = Collections.unmodifiableSortedMap(null); |
98 |
> |
} |
99 |
> |
catch (NullPointerException e) { |
100 |
> |
testSucceeded = true; |
101 |
> |
} |
102 |
> |
if (!testSucceeded) |
103 |
> |
throw new Exception("unmodifiableSortedMap"); |
104 |
> |
|
105 |
> |
testSucceeded = false; |
106 |
> |
try { |
107 |
> |
Collection c = Collections.synchronizedCollection(null); |
108 |
> |
} |
109 |
> |
catch (NullPointerException e) { |
110 |
> |
testSucceeded = true; |
111 |
> |
} |
112 |
> |
if (!testSucceeded) |
113 |
> |
throw new Exception("synchronizedCollection"); |
114 |
> |
|
115 |
> |
testSucceeded = false; |
116 |
> |
try { |
117 |
> |
Set c = Collections.synchronizedSet(null); |
118 |
> |
} |
119 |
> |
catch (NullPointerException e) { |
120 |
> |
testSucceeded = true; |
121 |
> |
} |
122 |
> |
if (!testSucceeded) |
123 |
> |
throw new Exception("synchronizedSet"); |
124 |
> |
|
125 |
> |
testSucceeded = false; |
126 |
> |
try { |
127 |
> |
List c = Collections.synchronizedList(null); |
128 |
> |
} |
129 |
> |
catch (NullPointerException e) { |
130 |
> |
testSucceeded = true; |
131 |
> |
} |
132 |
> |
if (!testSucceeded) |
133 |
> |
throw new Exception("synchronizedList"); |
134 |
> |
|
135 |
> |
testSucceeded = false; |
136 |
> |
try { |
137 |
> |
Map c = Collections.synchronizedMap(null); |
138 |
> |
} |
139 |
> |
catch (NullPointerException e) { |
140 |
> |
testSucceeded = true; |
141 |
> |
} |
142 |
> |
if (!testSucceeded) |
143 |
> |
throw new Exception("synchronizedMap"); |
144 |
> |
|
145 |
> |
testSucceeded = false; |
146 |
> |
try { |
147 |
> |
SortedSet c = Collections.synchronizedSortedSet(null); |
148 |
> |
} |
149 |
> |
catch (NullPointerException e) { |
150 |
> |
testSucceeded = true; |
151 |
> |
} |
152 |
> |
if (!testSucceeded) |
153 |
> |
throw new Exception("synchronizedSortedSet"); |
154 |
> |
|
155 |
> |
testSucceeded = false; |
156 |
> |
try { |
157 |
> |
SortedMap c = Collections.synchronizedSortedMap(null); |
158 |
> |
} |
159 |
> |
catch (NullPointerException e) { |
160 |
> |
testSucceeded = true; |
161 |
> |
} |
162 |
> |
if (!testSucceeded) |
163 |
> |
throw new Exception("synchronizedSortedMap"); |
164 |
> |
|
165 |
> |
// Make sure that non-null arguments don't throw exc. |
166 |
> |
List l = Arrays.asList(new Object[0]); |
167 |
> |
Collection c = Collections.unmodifiableCollection( |
168 |
> |
Collections.EMPTY_SET); |
169 |
> |
Set s = Collections.unmodifiableSet(Collections.EMPTY_SET); |
170 |
> |
l = Collections.unmodifiableList(Collections.EMPTY_LIST); |
171 |
> |
Map m = Collections.unmodifiableMap(Collections.EMPTY_MAP); |
172 |
> |
SortedSet ss = Collections.unmodifiableSortedSet(new TreeSet()); |
173 |
> |
SortedMap sm = Collections.unmodifiableSortedMap(new TreeMap()); |
174 |
> |
|
175 |
> |
c = Collections.synchronizedCollection(Collections.EMPTY_SET); |
176 |
> |
s = Collections.synchronizedSet(Collections.EMPTY_SET); |
177 |
> |
l = Collections.synchronizedList(Collections.EMPTY_LIST); |
178 |
> |
m = Collections.synchronizedMap(Collections.EMPTY_MAP); |
179 |
> |
ss = Collections.synchronizedSortedSet(new TreeSet()); |
180 |
> |
sm = Collections.synchronizedSortedMap(new TreeMap()); |
181 |
> |
} |
182 |
|
} |