Warnings.
1.1 --- a/openide.util/src/org/openide/util/lookup/ArrayStorage.java Fri Oct 09 13:53:04 2009 -0400
1.2 +++ b/openide.util/src/org/openide/util/lookup/ArrayStorage.java Fri Oct 09 15:11:13 2009 -0400
1.3 @@ -223,6 +223,7 @@
1.4 class JustPairs implements Enumeration<Pair<T>> {
1.5 private Pair<T> next;
1.6
1.7 + @SuppressWarnings("unchecked")
1.8 private Pair<T> findNext() {
1.9 for (;;) {
1.10 if (next != null) {
1.11 @@ -234,7 +235,7 @@
1.12 Object o = all.nextElement();
1.13 boolean ok;
1.14 if (o instanceof AbstractLookup.Pair) {
1.15 - ok = (clazz == null) || ((AbstractLookup.Pair) o).instanceOf(clazz);
1.16 + ok = (clazz == null) || ((AbstractLookup.Pair<?>) o).instanceOf(clazz);
1.17 } else {
1.18 ok = false;
1.19 }
1.20 @@ -366,23 +367,23 @@
1.21
1.22 public Transaction(int ensure, Object currentContent) {
1.23 Integer trashold;
1.24 - Object[] arr;
1.25 + Object[] _arr;
1.26
1.27 if (currentContent instanceof Integer) {
1.28 trashold = (Integer) currentContent;
1.29 - arr = null;
1.30 + _arr = null;
1.31 } else {
1.32 - arr = (Object[]) currentContent;
1.33 + _arr = (Object[]) currentContent;
1.34
1.35 - if (arr[arr.length - 1] instanceof Integer) {
1.36 - trashold = (Integer) arr[arr.length - 1];
1.37 + if (_arr[_arr.length - 1] instanceof Integer) {
1.38 + trashold = (Integer) _arr[_arr.length - 1];
1.39 } else {
1.40 // nowhere to grow we have reached the limit
1.41 trashold = null;
1.42 }
1.43 }
1.44
1.45 - int maxSize = (trashold == null) ? arr.length : trashold.intValue();
1.46 + int maxSize = (trashold == null) ? _arr.length : trashold.intValue();
1.47
1.48 if (ensure > maxSize) {
1.49 throw new UnsupportedOperationException();
1.50 @@ -398,19 +399,19 @@
1.51
1.52 if (ensure == -2) {
1.53 // adding one
1.54 - if (arr == null) {
1.55 + if (_arr == null) {
1.56 // first time add, let's allocate the array
1.57 - arr = new Object[2];
1.58 - arr[1] = trashold;
1.59 + _arr = new Object[2];
1.60 + _arr[1] = trashold;
1.61 } else {
1.62 - if (arr[arr.length - 1] instanceof AbstractLookup.Pair) {
1.63 + if (_arr[_arr.length - 1] instanceof AbstractLookup.Pair) {
1.64 // we are full
1.65 throw new UnsupportedOperationException();
1.66 } else {
1.67 // ensure we have allocated enough space
1.68 - if (arr.length < 2 || arr[arr.length - 2] != null) {
1.69 + if (_arr.length < 2 || _arr[_arr.length - 2] != null) {
1.70 // double the array
1.71 - int newSize = (arr.length - 1) * 2;
1.72 + int newSize = (_arr.length - 1) * 2;
1.73
1.74 if (newSize <= 1) {
1.75 newSize = 2;
1.76 @@ -419,26 +420,26 @@
1.77 if (newSize > maxSize) {
1.78 newSize = maxSize;
1.79
1.80 - if (newSize <= arr.length) {
1.81 + if (newSize <= _arr.length) {
1.82 // no space to get in
1.83 throw new UnsupportedOperationException();
1.84 }
1.85
1.86 - arr = new Object[newSize];
1.87 + _arr = new Object[newSize];
1.88 } else {
1.89 // still a lot of space
1.90 - arr = new Object[newSize + 1];
1.91 - arr[newSize] = trashold;
1.92 + _arr = new Object[newSize + 1];
1.93 + _arr[newSize] = trashold;
1.94 }
1.95
1.96 // copy content of original array without the last Integer into
1.97 // the new one
1.98 - System.arraycopy(currentContent, 0, arr, 0, ((Object[]) currentContent).length - 1);
1.99 + System.arraycopy(currentContent, 0, _arr, 0, ((Object[]) currentContent).length - 1);
1.100 }
1.101 }
1.102 }
1.103
1.104 - this.current = arr;
1.105 + this.current = _arr;
1.106 this.arr = null;
1.107 } else {
1.108 // allocate array for complete replacement
2.1 --- a/openide.util/test/unit/src/org/openide/util/EnumerationsTest.java Fri Oct 09 13:53:04 2009 -0400
2.2 +++ b/openide.util/test/unit/src/org/openide/util/EnumerationsTest.java Fri Oct 09 15:11:13 2009 -0400
2.3 @@ -41,19 +41,17 @@
2.4
2.5 package org.openide.util;
2.6
2.7 -import java.lang.ref.WeakReference;
2.8 import java.util.ArrayList;
2.9 import java.util.Arrays;
2.10 import java.util.Collection;
2.11 import java.util.Collections;
2.12 import java.util.Enumeration;
2.13 import java.util.Iterator;
2.14 +import java.util.List;
2.15 import java.util.Map;
2.16 import java.util.NoSuchElementException;
2.17 import java.util.Set;
2.18 -import junit.textui.TestRunner;
2.19 import org.netbeans.junit.NbTestCase;
2.20 -import org.netbeans.junit.NbTestSuite;
2.21
2.22 /** This is the base test for new and old enumerations. It contains
2.23 * factory methods for various kinds of enumerations and set of tests
2.24 @@ -72,54 +70,50 @@
2.25 // Factory methods
2.26 //
2.27
2.28 - protected Enumeration singleton(Object obj) {
2.29 + protected <T> Enumeration<T> singleton(T obj) {
2.30 return Enumerations.singleton(obj);
2.31 }
2.32 - protected Enumeration concat(Enumeration en1, Enumeration en2) {
2.33 + protected <T> Enumeration<T> concat(Enumeration<T> en1, Enumeration<T> en2) {
2.34 return Enumerations.concat(en1, en2);
2.35 }
2.36 - protected Enumeration concat(Enumeration enumOfEnums) {
2.37 + protected <T> Enumeration<T> concat(Enumeration<Enumeration<T>> enumOfEnums) {
2.38 return Enumerations.concat(enumOfEnums);
2.39 }
2.40 - protected Enumeration removeDuplicates(Enumeration en) {
2.41 + protected <T> Enumeration<T> removeDuplicates(Enumeration<T> en) {
2.42 return Enumerations.removeDuplicates(en);
2.43 }
2.44 - protected Enumeration empty() {
2.45 + protected <T> Enumeration<T> empty() {
2.46 return Enumerations.empty();
2.47 }
2.48 - protected Enumeration array(Object[] arr) {
2.49 + protected <T> Enumeration<T> array(T[] arr) {
2.50 return Enumerations.array(arr);
2.51 }
2.52 - protected Enumeration convert(Enumeration en, final Map map) {
2.53 - class P implements Enumerations.Processor {
2.54 - public Object process(Object obj, Collection nothing) {
2.55 + protected <T,R> Enumeration<R> convert(Enumeration<T> en, final Map<T,R> map) {
2.56 + class P implements Enumerations.Processor<T,R> {
2.57 + public R process(T obj, Collection<T> nothing) {
2.58 return map.get(obj);
2.59 }
2.60 }
2.61 -
2.62 -
2.63 return Enumerations.convert(en, new P());
2.64 }
2.65 - protected Enumeration removeNulls(Enumeration en) {
2.66 + protected <T> Enumeration<T> removeNulls(Enumeration<T> en) {
2.67 return Enumerations.removeNulls(en);
2.68 }
2.69 - protected Enumeration filter(Enumeration en, final Set filter) {
2.70 - class P implements Enumerations.Processor {
2.71 - public Object process(Object obj, Collection nothing) {
2.72 + protected <T> Enumeration<T> filter(Enumeration<T> en, final Set<T> filter) {
2.73 + class P implements Enumerations.Processor<T,T> {
2.74 + public T process(T obj, Collection<T> nothing) {
2.75 return filter.contains(obj) ? obj : null;
2.76 }
2.77 }
2.78 -
2.79 return Enumerations.filter(en, new P());
2.80 }
2.81
2.82 - protected Enumeration filter(Enumeration en, final QueueProcess filter) {
2.83 - class P implements Enumerations.Processor {
2.84 - public Object process(Object obj, Collection nothing) {
2.85 + protected <T,R> Enumeration<R> filter(Enumeration<T> en, final QueueProcess<T,R> filter) {
2.86 + class P implements Enumerations.Processor<T,R> {
2.87 + public R process(T obj, Collection<T> nothing) {
2.88 return filter.process(obj, nothing);
2.89 }
2.90 }
2.91 -
2.92 return Enumerations.filter(en, new P());
2.93 }
2.94
2.95 @@ -127,9 +121,9 @@
2.96 * @param filter the set.contains (...) is called before each object is produced
2.97 * @return Enumeration
2.98 */
2.99 - protected Enumeration queue(Collection initContent, final QueueProcess process) {
2.100 - class C implements Enumerations.Processor {
2.101 - public Object process(Object object, Collection toAdd) {
2.102 + protected <T,R> Enumeration<R> queue(Collection<T> initContent, final QueueProcess<T,R> process) {
2.103 + class C implements Enumerations.Processor<T,R> {
2.104 + public R process(T object, Collection<T> toAdd) {
2.105 return process.process(object, toAdd);
2.106 }
2.107 }
2.108 @@ -141,8 +135,8 @@
2.109
2.110 /** Processor interface.
2.111 */
2.112 - public static interface QueueProcess {
2.113 - public Object process(Object object, Collection toAdd);
2.114 + public static interface QueueProcess<T,R> {
2.115 + public R process(T object, Collection<T> toAdd);
2.116 }
2.117
2.118 //
2.119 @@ -174,10 +168,10 @@
2.120 }
2.121
2.122 public void testConcatTwoAndArray() {
2.123 - Object[] one = { new Integer(1), new Integer(2), new Integer(3) };
2.124 + Object[] one = { 1, 2, 3 };
2.125 Object[] two = { "1", "2", "3" };
2.126
2.127 - ArrayList list = new ArrayList(Arrays.asList(one));
2.128 + List<Object> list = new ArrayList<Object>(Arrays.asList(one));
2.129 list.addAll(Arrays.asList(two));
2.130
2.131 assertEnums(
2.132 @@ -187,15 +181,16 @@
2.133 }
2.134
2.135 public void testConcatTwoAndArrayAndTakeOnlyStrings() {
2.136 - Object[] one = { new Integer(1), new Integer(2), new Integer(3) };
2.137 + Object[] one = { 1, 2, 3 };
2.138 Object[] two = { "1", "2", "3" };
2.139 - Object[] three = { new Long(1) };
2.140 + Object[] three = { 1L };
2.141 Object[] four = { "Kuk" };
2.142
2.143 - ArrayList list = new ArrayList(Arrays.asList(two));
2.144 + List<Object> list = new ArrayList<Object>(Arrays.asList(two));
2.145 list.addAll(Arrays.asList(four));
2.146
2.147 - Enumeration[] alls = {
2.148 + @SuppressWarnings("unchecked")
2.149 + Enumeration<Object>[] alls = (Enumeration<Object>[]) new Enumeration<?>[] {
2.150 array(one), array(two), array(three), array(four)
2.151 };
2.152
2.153 @@ -206,18 +201,19 @@
2.154 }
2.155
2.156 public void testRemoveDuplicates() {
2.157 - Object[] one = { new Integer(1), new Integer(2), new Integer(3) };
2.158 + Object[] one = { 1, 2, 3 };
2.159 Object[] two = { "1", "2", "3" };
2.160 - Object[] three = { new Integer(1) };
2.161 + Object[] three = { 1 };
2.162 Object[] four = { "2", "3", "4" };
2.163
2.164 - Enumeration[] alls = {
2.165 + @SuppressWarnings("unchecked")
2.166 + Enumeration<Object>[] alls = (Enumeration<Object>[]) new Enumeration<?>[] {
2.167 array(one), array(two), array(three), array(four)
2.168 };
2.169
2.170 assertEnums(
2.171 removeDuplicates(concat(array(alls))),
2.172 - array(new Object[] { new Integer(1), new Integer(2), new Integer(3), "1", "2", "3", "4" })
2.173 + array(new Object[] { 1, 2, 3, "1", "2", "3", "4" })
2.174 );
2.175
2.176 }
2.177 @@ -225,7 +221,7 @@
2.178 public void testRemoveDuplicatesAndGCWorks() {
2.179
2.180 /*** Return { i1, "", "", "", i2 } */
2.181 - class WeakEnum implements Enumeration {
2.182 + class WeakEnum implements Enumeration<Object> {
2.183 public Object i1 = new Integer(1);
2.184 public Object i2 = new Integer(1);
2.185
2.186 @@ -249,15 +245,19 @@
2.187
2.188 assertTrue("Has some elements", en.hasMoreElements());
2.189 assertEquals("And the first one is get", weak.i1, en.nextElement());
2.190 -
2.191 +
2.192 + /*
2.193 try {
2.194 - WeakReference ref = new WeakReference(weak.i1);
2.195 + Reference<?> ref = new WeakReference<Object>(weak.i1);
2.196 + */
2.197 weak.i1 = null;
2.198 + /*
2.199 assertGC("Try hard to GC the first integer", ref);
2.200 // does not matter whether it GCs or not
2.201 } catch (Throwable tw) {
2.202 // not GCed, but does not matter
2.203 }
2.204 + */
2.205 assertTrue("Next object will be string", en.hasMoreElements());
2.206 assertEquals("is empty string", "", en.nextElement());
2.207
2.208 @@ -266,12 +266,11 @@
2.209 }
2.210
2.211 public void testQueueEnum() {
2.212 - class Pr implements QueueProcess {
2.213 - public Object process(Object o, Collection c) {
2.214 - Integer i = (Integer)o;
2.215 - int plus = i.intValue() + 1;
2.216 + class Pr implements QueueProcess<Integer,Integer> {
2.217 + public Integer process(Integer i, Collection<Integer> c) {
2.218 + int plus = i + 1;
2.219 if (plus < 10) {
2.220 - c.add(new Integer(plus));
2.221 + c.add(plus);
2.222 }
2.223 return i;
2.224 }
2.225 @@ -279,7 +278,7 @@
2.226 Pr p = new Pr();
2.227
2.228 Enumeration en = queue(
2.229 - Collections.nCopies(1, new Integer(0)), p
2.230 + Collections.nCopies(1, 0), p
2.231 );
2.232
2.233 for (int i = 0; i < 10; i++) {
2.234 @@ -291,17 +290,15 @@
2.235 }
2.236
2.237 public void testFilteringAlsoDoesConvertions() throws Exception {
2.238 - class Pr implements QueueProcess {
2.239 - public Object process(Object o, Collection ignore) {
2.240 - Integer i = (Integer)o;
2.241 - int plus = i.intValue() + 1;
2.242 - return new Integer(plus);
2.243 + class Pr implements QueueProcess<Integer,Integer> {
2.244 + public Integer process(Integer i, Collection<Integer> ignore) {
2.245 + return i + 1;
2.246 }
2.247 }
2.248 Pr p = new Pr();
2.249
2.250 - Enumeration onetwo = array(new Object[] { new Integer(1), new Integer(2) });
2.251 - Enumeration twothree = array(new Object[] { new Integer(2), new Integer(3) });
2.252 + Enumeration<Integer> onetwo = array(new Integer[] { 1, 2 });
2.253 + Enumeration<Integer> twothree = array(new Integer[] { 2, 3 });
2.254
2.255 assertEnums(
2.256 filter(onetwo, p), twothree
2.257 @@ -309,11 +306,11 @@
2.258 }
2.259
2.260
2.261 - private static void assertEnums(Enumeration e1, Enumeration e2) {
2.262 + private static <T> void assertEnums(Enumeration<T> e1, Enumeration<T> e2) {
2.263 int indx = 0;
2.264 while (e1.hasMoreElements() && e2.hasMoreElements()) {
2.265 - Object i1 = e1.nextElement();
2.266 - Object i2 = e2.nextElement();
2.267 + T i1 = e1.nextElement();
2.268 + T i2 = e2.nextElement();
2.269 assertEquals(indx++ + "th: ", i1, i2);
2.270 }
2.271
2.272 @@ -340,7 +337,7 @@
2.273 }
2.274
2.275 public void testConvertIntegersToStringRemoveNulls() {
2.276 - Object[] garbage = { new Integer(1), "kuk", "hle", new Integer(5) };
2.277 + Object[] garbage = { 1, "kuk", "hle", 5 };
2.278
2.279 assertEnums(
2.280 removeNulls(convert(array(garbage), new MapIntegers())),
2.281 @@ -351,8 +348,8 @@
2.282 public void testQueueEnumerationCanReturnNulls() {
2.283 Object[] nuls = { null, "NULL" };
2.284
2.285 - class P implements QueueProcess {
2.286 - public Object process(Object toRet, Collection toAdd) {
2.287 + class P implements QueueProcess<Object,Object> {
2.288 + public Object process(Object toRet, Collection<Object> toAdd) {
2.289 if (toRet == null) return null;
2.290
2.291 if ("NULL".equals(toRet)) {
2.292 @@ -372,7 +369,7 @@
2.293
2.294 /** Filters only strings.
2.295 */
2.296 - private static final class OnlyStrings implements Set {
2.297 + private static final class OnlyStrings implements Set<Object> {
2.298 public boolean add(Object o) {
2.299 fail("Should not be every called");
2.300 return false;
2.301 @@ -401,7 +398,7 @@
2.302 return false;
2.303 }
2.304
2.305 - public Iterator iterator() {
2.306 + public Iterator<Object> iterator() {
2.307 fail("Should not be every called");
2.308 return null;
2.309 }
2.310 @@ -431,7 +428,7 @@
2.311 return null;
2.312 }
2.313
2.314 - public Object[] toArray(Object[] a) {
2.315 + public <T> T[] toArray(T[] a) {
2.316 fail("Should not be every called");
2.317 return null;
2.318 }
2.319 @@ -439,7 +436,7 @@
2.320
2.321 /** Filters only strings.
2.322 */
2.323 - private static final class MapIntegers implements Map {
2.324 + private static final class MapIntegers implements Map<Object,Object> {
2.325 public boolean containsKey(Object key) {
2.326 fail("Should not be every called");
2.327 return false;
2.328 @@ -450,7 +447,7 @@
2.329 return false;
2.330 }
2.331
2.332 - public Set entrySet() {
2.333 + public Set<Map.Entry<Object,Object>> entrySet() {
2.334 fail("Should not be every called");
2.335 return null;
2.336 }
2.337 @@ -462,7 +459,7 @@
2.338 return null;
2.339 }
2.340
2.341 - public Set keySet() {
2.342 + public Set<Object> keySet() {
2.343 fail("Should not be every called");
2.344 return null;
2.345 }
2.346 @@ -476,7 +473,7 @@
2.347 fail("Should not be every called");
2.348 }
2.349
2.350 - public Collection values() {
2.351 + public Collection<Object> values() {
2.352 fail("Should not be every called");
2.353 return null;
2.354 }
3.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java Fri Oct 09 13:53:04 2009 -0400
3.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java Fri Oct 09 15:11:13 2009 -0400
3.3 @@ -45,21 +45,27 @@
3.4 import java.io.ByteArrayOutputStream;
3.5 import java.io.ObjectInputStream;
3.6 import java.io.ObjectOutputStream;
3.7 +import java.io.Serializable;
3.8 +import java.lang.ref.WeakReference;
3.9 +import java.lang.ref.Reference;
3.10 +import java.util.ArrayList;
3.11 +import java.util.Arrays;
3.12 +import java.util.Collection;
3.13 +import java.util.Collections;
3.14 +import java.util.Iterator;
3.15 +import java.util.LinkedList;
3.16 +import java.util.List;
3.17 +import java.util.concurrent.Executors;
3.18 +import java.util.concurrent.TimeUnit;
3.19 import javax.swing.ActionMap;
3.20 import javax.swing.InputMap;
3.21 -
3.22 -import java.lang.ref.WeakReference;
3.23 -import java.util.*;
3.24 -import org.netbeans.junit.*;
3.25 -import java.io.Serializable;
3.26 -import java.lang.ref.Reference;
3.27 -import java.util.concurrent.Executors;
3.28 -import java.util.concurrent.TimeUnit;
3.29 +import org.netbeans.junit.NbTestCase;
3.30 import org.openide.util.Lookup;
3.31 import org.openide.util.Lookup.Template;
3.32 import org.openide.util.LookupEvent;
3.33 import org.openide.util.LookupListener;
3.34
3.35 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
3.36 public class AbstractLookupBaseHid extends NbTestCase {
3.37 private static AbstractLookupBaseHid running;
3.38
3.39 @@ -72,7 +78,7 @@
3.40 /** implementation of methods that can influence the behaviour */
3.41 Impl impl;
3.42
3.43 - protected AbstractLookupBaseHid(java.lang.String testName, Impl impl) {
3.44 + protected AbstractLookupBaseHid(String testName, Impl impl) {
3.45 super(testName);
3.46 if (impl == null && (this instanceof Impl)) {
3.47 impl = (Impl)this;
3.48 @@ -80,7 +86,7 @@
3.49 this.impl = impl;
3.50 }
3.51
3.52 - protected void setUp () {
3.53 + protected @Override void setUp() {
3.54 this.ic = new InstanceContent ();
3.55
3.56 beforeActualTest(getName());
3.57 @@ -90,7 +96,7 @@
3.58 running = this;
3.59 }
3.60
3.61 - protected void tearDown () {
3.62 + protected @Override void tearDown() {
3.63 running = null;
3.64 }
3.65
3.66 @@ -129,18 +135,18 @@
3.67 /** Test if first is really first.
3.68 */
3.69 public void testFirst () {
3.70 - Object i1 = new Integer (1);
3.71 - Object i2 = new Integer (2);
3.72 + Integer i1 = 1;
3.73 + Integer i2 = 2;
3.74
3.75 ic.add (i1);
3.76 ic.add (i2);
3.77
3.78 - Object found = lookup.lookup (Integer.class);
3.79 + Integer found = lookup.lookup(Integer.class);
3.80 if (found != i1) {
3.81 fail ("First object is not first: " + found + " != " + i1);
3.82 }
3.83
3.84 - ArrayList list = new ArrayList ();
3.85 + List<Integer> list = new ArrayList<Integer>();
3.86 list.add (i2);
3.87 list.add (i1);
3.88 ic.set (list, null);
3.89 @@ -168,7 +174,7 @@
3.90 fail ("First object in intances not found");
3.91 }
3.92
3.93 - Iterator all = lookup.lookup (new Lookup.Template (Object.class)).allInstances ().iterator ();
3.94 + Iterator<?> all = lookup.lookupAll(Object.class).iterator();
3.95 checkIterator ("Difference between instances added and found", all, Arrays.asList (INSTANCES));
3.96 }
3.97
3.98 @@ -185,7 +191,7 @@
3.99 Runnable r2 = new Runnable () {
3.100 public void run () {}
3.101 };
3.102 - ArrayList l = new ArrayList ();
3.103 + List<Object> l = new ArrayList<Object>();
3.104
3.105 l.add (s1);
3.106 l.add (s2);
3.107 @@ -210,16 +216,16 @@
3.108 ic.add ("A serializable string");
3.109 lookup.lookup (Serializable.class);
3.110
3.111 - ic.set (Collections.EMPTY_LIST, null);
3.112 + ic.set (Collections.emptyList(), null);
3.113 }
3.114
3.115 /** Tests a more complex reorder on nodes.
3.116 */
3.117 public void testComplexReorder () {
3.118 - Integer i1 = new Integer (1);
3.119 - Long i2 = new Long (2);
3.120 + Integer i1 = 1;
3.121 + Long i2 = 2L;
3.122
3.123 - ArrayList l = new ArrayList ();
3.124 + List<Object> l = new ArrayList<Object>();
3.125 l.add (i1);
3.126 l.add (i2);
3.127 ic.set (l, null);
3.128 @@ -241,12 +247,12 @@
3.129 */
3.130 public void testSetPairs () {
3.131 // test setPairs method
3.132 - ArrayList li = new ArrayList();
3.133 + List<Object> li = new ArrayList<Object>();
3.134 li.addAll (Arrays.asList (INSTANCES));
3.135 ic.set (li, null);
3.136
3.137 - Lookup.Result res = lookup.lookup (new Lookup.Template (Object.class));
3.138 - Iterator all = res.allInstances ().iterator ();
3.139 + Lookup.Result<Object> res = lookup.lookupResult(Object.class);
3.140 + Iterator<?> all = res.allInstances().iterator();
3.141 checkIterator ("Original order not kept", all, li);
3.142
3.143 // reverse the order
3.144 @@ -268,23 +274,23 @@
3.145 */
3.146 public void testSetPairsFire () {
3.147 // test setPairs method
3.148 - ArrayList li = new ArrayList();
3.149 + List<Object> li = new ArrayList<Object>();
3.150 li.addAll (Arrays.asList (INSTANCES));
3.151 ic.set (li, null);
3.152
3.153 - Lookup.Result res = lookup.lookup (new Lookup.Template (Integer.class));
3.154 - Iterator all = res.allInstances ().iterator ();
3.155 + Lookup.Result<Integer> res = lookup.lookupResult(Integer.class);
3.156 + Iterator<?> all = res.allInstances().iterator();
3.157 checkIterator ("Integer is not there", all, Collections.nCopies (1, INSTANCES[0]));
3.158
3.159 // change the pairs
3.160 LL listener = new LL (res);
3.161 res.addLookupListener (listener);
3.162
3.163 - ArrayList l2 = new ArrayList (li);
3.164 + List<Object> l2 = new ArrayList<Object>(li);
3.165 l2.remove (INSTANCES[0]);
3.166 ic.set (l2, null);
3.167
3.168 - all = lookup.lookup (new Lookup.Template (Object.class)).allInstances ().iterator ();
3.169 + all = lookup.lookupAll(Object.class).iterator();
3.170 checkIterator ("The removed integer is not noticed", all, l2);
3.171
3.172 if (listener.getCount () != 1) {
3.173 @@ -297,24 +303,24 @@
3.174 public void testSetPairsDoesNotFire () {
3.175 Object tmp = new Object ();
3.176
3.177 - ArrayList li = new ArrayList();
3.178 + List<Object> li = new ArrayList<Object>();
3.179 li.add (tmp);
3.180 li.addAll (Arrays.asList (INSTANCES));
3.181 ic.set (li, null);
3.182
3.183 - Lookup.Result res = lookup.lookup (new Lookup.Template (Integer.class));
3.184 - Iterator all = res.allInstances ().iterator ();
3.185 + Lookup.Result<Integer> res = lookup.lookupResult(Integer.class);
3.186 + Iterator<?> all = res.allInstances ().iterator ();
3.187 checkIterator ("Integer is not there", all, Collections.nCopies (1, INSTANCES[0]));
3.188
3.189 // change the pairs
3.190 LL listener = new LL (res);
3.191 res.addLookupListener (listener);
3.192
3.193 - ArrayList l2 = new ArrayList (li);
3.194 + List<Object> l2 = new ArrayList<Object>(li);
3.195 l2.remove (tmp);
3.196 ic.set (l2, null);
3.197
3.198 - all = lookup.lookup (new Lookup.Template (Object.class)).allInstances ().iterator ();
3.199 + all = lookup.lookupAll(Object.class).iterator();
3.200 checkIterator ("The removed integer is not noticed", all, l2);
3.201
3.202 if (listener.getCount () != 0) {
3.203 @@ -336,7 +342,7 @@
3.204
3.205 /** Tries to find all classes and superclasses in the lookup.
3.206 */
3.207 - private void findAll (Lookup lookup, Class clazz, boolean shouldBeThere) {
3.208 + private void findAll(Lookup lookup, Class<?> clazz, boolean shouldBeThere) {
3.209 if (clazz == null) return;
3.210
3.211 Object found = lookup.lookup (clazz);
3.212 @@ -354,8 +360,8 @@
3.213 }
3.214 }
3.215
3.216 - Lookup.Result res = lookup.lookup (new Lookup.Template (clazz));
3.217 - Collection collection = res.allInstances ();
3.218 + Lookup.Result<?> res = lookup.lookupResult(clazz);
3.219 + Collection<?> collection = res.allInstances();
3.220
3.221 for (int i = 0; i < INSTANCES.length; i++) {
3.222 boolean isSubclass = clazz.isInstance (INSTANCES[i]);
3.223 @@ -398,8 +404,8 @@
3.224 }
3.225
3.226 public void testCanReturnReallyStrangeResults () throws Exception {
3.227 - class QueryingPair extends org.openide.util.lookup.AbstractLookup.Pair {
3.228 - private Integer i = new Integer (434);
3.229 + class QueryingPair extends AbstractLookup.Pair<Object> {
3.230 + private Integer i = 434;
3.231
3.232 //
3.233 // do the test
3.234 @@ -418,28 +424,28 @@
3.235 // Implementation of pair
3.236 //
3.237
3.238 - public java.lang.String getId() {
3.239 + public String getId() {
3.240 return getType ().toString();
3.241 }
3.242
3.243 - public java.lang.String getDisplayName() {
3.244 + public String getDisplayName() {
3.245 return getId ();
3.246 }
3.247
3.248 - public java.lang.Class getType() {
3.249 + public Class<?> getType() {
3.250 return getClass ();
3.251 }
3.252
3.253 - protected boolean creatorOf(java.lang.Object obj) {
3.254 + protected boolean creatorOf(Object obj) {
3.255 return obj == this;
3.256 }
3.257
3.258 - protected boolean instanceOf(java.lang.Class c) {
3.259 + protected boolean instanceOf(Class<?> c) {
3.260 assertEquals ("Integer found or exception is thrown", i, lookup.lookup (Integer.class));
3.261 return c.isAssignableFrom(getType ());
3.262 }
3.263
3.264 - public java.lang.Object getInstance() {
3.265 + public Object getInstance() {
3.266 return this;
3.267 }
3.268
3.269 @@ -453,8 +459,8 @@
3.270
3.271 /** Test of firing events. */
3.272 public void testLookupListener() {
3.273 - Integer inst = new Integer(10);
3.274 - Lookup.Result res = lookup.lookup(new Lookup.Template(inst.getClass()));
3.275 + Object inst = 10;
3.276 + Lookup.Result<?> res = lookup.lookupResult(inst.getClass());
3.277 res.allInstances ();
3.278
3.279 LL listener = new LL(res);
3.280 @@ -484,42 +490,39 @@
3.281 /** Testing identity of the lookup.
3.282 */
3.283 public void testId () {
3.284 - AbstractLookup.Template templ;
3.285 + Lookup.Template<?> templ;
3.286 int cnt;
3.287
3.288 addInstances (INSTANCES);
3.289
3.290 - AbstractLookup.Result res = lookup.lookup (new AbstractLookup.Template ());
3.291 - Iterator it;
3.292 - it = res.allItems ().iterator ();
3.293 - while (it.hasNext ()) {
3.294 - AbstractLookup.Item item = (AbstractLookup.Item)it.next ();
3.295 + Lookup.Result<?> res = lookup.lookupResult(Object.class);
3.296 + for (AbstractLookup.Item<?> item : res.allItems()) {
3.297
3.298 - templ = new AbstractLookup.Template (null, item.getId (), null);
3.299 + templ = new Lookup.Template<Object>(null, item.getId(), null);
3.300 cnt = lookup.lookup (templ).allInstances ().size ();
3.301 if (cnt != 1) {
3.302 fail ("Identity lookup failed. Instances = " + cnt);
3.303 }
3.304
3.305 - templ = new AbstractLookup.Template (item.getType (), item.getId (), null);
3.306 + templ = makeTemplate(item.getType(), item.getId());
3.307 cnt = lookup.lookup (templ).allInstances ().size ();
3.308 if (cnt != 1) {
3.309 fail ("Identity lookup with type failed. Instances = " + cnt);
3.310 }
3.311
3.312 - templ = new AbstractLookup.Template (this.getClass (), item.getId (), null);
3.313 + templ = makeTemplate(this.getClass(), item.getId());
3.314 cnt = lookup.lookup (templ).allInstances ().size ();
3.315 if (cnt != 0) {
3.316 fail ("Identity lookup with wrong type failed. Instances = " + cnt);
3.317 }
3.318
3.319 - templ = new AbstractLookup.Template (null, null, item.getInstance ());
3.320 + templ = new Lookup.Template<Object>(null, null, item.getInstance());
3.321 cnt = lookup.lookup (templ).allInstances ().size ();
3.322 if (cnt != 1) {
3.323 fail ("Instance lookup failed. Instances = " + cnt);
3.324 }
3.325
3.326 - templ = new AbstractLookup.Template (null, item.getId (), item.getInstance ());
3.327 + templ = new Lookup.Template<Object>(null, item.getId(), item.getInstance());
3.328 cnt = lookup.lookup (templ).allInstances ().size ();
3.329 if (cnt != 1) {
3.330 fail ("Instance & identity lookup failed. Instances = " + cnt);
3.331 @@ -527,6 +530,9 @@
3.332
3.333 }
3.334 }
3.335 + private static <T> Lookup.Template<T> makeTemplate(Class<T> clazz, String id) { // captures type parameter
3.336 + return new Lookup.Template<T>(clazz, id, null);
3.337 + }
3.338
3.339 /** Tests adding and removing.
3.340 */
3.341 @@ -534,7 +540,7 @@
3.342 Object map = new javax.swing.ActionMap ();
3.343 LL ll = new LL ();
3.344
3.345 - Lookup.Result res = lookup.lookup (new Lookup.Template (map.getClass ()));
3.346 + Lookup.Result<?> res = lookup.lookupResult(map.getClass());
3.347 res.allItems();
3.348 res.addLookupListener (ll);
3.349 ll.source = res;
3.350 @@ -561,8 +567,8 @@
3.351 */
3.352 public void testGarbageCollect () throws Exception {
3.353 ClassLoader l = new CL ();
3.354 - Class c = l.loadClass (Garbage.class.getName ());
3.355 - WeakReference ref = new WeakReference (c);
3.356 + Class<?> c = l.loadClass(Garbage.class.getName());
3.357 + Reference<?> ref = new WeakReference<Object>(c);
3.358
3.359 lookup.lookup (c);
3.360
3.361 @@ -578,18 +584,15 @@
3.362 public void testItemsAndIntances () {
3.363 addInstances (INSTANCES);
3.364
3.365 - Lookup.Template t = new Lookup.Template (Object.class);
3.366 - Lookup.Result r = lookup.lookup (t);
3.367 - Collection items = r.allItems ();
3.368 - Collection insts = r.allInstances ();
3.369 + Lookup.Result<Object> r = lookup.lookupResult(Object.class);
3.370 + Collection<? extends Lookup.Item<?>> items = r.allItems();
3.371 + Collection<?> insts = r.allInstances();
3.372
3.373 if (items.size () != insts.size ()) {
3.374 fail ("Different size of sets");
3.375 }
3.376 -
3.377 - Iterator it = items.iterator ();
3.378 - while (it.hasNext ()) {
3.379 - Lookup.Item item = (Lookup.Item)it.next ();
3.380 +
3.381 + for (Lookup.Item<?> item : items) {
3.382 if (!insts.contains (item.getInstance ())) {
3.383 fail ("Intance " + item.getInstance () + " is missing in " + insts);
3.384 }
3.385 @@ -599,7 +602,7 @@
3.386 /** Checks search for interface.
3.387 */
3.388 public void testSearchForInterface () {
3.389 - Lookup.Template t = new Lookup.Template (Serializable.class, null, null);
3.390 + Lookup.Template<Serializable> t = new Lookup.Template<Serializable>(Serializable.class, null, null);
3.391
3.392 assertNull("Nothing to find", lookup.lookupItem (t));
3.393
3.394 @@ -615,7 +618,7 @@
3.395 public void testIncorectInstanceOf40364 () {
3.396 final Long sharedLong = new Long (0);
3.397
3.398 - class P extends AbstractLookup.Pair {
3.399 + class P extends AbstractLookup.Pair<Object> {
3.400 public boolean isLong;
3.401
3.402 P (boolean b) {
3.403 @@ -638,19 +641,19 @@
3.404 return sharedLong;
3.405 }
3.406
3.407 - public Class getType () {
3.408 + public Class<?> getType() {
3.409 return isLong ? Long.class : Number.class;
3.410 }
3.411
3.412 - protected boolean instanceOf (Class c) {
3.413 + protected boolean instanceOf(Class<?> c) {
3.414 return c.isAssignableFrom (getType ());
3.415 }
3.416
3.417 - public int hashCode () {
3.418 + public @Override int hashCode() {
3.419 return getClass ().hashCode ();
3.420 }
3.421
3.422 - public boolean equals (Object obj) {
3.423 + public @Override boolean equals(Object obj) {
3.424 return obj != null && getClass ().equals (obj.getClass ());
3.425 }
3.426 }
3.427 @@ -666,16 +669,16 @@
3.428 P lng2 = new P (false);
3.429 ic.setPairs (Collections.singleton (lng2));
3.430
3.431 - Collection res = lookup.lookup (new Lookup.Template (Object.class)).allItems ();
3.432 + Collection<? extends Lookup.Item<?>> res = lookup.lookupResult(Object.class).allItems();
3.433 assertEquals ("Just one pair", 1, res.size ());
3.434 }
3.435
3.436 public void testAbsolutelyCrazyWayToSimulateIssue48590ByChangingTheBehaviourOfEqualOnTheFly () throws Exception {
3.437 - class X implements testInterfaceInheritanceA, testInterfaceInheritanceB {
3.438 + class X implements TestInterfaceInheritanceA, TestInterfaceInheritanceB {
3.439 }
3.440 final X shared = new X ();
3.441
3.442 - class P extends AbstractLookup.Pair {
3.443 + class P extends AbstractLookup.Pair<Object> {
3.444 public int howLong;
3.445
3.446 P (int b) {
3.447 @@ -698,19 +701,19 @@
3.448 return shared;
3.449 }
3.450
3.451 - public Class getType () {
3.452 - return howLong == 0 ? testInterfaceInheritanceB.class : testInterfaceInheritanceA.class;
3.453 + public Class<?> getType() {
3.454 + return howLong == 0 ? TestInterfaceInheritanceB.class : TestInterfaceInheritanceA.class;
3.455 }
3.456
3.457 - protected boolean instanceOf (Class c) {
3.458 + protected boolean instanceOf(Class<?> c) {
3.459 return c.isAssignableFrom (getType ());
3.460 }
3.461
3.462 - public int hashCode () {
3.463 + public @Override int hashCode() {
3.464 return getClass ().hashCode ();
3.465 }
3.466
3.467 - public boolean equals (Object obj) {
3.468 + public @Override boolean equals(Object obj) {
3.469 if (obj instanceof P) {
3.470 P p = (P)obj;
3.471 if (this.howLong > 0) {
3.472 @@ -728,8 +731,8 @@
3.473 }
3.474
3.475 // to create the right structure in the lookup
3.476 - Lookup.Result a = lookup.lookup (new Lookup.Template (testInterfaceInheritanceA.class));
3.477 - Lookup.Result b = lookup.lookup (new Lookup.Template (testInterfaceInheritanceB.class));
3.478 + Lookup.Result<?> a = lookup.lookupResult(TestInterfaceInheritanceA.class);
3.479 + Lookup.Result<?> b = lookup.lookupResult(TestInterfaceInheritanceB.class);
3.480
3.481 P lng1 = new P (0);
3.482 ic.addPair (lng1);
3.483 @@ -769,15 +772,15 @@
3.484
3.485 }
3.486
3.487 - public void assertOnlyMe (String msg, Lookup.Result res) {
3.488 - Collection col = res.allInstances ();
3.489 + public void assertOnlyMe (String msg, Lookup.Result<?> res) {
3.490 + Collection<?> col = res.allInstances();
3.491 assertEquals (msg + " just one", 1, col.size ());
3.492 assertSame (msg + " and it is me", this, col.iterator ().next ());
3.493 }
3.494 }
3.495
3.496 - Lookup.Result runnable = lookup.lookup (new Lookup.Template (Runnable.class));
3.497 - Lookup.Result serial = lookup.lookup (new Lookup.Template (Serializable.class));
3.498 + Lookup.Result<?> runnable = lookup.lookupResult(Runnable.class);
3.499 + Lookup.Result<?> serial = lookup.lookupResult(Serializable.class);
3.500
3.501
3.502 X x = new X ();
3.503 @@ -814,13 +817,13 @@
3.504 int size1, size2;
3.505
3.506 //interface query
3.507 - size1 = lookup.lookup(new Lookup.Template(java.rmi.Remote.class)).allInstances().size();
3.508 + size1 = lookup.lookupAll(java.rmi.Remote.class).size();
3.509 size2 = countInstances(types, java.rmi.Remote.class);
3.510
3.511 if (size1 != size2) fail("Lookup with interface failed: " + size1 + " != " + size2);
3.512
3.513 // superclass query
3.514 - size1 = lookup.lookup(new Lookup.Template(A.class)).allInstances().size();
3.515 + size1 = lookup.lookupAll(A.class).size();
3.516 size2 = countInstances(types, A.class);
3.517
3.518 if (size1 != size2) fail("Lookup with superclass failed: " + size1 + " != " + size2);
3.519 @@ -829,11 +832,11 @@
3.520 /** Test interface inheritance.
3.521 */
3.522 public void testInterfaceInheritance() {
3.523 - testInterfaceInheritanceA[] types = {
3.524 - new testInterfaceInheritanceB() {},
3.525 - new testInterfaceInheritanceBB() {},
3.526 - new testInterfaceInheritanceC() {},
3.527 - new testInterfaceInheritanceD() {}
3.528 + TestInterfaceInheritanceA[] types = {
3.529 + new TestInterfaceInheritanceB() {},
3.530 + new TestInterfaceInheritanceBB() {},
3.531 + new TestInterfaceInheritanceC() {},
3.532 + new TestInterfaceInheritanceD() {}
3.533 };
3.534
3.535 for (int i = 0; i < types.length; i++) {
3.536 @@ -848,7 +851,7 @@
3.537
3.538 //interface query
3.539 LL l = new LL ();
3.540 - Lookup.Result res = lookup.lookup(new Lookup.Template(java.rmi.Remote.class));
3.541 + Lookup.Result<?> res = lookup.lookupResult(java.rmi.Remote.class);
3.542 l.source = res;
3.543 size1 = res.allInstances().size();
3.544 size2 = countInstances(types, java.rmi.Remote.class);
3.545 @@ -856,8 +859,8 @@
3.546 if (size1 != size2) fail("Lookup with interface failed: " + size1 + " != " + size2);
3.547
3.548 // superclass query
3.549 - size1 = lookup.lookup(new Lookup.Template(testInterfaceInheritanceA.class)).allInstances().size();
3.550 - size2 = countInstances(types, testInterfaceInheritanceA.class);
3.551 + size1 = lookup.lookupAll(TestInterfaceInheritanceA.class).size();
3.552 + size2 = countInstances(types, TestInterfaceInheritanceA.class);
3.553
3.554 if (size1 != size2) fail("Lookup with superclass failed: " + size1 + " != " + size2);
3.555
3.556 @@ -876,8 +879,8 @@
3.557 BrokenPair broken = new BrokenPair (true, false);
3.558 ic.addPair (broken);
3.559
3.560 - Lookup.Template templ = new Lookup.Template (BrokenPair.class);
3.561 - Object item = lookup.lookupItem (templ);
3.562 + Lookup.Template<BrokenPair> templ = new Lookup.Template<BrokenPair>(BrokenPair.class);
3.563 + Lookup.Item<BrokenPair> item = lookup.lookupItem (templ);
3.564 assertEquals ("Broken is found", broken, item);
3.565 }
3.566
3.567 @@ -885,9 +888,9 @@
3.568 BrokenPair broken = new BrokenPair (false, true);
3.569 ic.addPair (broken);
3.570
3.571 - Lookup.Template templ = new Lookup.Template (BrokenPair.class);
3.572 + Lookup.Template<BrokenPair> templ = new Lookup.Template<BrokenPair>(BrokenPair.class);
3.573
3.574 - Collection c = lookup.lookup (templ).allInstances();
3.575 + Collection<? extends BrokenPair> c = lookup.lookup (templ).allInstances();
3.576 assertEquals ("One item", 1, c.size ());
3.577 assertEquals ("Broken is found again", broken, c.iterator().next ());
3.578 }
3.579 @@ -896,11 +899,11 @@
3.580 BrokenPair broken = new BrokenPair (false, true);
3.581 ic.addPair (broken);
3.582
3.583 - Lookup.Template templ = new Lookup.Template (BrokenPair.class);
3.584 - Object item = lookup.lookupItem (templ);
3.585 + Lookup.Template<BrokenPair> templ = new Lookup.Template<BrokenPair>(BrokenPair.class);
3.586 + Lookup.Item<BrokenPair> item = lookup.lookupItem (templ);
3.587 assertEquals ("Broken is found", broken, item);
3.588
3.589 - Collection c = lookup.lookup (templ).allInstances();
3.590 + Collection<? extends BrokenPair> c = lookup.lookup(templ).allInstances();
3.591 assertEquals ("One item", 1, c.size ());
3.592 assertEquals ("Broken is found again", broken, c.iterator().next ());
3.593 }
3.594 @@ -909,8 +912,8 @@
3.595 BrokenPair broken = new BrokenPair (false, true);
3.596 ic.addPair (broken);
3.597
3.598 - Lookup.Template templ = new Lookup.Template (BrokenPair.class);
3.599 - Collection c = lookup.lookup (templ).allInstances();
3.600 + Lookup.Template<BrokenPair> templ = new Lookup.Template<BrokenPair>(BrokenPair.class);
3.601 + Collection<? extends BrokenPair> c = lookup.lookup(templ).allInstances();
3.602 assertEquals ("One item", 1, c.size ());
3.603 assertEquals ("Broken is found again", broken, c.iterator().next ());
3.604
3.605 @@ -919,9 +922,9 @@
3.606 }
3.607
3.608 public void testAddALotOfPairsIntoTheLookupOneByOne () throws Exception {
3.609 - Lookup.Result res = lookup.lookup (new Lookup.Template (Integer.class));
3.610 + Lookup.Result<Integer> res = lookup.lookupResult(Integer.class);
3.611 for (int i = 0; i < 1000; i++) {
3.612 - ic.add (new Integer (i));
3.613 + ic.add(i);
3.614 }
3.615 assertEquals (
3.616 "there is the right count",
3.617 @@ -931,31 +934,30 @@
3.618 }
3.619
3.620 public void testAddALotOfPairsIntoTheLookup () throws Exception {
3.621 - ArrayList arr = new ArrayList ();
3.622 + List<Integer> arr = new ArrayList<Integer>();
3.623 for (int i = 0; i < 1000; i++) {
3.624 - arr.add (new Integer (i));
3.625 + arr.add(i);
3.626 }
3.627 ic.set (arr, null);
3.628
3.629 assertEquals (
3.630 "there is the right count",
3.631 1000,
3.632 - lookup.lookup (new Lookup.Template (Integer.class)).allItems().size ()
3.633 + lookup.lookupResult(Integer.class).allItems().size()
3.634 );
3.635 }
3.636
3.637
3.638 public void testDoubleAddIssue35274 () throws Exception {
3.639 - class P extends AbstractLookup.Pair {
3.640 + class P extends AbstractLookup.Pair<Object> {
3.641 protected boolean creatorOf(Object obj) { return false; }
3.642 public String getDisplayName() { return ""; }
3.643 public String getId() { return ""; }
3.644 public Object getInstance() { return null; }
3.645 - public Class getType() { return Object.class; }
3.646 - protected boolean instanceOf(Class c) { return c.isAssignableFrom(getType ()); }
3.647 -
3.648 - public int hashCode () { return getClass ().hashCode(); };
3.649 - public boolean equals (Object obj) { return getClass () == obj.getClass (); };
3.650 + public Class<?> getType() { return Object.class; }
3.651 + protected boolean instanceOf(Class<?> c) { return c.isAssignableFrom(getType ()); }
3.652 + public @Override int hashCode() {return getClass().hashCode();}
3.653 + public @Override boolean equals(Object obj) {return getClass() == obj.getClass();}
3.654 }
3.655
3.656 P p = new P ();
3.657 @@ -963,7 +965,7 @@
3.658 ic.addPair (p);
3.659 ic.addPair (p);
3.660
3.661 - Lookup.Result result = lookup.lookup (new Lookup.Template (Object.class));
3.662 + Lookup.Result<Object> result = lookup.lookupResult(Object.class);
3.663 Collection res = result.allItems ();
3.664 assertEquals ("One item there", 1, res.size ());
3.665 assertTrue ("It is the p", p == res.iterator ().next ());
3.666 @@ -971,13 +973,13 @@
3.667 P p2 = new P ();
3.668 ic.addPair (p2);
3.669
3.670 - WeakReference ref = new WeakReference (result);
3.671 + Reference<?> ref = new WeakReference<Object>(result);
3.672 result = null;
3.673 assertGC ("The result can disappear", ref);
3.674
3.675 impl.clearCaches ();
3.676
3.677 - result = lookup.lookup (new Lookup.Template (Object.class));
3.678 + result = lookup.lookupResult(Object.class);
3.679 res = result.allItems ();
3.680 assertEquals ("One item is still there", 1, res.size ());
3.681 assertTrue ("But the p2 replaced p", p2 == res.iterator ().next ());
3.682 @@ -1178,7 +1180,7 @@
3.683 synchronized (pair) {
3.684 class BlockInInstanceOf implements Runnable {
3.685 public void run () {
3.686 - Integer i = (Integer)my.lookup (Integer.class);
3.687 + Integer i = my.lookup(Integer.class);
3.688 assertEquals (new Integer (10), i);
3.689 }
3.690 }
3.691 @@ -1249,12 +1251,12 @@
3.692 }
3.693
3.694 /** Checks the iterator */
3.695 - private void checkIterator (String msg, Iterator it1, List list) {
3.696 + private <T> void checkIterator(String msg, Iterator<? extends T> it1, List<? extends T> list) {
3.697 int cnt = 0;
3.698 - Iterator it2 = list.iterator ();
3.699 + Iterator<? extends T> it2 = list.iterator();
3.700 while (it1.hasNext () && it2.hasNext ()) {
3.701 - Object n1 = it1.next ();
3.702 - Object n2 = it2.next ();
3.703 + T n1 = it1.next();
3.704 + T n2 = it2.next();
3.705
3.706 if (n1 != n2) {
3.707 fail (msg + " iterator[" + cnt + "] = " + n1 + " but list[" + cnt + "] = " + n2);
3.708 @@ -1413,7 +1415,7 @@
3.709 this.ic = ic;
3.710 }
3.711
3.712 - protected void beforeLookup(Template template) {
3.713 + protected @Override void beforeLookup(Template template) {
3.714 if (ic != null) {
3.715 ic.add(am);
3.716 ic = null;
3.717 @@ -1447,7 +1449,7 @@
3.718 return delegate;
3.719 }
3.720
3.721 - public void setLookups(Lookup[] arr) {
3.722 + public void setLookups(Lookup... arr) {
3.723 if (wrapBySimple) {
3.724 delegate = new ProxyLookup(arr);
3.725 } else {
3.726 @@ -1479,10 +1481,10 @@
3.727 assertEquals("No change in ActionMap 2", 0, ll.getCount());
3.728 ic.add(m2);
3.729 assertEquals("No change in ActionMap 3", 0, ll.getCount());
3.730 - p.setLookups(new Lookup[]{ lookup, actionMapLookup, Lookup.EMPTY });
3.731 + p.setLookups(lookup, actionMapLookup, Lookup.EMPTY);
3.732 assertEquals("No change in ActionMap 4", 0, ll.getCount());
3.733
3.734 - ActionMap am2 = (ActionMap)p.query.lookup(ActionMap.class);
3.735 + ActionMap am2 = p.query.lookup(ActionMap.class);
3.736 assertEquals("Still the same action map", am, am2);
3.737
3.738
3.739 @@ -1497,7 +1499,7 @@
3.740 this.ic = ic;
3.741 }
3.742
3.743 - protected void beforeLookup(Template template) {
3.744 + protected @Override void beforeLookup(Template template) {
3.745 if (ic != null) {
3.746 ic.add(am);
3.747 ic = null;
3.748 @@ -1826,11 +1828,11 @@
3.749
3.750 /** A set of interfaces for testInterfaceInheritance
3.751 */
3.752 - interface testInterfaceInheritanceA {}
3.753 - interface testInterfaceInheritanceB extends testInterfaceInheritanceA, java.rmi.Remote {}
3.754 - interface testInterfaceInheritanceBB extends testInterfaceInheritanceB {}
3.755 - interface testInterfaceInheritanceC extends testInterfaceInheritanceA, java.rmi.Remote {}
3.756 - interface testInterfaceInheritanceD extends testInterfaceInheritanceA {}
3.757 + interface TestInterfaceInheritanceA {}
3.758 + interface TestInterfaceInheritanceB extends TestInterfaceInheritanceA, java.rmi.Remote {}
3.759 + interface TestInterfaceInheritanceBB extends TestInterfaceInheritanceB {}
3.760 + interface TestInterfaceInheritanceC extends TestInterfaceInheritanceA, java.rmi.Remote {}
3.761 + interface TestInterfaceInheritanceD extends TestInterfaceInheritanceA {}
3.762
3.763 /** A special class for garbage test */
3.764 public static final class Garbage extends Object implements Serializable {
3.765 @@ -1844,7 +1846,7 @@
3.766 super (null);
3.767 }
3.768
3.769 - public Class findClass (String name) throws ClassNotFoundException {
3.770 + public @Override Class findClass(String name) throws ClassNotFoundException {
3.771 if (name.equals (Garbage.class.getName ())) {
3.772 String n = name.replace ('.', '/');
3.773 java.io.InputStream is = getClass ().getResourceAsStream ("/" + n + ".class");
4.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupMemoryTest.java Fri Oct 09 13:53:04 2009 -0400
4.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupMemoryTest.java Fri Oct 09 15:11:13 2009 -0400
4.3 @@ -77,7 +77,7 @@
4.4 }
4.5
4.6 public void testLookupWithPairs () {
4.7 - Lookup.Template t = new Lookup.Template (Object.class);
4.8 + Lookup.Template<Object> t = new Lookup.Template<Object>(Object.class);
4.9 class L implements org.openide.util.LookupListener {
4.10 public int cnt;
4.11 public void resultChanged (org.openide.util.LookupEvent ev) {
4.12 @@ -86,12 +86,18 @@
4.13 }
4.14 L listener = new L ();
4.15 L listener2 = new L ();
4.16 -
4.17 +
4.18 + EmptyPair[] pairs = {
4.19 + new EmptyPair(),
4.20 + new EmptyPair(),
4.21 + new EmptyPair(),
4.22 + new EmptyPair(),
4.23 + };
4.24 Object[] ignore = {
4.25 - new EmptyPair (),
4.26 - new EmptyPair (),
4.27 - new EmptyPair (),
4.28 - new EmptyPair (),
4.29 + pairs[0],
4.30 + pairs[1],
4.31 + pairs[2],
4.32 + pairs[3],
4.33 t,
4.34 ActiveQueue.queue(),
4.35 listener,
4.36 @@ -108,10 +114,10 @@
4.37 c.addPair ((EmptyPair)ignore[1]);
4.38 assertSize ("Is bigger I guess (not counting the pair sizes)", Collections.singleton (l), 56, ignore);
4.39
4.40 - c.setPairs((Collection)Arrays.asList (ignore).subList (0, 3));
4.41 + c.setPairs(Arrays.asList(pairs).subList(0, 3));
4.42 assertSize ("Even bigger (not counting the pair sizes)", Collections.singleton (l), 64, ignore);
4.43
4.44 - c.setPairs((Collection)Arrays.asList (ignore).subList (0, 4));
4.45 + c.setPairs(Arrays.asList(pairs).subList(0, 4));
4.46 assertSize ("Now not that much(not counting the pair sizes)", Collections.singleton (l), 64, ignore);
4.47
4.48 Lookup.Result res = l.lookup (t);
5.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupTest.java Fri Oct 09 13:53:04 2009 -0400
5.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/AbstractLookupTest.java Fri Oct 09 15:11:13 2009 -0400
5.3 @@ -51,6 +51,7 @@
5.4 import org.openide.util.Lookup;
5.5 import org.openide.util.lookup.AbstractLookup.Pair;
5.6
5.7 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
5.8 public class AbstractLookupTest extends AbstractLookupBaseHid implements AbstractLookupBaseHid.Impl {
5.9 public AbstractLookupTest(java.lang.String testName) {
5.10 super(testName, null);
5.11 @@ -86,7 +87,7 @@
5.12 public int cleared;
5.13 public int dirty;
5.14
5.15 - synchronized boolean cleanUpResult (Template t) {
5.16 + synchronized @Override boolean cleanUpResult(Template t) {
5.17 boolean res = super.cleanUpResult (t);
5.18 if (res) {
5.19 cleared++;
5.20 @@ -172,7 +173,7 @@
5.21 this.ic = ic;
5.22 }
5.23
5.24 - protected void initialize () {
5.25 + protected @Override void initialize() {
5.26 if (direct) {
5.27 run ();
5.28 } else {
5.29 @@ -214,7 +215,7 @@
5.30 this.ic = c;
5.31 }
5.32
5.33 - protected void beforeLookup (Template t) {
5.34 + protected @Override void beforeLookup(Template t) {
5.35 if (toAdd != null) {
5.36 list.add (0, new SerialPair (toAdd));
5.37 setPairs (list);
6.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/ExcludingLookupTest.java Fri Oct 09 13:53:04 2009 -0400
6.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/ExcludingLookupTest.java Fri Oct 09 15:11:13 2009 -0400
6.3 @@ -46,6 +46,7 @@
6.4
6.5 /** Runs all NbLookupTest tests on ProxyLookup and adds few additional.
6.6 */
6.7 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
6.8 public class ExcludingLookupTest extends AbstractLookupBaseHid
6.9 implements AbstractLookupBaseHid.Impl {
6.10 public ExcludingLookupTest(java.lang.String testName) {
7.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/LookupsProxyTest.java Fri Oct 09 13:53:04 2009 -0400
7.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/LookupsProxyTest.java Fri Oct 09 15:11:13 2009 -0400
7.3 @@ -51,6 +51,7 @@
7.4
7.5 /** Runs all NbLookupTest tests on ProxyLookup and adds few additional.
7.6 */
7.7 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
7.8 public class LookupsProxyTest extends AbstractLookupBaseHid
7.9 implements AbstractLookupBaseHid.Impl {
7.10 public LookupsProxyTest(java.lang.String testName) {
8.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/ProxyLookupTest.java Fri Oct 09 13:53:04 2009 -0400
8.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/ProxyLookupTest.java Fri Oct 09 15:11:13 2009 -0400
8.3 @@ -57,6 +57,7 @@
8.4
8.5 /** Runs all NbLookupTest tests on ProxyLookup and adds few additional.
8.6 */
8.7 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
8.8 public class ProxyLookupTest extends AbstractLookupBaseHid
8.9 implements AbstractLookupBaseHid.Impl {
8.10 public ProxyLookupTest(java.lang.String testName) {
8.11 @@ -459,6 +460,7 @@
8.12 }
8.13
8.14 @Override
8.15 + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
8.16 public boolean equals(Object obj) {
8.17 if (set != null) {
8.18 cnt[0]++;
9.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/SimpleProxyLookupIssue42244Test.java Fri Oct 09 13:53:04 2009 -0400
9.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/SimpleProxyLookupIssue42244Test.java Fri Oct 09 15:11:13 2009 -0400
9.3 @@ -49,6 +49,7 @@
9.4
9.5 /** To simulate issue 42244.
9.6 */
9.7 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
9.8 public class SimpleProxyLookupIssue42244Test extends AbstractLookupBaseHid implements AbstractLookupBaseHid.Impl {
9.9 public SimpleProxyLookupIssue42244Test (java.lang.String testName) {
9.10 super(testName, null);
10.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/SimpleProxyLookupTest.java Fri Oct 09 13:53:04 2009 -0400
10.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/SimpleProxyLookupTest.java Fri Oct 09 15:11:13 2009 -0400
10.3 @@ -45,22 +45,18 @@
10.4 import org.netbeans.junit.NbTestCase;
10.5 import org.openide.util.Lookup;
10.6 import org.openide.util.Lookup.Provider;
10.7 -import org.openide.util.Lookup.Result;
10.8 -import org.openide.util.Lookup.Template;
10.9
10.10 /**
10.11 *
10.12 * @author Jan Lahoda
10.13 */
10.14 +@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
10.15 public class SimpleProxyLookupTest extends NbTestCase {
10.16
10.17 public SimpleProxyLookupTest(String testName) {
10.18 super(testName);
10.19 }
10.20
10.21 - protected void setUp() throws Exception {
10.22 - }
10.23 -
10.24 public void test69810() throws Exception {
10.25 Lookup.Template t = new Lookup.Template(String.class);
10.26 SimpleProxyLookup spl = new SimpleProxyLookup(new Provider() {