incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r778793 - /incubator/kato/trunk/org.apache.kato.example/src/org/apache/kato/example/ObjectFields.java
Date Tue, 26 May 2009 16:46:51 GMT
Author: monteith
Date: Tue May 26 16:46:51 2009
New Revision: 778793

URL: http://svn.apache.org/viewvc?rev=778793&view=rev
Log:
Update ObjectFields example to use Lists.

Modified:
    incubator/kato/trunk/org.apache.kato.example/src/org/apache/kato/example/ObjectFields.java

Modified: incubator/kato/trunk/org.apache.kato.example/src/org/apache/kato/example/ObjectFields.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.example/src/org/apache/kato/example/ObjectFields.java?rev=778793&r1=778792&r2=778793&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato.example/src/org/apache/kato/example/ObjectFields.java
(original)
+++ incubator/kato/trunk/org.apache.kato.example/src/org/apache/kato/example/ObjectFields.java
Tue May 26 16:46:51 2009
@@ -15,6 +15,7 @@
 
 import java.lang.reflect.Array;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.kato.image.CorruptData;
 import org.apache.kato.image.CorruptDataException;
@@ -116,15 +117,14 @@
 		 * A JVM's heap may split across different heaps, e.g.
 		 * nurseries, system heap, large object heap.
 		 */
-		Iterator heaps = jr.getHeaps();
+		List heaps = jr.getHeaps();
 		
 		
 		/* What follows is a typical pattern, 
 		 * iterate, check type, handle data or handle corrupt data,
 		 * continue.
 		 */
-		while (heaps.hasNext()) {
-			Object next = heaps.next();
+		for (Object next : heaps) {
 			
 			// This is the normal case.
 			if (next instanceof JavaHeap) {
@@ -147,11 +147,10 @@
 	 * @param heap JavaHeap to iterate over.
 	 */
 	public void walkHeap(JavaHeap heap) {
-		Iterator objects = heap.getObjects();
+		List objects = heap.getObjects();
 		
 		// Follow same pattern as walkObjectFields
-		while (objects.hasNext()) {
-			Object next = objects.next();
+		for (Object next : objects) {
 			
 			/* The heap has only JavaObjects on it. Not JavaClasses,
 			 * but JavaObjects of type java/lang/Class will be encountered.
@@ -241,12 +240,11 @@
 				System.out.println( prefix + clazz.getName() +":");
 				prefix += "  ";
 			
-				Iterator fields = clazz.getDeclaredFields();
+				List fields = clazz.getDeclaredFields();
 			
 				/* Print out all fields for this class.
 				 */
-				while (fields.hasNext()) {
-					Object nextField = fields.next();
+				for (Object nextField : fields) {
 					
 					if (nextField instanceof JavaField) {
 						printField(prefix, (JavaField) nextField, jObject);						



Mime
View raw message