You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by mo...@apache.org on 2009/10/22 12:22:37 UTC

svn commit: r828669 - in /incubator/kato/trunk/org.apache.kato/kato.cjvmti/src: main/java/org/apache/kato/jvmti/javaruntime/ main/java/org/apache/kato/jvmti/javaruntime/model/ main/java/org/apache/kato/jvmti/process/ main/java/org/apache/kato/jvmti/rea...

Author: monteith
Date: Thu Oct 22 12:22:37 2009
New Revision: 828669

URL: http://svn.apache.org/viewvc?rev=828669&view=rev
Log:
Remove unnecessary EmptyList and add unit testcase for ObjectMapList

Added:
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/CorruptDataImpl.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapListTest.java   (with props)
Removed:
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/EmptyList.java
Modified:
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/JavaRuntimeImpl.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClass.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClassLoader.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JHeap.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapList.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/JavaRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/JavaRuntimeImpl.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/JavaRuntimeImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/JavaRuntimeImpl.java Thu Oct 22 12:22:37 2009
@@ -16,6 +16,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.logging.Level;
@@ -34,14 +35,11 @@
 import javax.tools.diagnostics.runtime.java.JavaThread;
 import javax.tools.diagnostics.runtime.java.JavaVMInitArgs;
 
-import org.apache.kato.jvmti.javaruntime.model.EmptyList;
 import org.apache.kato.jvmti.javaruntime.model.Model;
+import org.apache.kato.jvmti.reader.CJVMTIBinReader;
 import org.apache.kato.jvmti.reader.CLogger;
 
-public class JavaRuntimeImpl implements JavaRuntime {
-	private static final String VERSION = "0.1.0";
-	private static final String FULL_VERSION = "CJVMTI v0.1";
-	
+public class JavaRuntimeImpl implements JavaRuntime {	
 	private Model model=null;
 	private File source;
 	
@@ -52,12 +50,12 @@
 	
 	@Override
 	public List<JavaMethod> getCompiledMethods() {
-		return new EmptyList<JavaMethod>();
+		return Collections.emptyList();
 	}
 
 	@Override
 	public List<JavaReference> getHeapRoots() {
-		return new EmptyList<JavaReference>();
+		return Collections.emptyList();
 	}
 
 	private List<JavaHeap> heap = null;
@@ -120,12 +118,12 @@
 
 	@Override
 	public String getFullVersion() throws CorruptDataException {
-		return FULL_VERSION;
+		return CJVMTIBinReader.CJVMTI_VERSION_STRING;
 	}
 
 	@Override
 	public String getVersion() throws CorruptDataException {
-		return VERSION;
+		return CJVMTIBinReader.CJVMTI_VERSION_STRING;
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClass.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClass.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClass.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClass.java Thu Oct 22 12:22:37 2009
@@ -14,6 +14,7 @@
 
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -21,7 +22,11 @@
 import javax.tools.diagnostics.image.ImagePointer;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaMethod;
 import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
+
+import org.apache.kato.jvmti.process.CorruptDataImpl;
 
 public class JClass implements JavaClass {
 	/**
@@ -54,7 +59,7 @@
 	public String classSig = null;
 	public String sourceFile;
 	private List<JClass> interfaces = null;
-	private List<JMethod> methods = null;
+	private List<JavaMethod> methods = null;
 	private ObjectMapList<Long, JField> fields = null;
 	public int locIn; // remove this
 
@@ -73,21 +78,89 @@
 
 	public void addMethod(JMethod m) {
 		if (methods == null) {
-			methods = new LinkedList<JMethod>();
+			methods = new LinkedList<JavaMethod>();
 		}
 		m.setParent(this);
 		methods.add(m);
 	}
 
+	private JClass componentType = null;
+	
+	/**
+	 * Returns the component type of this array class. 
+	 * Takes the 
+	 * 
+	 * @return JavaClass
+	 * @throws IllegalArgumentException when the JavaClass is not an array type/
+	 */
 	@Override
 	public JavaClass getComponentType() throws CorruptDataException {
-		// TODO Auto-generated method stub
-		return null;
+		if (!isArray()) {
+			throw new IllegalArgumentException("JavaClass.getComponentType() cannot be called on a non-array type - \"" +
+					classSig + "\"");
+		}
+		
+		
+		if (componentType == null) {
+			String componentSig = classSig.substring(1);
+					
+			switch (componentSig.charAt(0)) {
+			case 'L':
+				// This is an array of objects. Strip off L and ;
+				// [Ljava/lang/Object; -> java/lang/Object
+				componentSig = componentSig.substring(1, componentSig.length()-1);				
+				break;
+			case '[':
+				// This is fine - make no change. 
+				break;
+			case 'Z':
+				componentSig = "boolean";
+				break;
+			case 'B':
+				componentSig = "byte";
+				break;
+			case 'C':
+				componentSig = "char";
+				break;
+			case 'S':
+				componentSig = "short";
+				break;
+			case 'I':
+				componentSig = "int";
+				break;
+			case 'J':
+				componentSig = "long";
+				break;
+			case 'F':
+				componentSig = "float";
+				break;
+			case 'D':
+				componentSig = "double";
+				break;
+			default:
+				throw CorruptDataImpl.corruptDataException("Tried to determine component type from invalid starting character '" +
+						+componentSig.charAt(0)+"', should be one of 'ZBCSIJFD[L'");
+			}
+			componentType = (JClass) classloader.findClass(componentSig);
+			
+			if (componentType == null) {
+				JavaObject classLoaderObj =classloader.getObject();
+				long id = 0;
+				
+				if (classLoaderObj != null) {
+					id = classLoaderObj.getID().getAddress();
+				}
+				
+				throw CorruptDataImpl.corruptDataException("Unable to find class of type `"+componentSig+"' from" +
+						" classloader 0x"+Long.toHexString(id));
+			}
+		}
+		return componentType;
 	}
 
 	@Override
 	public List getConstantPoolReferences() {
-		return new LinkedList();
+		return Collections.EMPTY_LIST;
 
 	}
 
@@ -96,24 +169,23 @@
 
 		if (fields == null)
 			fields = new ObjectMapList<Long, JField>();
-		return fields.values();
+		return Collections.unmodifiableList(fields.values());
 	}
 
 	@Override
-	public List getDeclaredMethods() {
+	public List<JavaMethod> getDeclaredMethods() {
 		if (methods == null)
-			methods = new LinkedList<JMethod>();
-		return methods;
+			methods = new LinkedList<JavaMethod>();
+		return Collections.unmodifiableList(methods);
 	}
 
 	@Override
 	public ImagePointer getID() {
-		// TODO Auto-generated method stub
 		return new SimpleImagePointer(classid);
 	}
 
 	@Override
-	public List getInterfaces() {
+	public List<String> getInterfaces() {
 		// TODO implement this
 		LinkedList<String> interfaceNames = new LinkedList<String>();
 		if (interfaces != null) {
@@ -131,7 +203,6 @@
 
 	@Override
 	public int getModifiers() throws CorruptDataException {
-
 		return modifiers;
 	}
 
@@ -145,13 +216,13 @@
 
 	@Override
 	public JavaObject getObject() throws CorruptDataException {
-		// TODO Auto-generated method stub
+		// This is expected.
 		return null;
 	}
 
 	@Override
-	public List getReferences() {
-		return new LinkedList();
+	public List<JavaReference> getReferences() {
+		return Collections.emptyList();
 	}
 
 	@Override
@@ -170,7 +241,7 @@
 			fields = new ObjectMapList<Long, JField>();
 		}
 
-		JField f = fields.get(id);
+		JField f = (JField) fields.get(id);
 		if (f == null) {
 			f = new JField(this, id);
 			fields.put(id, f);

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClassLoader.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClassLoader.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JClassLoader.java Thu Oct 22 12:22:37 2009
@@ -14,6 +14,7 @@
 
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -43,7 +44,7 @@
 
 	@Override
 	public List<JavaClass> getCachedClasses() {
-		return new EmptyList<JavaClass>();
+		return Collections.emptyList();
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JHeap.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JHeap.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JHeap.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JHeap.java Thu Oct 22 12:22:37 2009
@@ -13,6 +13,7 @@
  ******************************************************************************/
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.List;
 
 import javax.tools.diagnostics.image.ImageSection;
@@ -51,7 +52,7 @@
 	 */
 	@Override
 	public List<ImageSection> getSections() {
-		return new EmptyList<ImageSection>();
+		return Collections.emptyList();
 	}
 
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMethod.java Thu Oct 22 12:22:37 2009
@@ -82,12 +82,12 @@
 
 	@Override
 	public List<ImageSection> getBytecodeSections() {
-		return new EmptyList<ImageSection>();
+		return Collections.emptyList();
 	}
 
 	@Override
 	public List<ImageSection> getCompiledSections() {
-		return new EmptyList<ImageSection>();
+		return Collections.emptyList();
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java Thu Oct 22 12:22:37 2009
@@ -14,6 +14,7 @@
 
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -308,12 +309,12 @@
 
 	@Override
 	public List<JavaReference> getReferences() {
-		return new EmptyList<JavaReference>();
+		return Collections.emptyList();
 	}
 
 	@Override
 	public List<ImageSection> getSections() {
-		return new EmptyList<ImageSection>();
+		return Collections.emptyList();
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JStackFrame.java Thu Oct 22 12:22:37 2009
@@ -14,6 +14,7 @@
 
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.logging.Level;
 
@@ -49,7 +50,7 @@
 	}
 	@Override
 	public List<JavaReference> getHeapRoots() {
-		return new EmptyList<JavaReference>();
+		return Collections.emptyList();
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java Thu Oct 22 12:22:37 2009
@@ -14,6 +14,7 @@
 
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.logging.Level;
@@ -160,7 +161,7 @@
 	
 	@Override
 	public List<ImageSection> getStackSections() {
-		return new EmptyList<ImageSection>();
+		return Collections.emptyList();
 	}
 	
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapList.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapList.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapList.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapList.java Thu Oct 22 12:22:37 2009
@@ -14,27 +14,67 @@
 
 package org.apache.kato.jvmti.javaruntime.model;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Stores values in both a map and in a list.
+ * 
+ *
+ * @param <K> Key type
+ * @param <V> Value type
+ */
 public class ObjectMapList<K,V> {
-	HashMap<K,V> map=new HashMap<K,V>();
-	LinkedList<V> list=new LinkedList<V>();
-	public List<V> values() {
-		
-		return list;
+	private HashMap<K,V> map=new HashMap<K,V>();
+	private LinkedList<V> list=new LinkedList<V>();
+	
+	/**
+	 * Returns unmodifiable List of the values.
+	 * 
+	 * @return List of map values.
+	 */
+	public List<V> values() {		
+		return Collections.unmodifiableList(list);
 	}
+	
+	/**
+	 * Given a key, return the value associated with this.
+	 * 
+	 * @param key non-null object as a key.
+	 * @return value or null if not found.
+	 */
 	public V get(K key) {
+		if (key == null) {
+			throw new NullPointerException("Key cannot be null.");
+		}
 		
 		return map.get(key);
 	}
-	public void put(K key, V value) {
+	
+	/**
+	 * Associates a key with a value.
+	 * 
+	 * @param key  object to identify value. Must not be null.
+	 * @param value  object to be associated with key. Must not be null.
+	 * @return the previous value associated with the key, or null.
+	 */
+	public V put(K key, V value) {
+		if (value == null) {
+			throw new NullPointerException("Value must not be null.");
+		}
+		
+		if (key == null) {
+			throw new NullPointerException("Key must not be null.");
+		}
+		
 		if(map.containsKey(key)) {
 			Object orig=map.get(key);
 			list.remove(orig);
 		}
-		map.put(key, value);
+		
 		list.add(value);
+		return map.put(key, value);
 	}
-}
\ No newline at end of file
+}

Added: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/CorruptDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/CorruptDataImpl.java?rev=828669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/CorruptDataImpl.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/CorruptDataImpl.java Thu Oct 22 12:22:37 2009
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.jvmti.process;
+
+import javax.tools.diagnostics.image.CorruptData;
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.ImagePointer;
+
+/**
+ * Implementation of CorruptData.
+ * Very simply - all implementations should be like this.
+ * 
+ */
+public class CorruptDataImpl implements CorruptData {
+	private String string;
+	private ImagePointer pointer = null;
+	
+	/**
+	 * Convenience method for creating CorruptDataException instances.
+	 * They always take a CorruptData object.
+	 * 
+	 * @param desc Description of corrupt data.
+	 * @return a CorruptDataException with an initialized CorruptData instance.
+	 */
+	static public CorruptDataException corruptDataException(String desc) {
+		return new CorruptDataException(new CorruptDataImpl(desc));
+	}
+	
+	/**
+	 * Convenience method for creating CorruptDataException instances.
+	 * They always take a CorruptData object.
+	 * 
+	 * @param desc Description of corrupt data.
+	 * @param pointer locations of corrupt data.
+	 * @return a CorruptDataException with an initialized CorruptData instance.
+	 */
+	static public CorruptDataException corruptDataException(String desc, ImagePointer pointer) {
+		return new CorruptDataException(new CorruptDataImpl(desc, pointer));
+	}
+	
+	/**
+	 * Constructor for CorruptDataImpl. Takes a String. 
+	 * @param desc description of the corrupt data.
+	 */
+	public CorruptDataImpl(String desc) {
+		this.string = desc;
+	}
+	
+	/**
+	 * Constructor for CorruptDataImpl. Takes a String. 
+	 * @param desc description of the corrupt data.
+	 * @param pointer ImagePointer to locate corrupt data. 
+	 */	
+	public CorruptDataImpl(String desc, ImagePointer pointer) {
+		this.string = desc;
+		this.pointer = pointer;
+	}
+	
+	@Override
+	public ImagePointer getAddress() {
+		return pointer;
+	}
+
+	@Override
+	public String toString() {
+		return string +
+		((pointer == null) ? "" : ", @  0x" + Long.toHexString(pointer.getAddress()));	
+	}
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/CorruptDataImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/process/ImageImpl.java Thu Oct 22 12:22:37 2009
@@ -17,6 +17,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -34,7 +35,6 @@
 import javax.tools.diagnostics.runtime.ManagedRuntime;
 
 import org.apache.kato.jvmti.javaruntime.JavaRuntimeImpl;
-import org.apache.kato.jvmti.javaruntime.model.EmptyList;
 import org.apache.kato.jvmti.javaruntime.model.SimpleImagePointer;
 import org.apache.kato.jvmti.reader.CJVMTIBinReader;
 
@@ -129,7 +129,7 @@
 
 	@Override
 	public List<ImageThread> getThreads() {
-		return new EmptyList<ImageThread>();
+		return Collections.emptyList();
 	}
 
 	@Override
@@ -139,7 +139,7 @@
 
 	@Override
 	public List<ImageSection> getImageSections() {
-		return new EmptyList<ImageSection>();
+		return Collections.emptyList();
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java?rev=828669&r1=828668&r2=828669&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java Thu Oct 22 12:22:37 2009
@@ -57,6 +57,9 @@
  */
 public class CJVMTIBinReader {
 
+	// This is literally the String in the
+	public static final String CJVMTI_VERSION_STRING = "CJVMTI V0.01";
+	
 	private static final byte CJVMTI_BYTE = 0x1c;
 	private static final byte CJVMTI_CHAR = 0x01;
 	private static final byte CJVMTI_DOUBLE = 0x02;
@@ -221,12 +224,12 @@
 			sb.append((char) variablesIn.readByte());
 		}
 
-		if (!sb.toString().equals("CJVMTI V0.01")) {
+		if (!sb.toString().equals(CJVMTI_VERSION_STRING)) {
 			System.err.println("Incorrect format for reader _" + sb.toString()
 					+ "_");
 			throw new IOException();
 		}
-		log.log(Level.INFO, "CJVMTI Format V0.01");
+		log.log(Level.INFO, CJVMTI_VERSION_STRING);
 		log.log(Level.INFO, "Starting reading in..");
 
 		time = variablesIn.readLong();

Added: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapListTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapListTest.java?rev=828669&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapListTest.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapListTest.java Thu Oct 22 12:22:37 2009
@@ -0,0 +1,106 @@
+package org.apache.kato.jvmti.javaruntime.model;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Some simple tests for ObjectMapList.
+ * Ensures that the map and the list behave properly.
+ * 
+ */
+public class ObjectMapListTest extends TestCase {
+
+	
+	ObjectMapList<Long,Long> oml;
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		oml = new ObjectMapList<Long,Long>();
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	public void addValues() {
+		oml.put(new Long(1), new Long(2));
+		oml.put(new Long(3), new Long(4));
+		oml.put(new Long(5), new Long(6));	
+	}
+	
+	public void testUnmodifiableValuesAdd() {
+		addValues();
+		
+		List<Long> values = oml.values();
+		
+		try{
+			values.add(new Long(7));
+			fail("values.add(value) should throw UnsupportedOperationException");
+		} catch(UnsupportedOperationException e) {
+			// expected
+		}		
+	}
+
+	public void testGet1() {
+		addValues();
+		
+		assertEquals(new Long(2), oml.get(new Long(1)));
+	}
+	
+	public void testGet3() {
+		addValues();
+		
+		assertEquals(new Long(4), oml.get(new Long(3)));
+	}
+	
+	public void testGet5() {
+		addValues();
+		
+		assertEquals(new Long(6), oml.get(new Long(5)));
+	}
+	
+	public void testValuesContents() {
+		addValues();
+
+		// Copy the list.
+		List<Long> list = new LinkedList<Long>(oml.values());
+
+		// So we can sort it.
+		Collections.sort(list);
+		
+		assertEquals(new Long(2), list.remove(0));
+		assertEquals(new Long(4), list.remove(0));
+		assertEquals(new Long(6), list.remove(0));		
+	}
+	
+	public void testGetNull() {
+		try{
+			oml.get(null);
+			fail("Get with null key did not throw NPE");
+		} catch (NullPointerException e) {
+			// Expected			
+		}
+
+	}
+
+	public void testPutNullValue() {
+		try{
+			oml.put(new Long(1), null);
+			fail("Put with null value did not throw NPE");
+		} catch (NullPointerException e) {
+			// Expected
+		}
+	}
+	
+	public void testPutNullKey() {
+		try{
+			oml.put(null, new Long(1));
+			fail("Put with null key did not throw NPE");
+		} catch (NullPointerException e) {
+			// Expected			
+		}
+	}
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/test/java/org/apache/kato/jvmti/javaruntime/model/ObjectMapListTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain