< prev index next >

src/com/sun/javatest/TestResult.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg

@@ -948,12 +948,12 @@
     public synchronized void setEnvironment(TestEnvironment environment) {
         if (!isMutable()) {
             throw new IllegalStateException(
                         "This TestResult is no longer mutable!");
         }
-        for (Iterator i = environment.elementsUsed().iterator(); i.hasNext(); ) {
-            TestEnvironment.Element elem = (TestEnvironment.Element) (i.next());
+        for (Iterator<TestEnvironment.Element> i = environment.elementsUsed().iterator(); i.hasNext(); ) {
+            TestEnvironment.Element elem = i.next();
             // this is stunningly inefficient and should be fixed
             env = PropertyArray.put(env, elem.getKey(), elem.getValue());
         }
     }
 

@@ -1299,11 +1299,11 @@
 
     /**
      * Get the keys of the properties that this object has stored.
      * @return the keys of the properties that this object has stored
      */
-    public synchronized Enumeration getPropertyNames() {
+    public synchronized Enumeration<String> getPropertyNames() {
         return PropertyArray.enumerate(props);
     }
 
     /**
      * Get the value of a property of this test result.

@@ -1330,11 +1330,11 @@
      * @return a copy of the environment that this object has stored
      * @throws TestResult.Fault if there is a problem
      *          recreating data from the results file.
      * @see #setEnvironment
      */
-    public synchronized Map getEnvironment() throws Fault {
+    public synchronized Map<String, String> getEnvironment() throws Fault {
         if (env == null) {
             // reconstitute environment
             // this may result in a Fault, which is okay
             reload();
         }

@@ -1980,14 +1980,14 @@
         return Math.abs(cs);  // ensure +ve, to avoid sign issues!
     }
 
     private static long computeChecksum(TestDescription td) {
         long cs = 0;
-        for (Iterator i = td.getParameterKeys(); i.hasNext(); ) {
+        for (Iterator<String> i = td.getParameterKeys(); i.hasNext(); ) {
             // don't rely on enumeration in a particular order
             // so simply add the checksum products together
-            String key = (String) (i.next());
+            String key = (i.next());
             cs += computeChecksum(key) * computeChecksum(td.getParameter(key));
         }
         return cs;
     }
 

@@ -2555,18 +2555,18 @@
     private void addToShrinkList() {
         synchronized (shrinkList) {
             // if this object is in the list; remove it;
             // if there are dead weak refs, remove them
             for (Iterator<WeakReference<TestResult>> iter = shrinkList.iterator(); iter.hasNext(); ) {
-                WeakReference wref = iter.next();
+                WeakReference<TestResult> wref = iter.next();
                 Object o = wref.get();
                 if (o == null || o == this)
                     iter.remove();
             }
             while (shrinkList.size() >= maxShrinkListSize) {
-                WeakReference wref = shrinkList.removeFirst();
-                TestResult tr = (TestResult) (wref.get());
+                WeakReference<TestResult> wref = shrinkList.removeFirst();
+                TestResult tr = wref.get();
                 if (tr != null)
                     tr.shrink();
             }
             shrinkList.addLast(new WeakReference<>(this));
         }
< prev index next >