incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r906592 - in /incubator/kato/trunk/org.apache.kato: kato.hprof.api/src/main/java/org/apache/kato/hprof/java/ kato.hprof.api/src/test/java/org/apache/kato/hprof/java/ kato.hprof.reader/src/main/java/org/apache/kato/hprof/ kato.hprof.reader/s...
Date Thu, 04 Feb 2010 18:15:56 GMT
Author: monteith
Date: Thu Feb  4 18:15:55 2010
New Revision: 906592

URL: http://svn.apache.org/viewvc?rev=906592&view=rev
Log:
Add heaproots implementation to hprof readers. Just need to add stack frames roots, including jni local references.
Run this in katoview for the heaproots: xpath runtime heapRoots
For the references from classes and objects roots:  xpath runtime heapRoots/target/references

Added:
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaReferenceImpl.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNIGlobalRefHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNILocalHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJavaFrameHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootMonitorUsedHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootNativeStackHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootStickyClassHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadBlockHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadObjHeapRecord.java   (with props)
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootUnknownHeapRecord.java   (with props)
Modified:
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/IJavaHeapInternal.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassLoaderImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaHeapImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectArrayImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaRuntimeImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaStackFrameImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaThreadImpl.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/org/apache/kato/hprof/java/JavaHeapImplTest.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/ConstantPoolEntry.java
    incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/HProfFile.java

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/IJavaHeapInternal.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/IJavaHeapInternal.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/IJavaHeapInternal.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/IJavaHeapInternal.java Thu Feb  4 18:15:55 2010
@@ -15,6 +15,7 @@
 
 import java.util.Collection;
 
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.Handle;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaHeap;
@@ -43,5 +44,5 @@
 
 	abstract Collection<JavaClassLoaderImpl> getJavaClassLoaders();
 
-	abstract Handle getHandle(long address); 
+	abstract Handle getHandle(EntityType type, long address); 
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassImpl.java Thu Feb  4 18:15:55 2010
@@ -13,6 +13,7 @@
  ******************************************************************************/
 package org.apache.kato.hprof.java;
 
+import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -21,11 +22,13 @@
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
 import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.Handle;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaClassLoader;
 import javax.tools.diagnostics.runtime.java.JavaField;
 import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
 
 import org.apache.kato.common.BasicType;
 import org.apache.kato.hprof.IJavaClass;
@@ -718,7 +721,7 @@
 	 */
 	@Override	
 	public Handle getID() {
-		return heap.getHandle(javaClass.getClassObjectID());
+		return heap.getHandle(EntityType.javaclass, javaClass.getClassObjectID());
 	}
 
 	/**
@@ -820,11 +823,90 @@
 		return heap.getJavaClassByID(superClassObjId);
 	}
 
+
 	@Override
-	public List getReferences() {
-		// TODO Auto-generated method stub
-		// All object references, constantpool entries, superclass, etc.
-		return null;
+	public List<JavaReference> getReferences() {
+		List<JavaReference> list = new LinkedList<JavaReference>();
+
+		
+		try {
+			JavaClass superClass = getSuperclass();
+			
+			if (superClass != null ) {
+				list.add(new JavaReferenceImpl(this,
+						superClass,
+						"Superclass",
+						JavaReference.REACHABILITY_STRONG,
+						JavaReference.REFERENCE_SUPERCLASS,
+						JavaReference.HEAP_ROOT_UNKNOWN));
+			}
+		} catch (CorruptDataException e) {
+			e.printStackTrace();
+		}
+
+
+		JavaObject signerObject = heap.getObjectByID(javaClass.getSignersObjectID());
+
+		if (signerObject != null) {
+			list.add(new JavaReferenceImpl(this,
+					signerObject,
+					"Signers array",
+					JavaReference.REACHABILITY_STRONG,
+					JavaReference.REFERENCE_SIGNERS,
+					JavaReference.HEAP_ROOT_UNKNOWN));						
+		}
+		
+		JavaObject protectionDomainObject = heap.getObjectByID( javaClass.getProtectionDomainObjectID());
+		if (protectionDomainObject != null) {
+			list.add(new JavaReferenceImpl(this,
+					protectionDomainObject,
+					"Protection domain",
+					JavaReference.REACHABILITY_STRONG,
+					JavaReference.REFERENCE_PROTECTION_DOMAIN,
+					JavaReference.HEAP_ROOT_UNKNOWN));						
+		}
+		
+		StaticFieldEntry[] staticFields = javaClass.getStaticFields();
+		
+		for (StaticFieldEntry field : staticFields) {
+			if (field.getType() == BasicType.OBJECT) {
+				long id = field.getIDField();
+				if (id != 0L) {
+					JavaObject obj = heap.getObjectByID(id);
+
+					if (obj != null) {
+						list.add(new JavaReferenceImpl(this,
+								obj,
+								"Static field",
+								JavaReference.REACHABILITY_STRONG,
+								JavaReference.REFERENCE_STATIC_FIELD,
+								JavaReference.HEAP_ROOT_UNKNOWN));						
+					}
+				}
+			}
+		}
+		
+		
+		ConstantPoolEntry cpes[] = javaClass.getConstantPoolEntries();
+		for(ConstantPoolEntry cpe : cpes) {
+			if (cpe.getType() == BasicType.OBJECT) {
+				long id = cpe.getIDField();				
+				if (id != 0L) {
+					JavaObject obj = heap.getObjectByID(id);
+					
+					if (obj != null) {
+						list.add(new JavaReferenceImpl(this,
+								obj,
+								"Constantpool entry",
+								JavaReference.REACHABILITY_STRONG,
+								JavaReference.REFERENCE_CONSTANT_POOL,
+								JavaReference.HEAP_ROOT_UNKNOWN));						
+					}
+				}
+			}
+		}
+		
+		return list;
 	}
 
 	/**
@@ -902,4 +984,5 @@
 	int getOffsetSize() {
 		return javaClass.getOffsetSize();
 	}
+	
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassLoaderImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassLoaderImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaClassLoaderImpl.java Thu Feb  4 18:15:55 2010
@@ -19,6 +19,7 @@
 import java.util.List;
 
 import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.JavaClassLoader;
 import javax.tools.diagnostics.runtime.java.JavaObject;
 
@@ -104,7 +105,8 @@
 			JavaClassImpl clazz = heap.getJavaClassByID(ID);
 
 			if (clazz == null) {
-				return new CorruptDataImpl((JHandle) heap.getHandle(ID), "Can't match class object ID to a JavaClassImpl.");
+				return new CorruptDataImpl((JHandle) heap.getHandle(EntityType.javaclass, ID),
+						"Can't match class object ID to a JavaClassImpl.");
 			}
 			
 			return clazz;

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaHeapImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaHeapImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaHeapImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaHeapImpl.java Thu Feb  4 18:15:55 2010
@@ -21,13 +21,23 @@
 
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.ImageAddressSpace;
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
+import javax.tools.diagnostics.runtime.java.JavaThread;
 
 import org.apache.kato.common.BasicType;
 import org.apache.kato.common.IteratorBackedList;
 import org.apache.kato.common.ObjectMapList;
 import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.IGCRootJNIGlobalRefHeapRecord;
+import org.apache.kato.hprof.IGCRootMonitorUsedHeapRecord;
+import org.apache.kato.hprof.IGCRootNativeStackHeapRecord;
+import org.apache.kato.hprof.IGCRootStickyClassHeapRecord;
+import org.apache.kato.hprof.IGCRootThreadBlockHeapRecord;
+import org.apache.kato.hprof.IGCRootThreadObjHeapRecord;
+import org.apache.kato.hprof.IGCRootUnknownHeapRecord;
 import org.apache.kato.hprof.IJavaClass;
 import org.apache.kato.hprof.IJavaClassLoader;
 import org.apache.kato.hprof.datalayer.IGCInstanceHeapDumpRecord;
@@ -170,6 +180,7 @@
 		return null;
 	}
 
+	
 	private HashMap<Long,JavaClassImpl> classCache = new HashMap<Long,JavaClassImpl>();
 
 	/**
@@ -266,7 +277,8 @@
 					 name ="<invalid primitive class type "+type+">";
 			}
 			
-			clazz = primitiveClasses[type-4] = new JavaPrimitiveClassImpl(name, getHandle(type),
+			clazz = primitiveClasses[type-4] = new JavaPrimitiveClassImpl(name,
+					getHandle(EntityType.javaclass, type),
 					this.getJavaClassLoaderByID(0)); // The system class loader is 0
 		}
 		
@@ -349,8 +361,8 @@
 	}
 
 	@Override
-	public JHandle getHandle(long address) {
-		return (JHandle) addressSpace.getPointer(address);
+	public JHandle getHandle(EntityType type, long address) {
+		return  new JHandle(type ,address);
 	}
 	
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectArrayImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectArrayImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectArrayImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectArrayImpl.java Thu Feb  4 18:15:55 2010
@@ -20,10 +20,12 @@
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
 import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.Handle;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaHeap;
 import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
 
 import org.apache.kato.hprof.datalayer.IGCObjectArrayHeapDumpRecord;
 
@@ -103,7 +105,7 @@
 
 	@Override
 	public Handle getID() {
-		return heap.getHandle(record.getID());
+		return heap.getHandle(EntityType.javaobject, record.getID());
 	}
 
 	@Override
@@ -116,9 +118,42 @@
 			CorruptDataException {
 		throw new DataUnavailable("Persistent hashcode unknown.");	}
 
+	/**
+	 * Returns a List of JavaReferences
+	 * 
+	 *  @FIXME Creates a list of all of the object elements. This is a really dump thing to do with large arrays.
+	 */
 	@Override
-	public List getReferences() {
-		return new LinkedList();
+	public List<JavaReference> getReferences() {
+		List<JavaReference> list = new LinkedList<JavaReference>();
+		
+		try {
+			list.add(new JavaReferenceImpl(this, getJavaClass(),
+					"Array object class",
+					JavaReference.REACHABILITY_STRONG,
+					JavaReference.REFERENCE_CLASS,
+					JavaReference.HEAP_ROOT_UNKNOWN));
+		} catch (CorruptDataException e) {
+			e.printStackTrace();
+		}
+		
+		try {
+			for(int i = 0; i < getArraySize(); i++) {
+				 JavaObject reference = heap.getObjectByID(record.getElement(i));
+				 
+				 if (reference != null) {
+					 list.add(new JavaReferenceImpl(this, reference,
+								"Array element",
+								JavaReference.REACHABILITY_STRONG,
+								JavaReference.REFERENCE_ARRAY_ELEMENT,
+								JavaReference.HEAP_ROOT_UNKNOWN));
+				 }
+			}
+		} catch (CorruptDataException e) {
+			e.printStackTrace();
+		}
+		
+		return list;
 	}
 
 	@Override
@@ -165,4 +200,14 @@
 	public long getObjectID() {
 		return record.getID();
 	}
+	
+	@Override
+	public String toString() {
+		try {
+			return "JavaObject: "+this.getJavaClass().getName()+" @ 0x"+Long.toHexString(getID().getAddress());
+		} catch (CorruptDataException e) {
+			return "JavaObject: <Corrupt name> @ 0x"+Long.toHexString(getID().getAddress());
+		}
+		
+	}
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java Thu Feb  4 18:15:55 2010
@@ -13,15 +13,21 @@
  ******************************************************************************/
 package org.apache.kato.hprof.java;
 
+import java.lang.reflect.Modifier;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
 import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.Handle;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaField;
 import javax.tools.diagnostics.runtime.java.JavaHeap;
 import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
 
 import org.apache.kato.hprof.datalayer.IGCInstanceHeapDumpRecord;
 
@@ -66,7 +72,7 @@
 
 	@Override
 	public Handle getID() {		
-		return heap.getHandle(record.getID());
+		return heap.getHandle(EntityType.javaobject, record.getID());
 	}
 
 	@Override
@@ -82,11 +88,74 @@
 		throw new DataUnavailable("Persistent hashcode unknown.");
 	}
 
+	/**
+	 * Implements {@link JavaObject#getReferences()}. 
+	 * 
+	 * 
+	 */
 	@Override
-	public List getReferences() {
-		return new LinkedList();
+	public List<JavaReference> getReferences() {
+		List<JavaReference> list = new LinkedList<JavaReference>();
+		
+		JavaClass clazz = null;
+		try {
+			 clazz = this.getJavaClass();
+		} catch (CorruptDataException e) {
+			e.printStackTrace();
+		}
+		
+		list.add(new JavaReferenceImpl(this, 
+				clazz, 
+				"Object class", 
+				JavaReference.REACHABILITY_STRONG,
+				JavaReference.REFERENCE_CLASS,
+				JavaReference.HEAP_ROOT_UNKNOWN));
+		
+		// Add all non
+		while (clazz != null ) {
+			List<JavaField> fields = clazz.getDeclaredFields();
+			
+			for (JavaField field : fields) {
+				try {
+					String signature = field.getSignature();
+					int modifiers = field.getModifiers();
+					
+					// Add all non-static 
+					if (!Modifier.isStatic(modifiers) &&
+							(signature.startsWith("L") ||
+									signature.startsWith("["))) {
+						JavaObject ref =  (JavaObject) field.get(this);
+						
+						if (ref != null) {
+							list.add(new JavaReferenceImpl(this, 
+									ref, 
+									"Instance field reference", 
+									JavaReference.REACHABILITY_STRONG,
+									JavaReference.REFERENCE_FIELD,
+									JavaReference.HEAP_ROOT_UNKNOWN));
+						}
+						
+					}
+				} catch (CorruptDataException e) {
+					e.printStackTrace();
+				} catch (MemoryAccessException e) {
+					e.printStackTrace();
+				}
+			}
+		
+			try {
+				clazz = clazz.getSuperclass();
+			} catch (CorruptDataException e) {
+				e.printStackTrace();
+				break;				
+			}
+		}
+		
+		return Collections.unmodifiableList(list);
 	}
 
+	
+	
 	@Override
 	public List getSections() {		
 		return new LinkedList();
@@ -219,4 +288,13 @@
 		return record.getID();
 	}
 	
+	@Override
+	public String toString() {
+		try {
+			return "JavaObject: "+this.getJavaClass().getName()+" @ 0x"+Long.toHexString(getID().getAddress());
+		} catch (CorruptDataException e) {
+			return "JavaObject: <Corrupt name> @ 0x"+Long.toHexString(getID().getAddress());
+		}
+		
+	}
 }
\ No newline at end of file

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java Thu Feb  4 18:15:55 2010
@@ -20,6 +20,7 @@
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
 import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.Handle;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaHeap;
@@ -196,7 +197,7 @@
 
 	@Override
 	public Handle getID() {
-		return heap.getHandle(record.getID());
+		return heap.getHandle(EntityType.javaobject, record.getID());
 	}
 
 	@Override

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaReferenceImpl.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaReferenceImpl.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaReferenceImpl.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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.hprof.java;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
+
+final public class JavaReferenceImpl implements JavaReference {
+	
+	public JavaReferenceImpl(Object source, Object target, String description,
+			int reachability, int referenceType, int rootType ){
+		if (target == null) {
+				throw new IllegalArgumentException("target must not be null");
+		}
+		
+		this.source = source;
+		this.target = target;
+		this.description = description;
+		this.reachability = reachability;
+		this.referenceType = referenceType;
+		this.rootType = rootType;
+	}
+	
+	private String description;
+	@Override
+	public String getDescription() {
+		return description;
+	}
+
+	private int reachability;
+	@Override
+	public int getReachability() throws CorruptDataException {
+		return reachability;
+	}
+
+	private int referenceType;
+	@Override
+	public int getReferenceType() throws CorruptDataException {
+		return referenceType;
+	}
+
+	private int rootType;
+	@Override
+	public int getRootType() throws CorruptDataException {
+		return rootType;
+	}
+
+	private Object source;
+	@Override
+	public Object getSource() throws DataUnavailable, CorruptDataException {
+		return source;
+	}
+
+	private Object target;
+	@Override
+	public Object getTarget() throws DataUnavailable, CorruptDataException {
+		return target;
+	}
+
+	boolean classReference;
+	@Override
+	public boolean isClassReference() throws DataUnavailable,
+			CorruptDataException {
+		return target instanceof JavaClass;
+	}
+
+	boolean objectReference;
+	@Override
+	public boolean isObjectReference() throws DataUnavailable,
+			CorruptDataException {
+		return target instanceof JavaObject;
+	}
+
+	/**
+	 * Translates a root type constant into a String.
+	 * @param rootType Root type value HEAP_ROOT_
+	 * @return A string with the constant name.
+	 */
+	public static String rootTypeString(int rootType) {
+		switch (rootType) {
+		case HEAP_ROOT_CLASSLOADER:
+			return "HEAP_ROOT_CLASSLOADER";
+		case HEAP_ROOT_FINALIZABLE_OBJ:
+			return "HEAP_ROOT_FINALIZABLE_OBJ";
+		case HEAP_ROOT_JNI_GLOBAL:
+			return "HEAP_ROOT_JNI_GLOBAL";
+		case HEAP_ROOT_JNI_LOCAL:
+			return "HEAP_ROOT_JNI_LOCAL";
+		case HEAP_ROOT_MONITOR:
+			return "HEAP_ROOT_MONITOR";
+		case HEAP_ROOT_OTHER:
+			return "HEAP_ROOT_OTHER";
+		case HEAP_ROOT_STACK_LOCAL:
+			return "HEAP_ROOT_STACK_LOCAL";
+		case HEAP_ROOT_STRINGTABLE:
+			return "HEAP_ROOT_STRINGTABLE";
+		case HEAP_ROOT_SYSTEM_CLASS:
+			return "HEAP_ROOT_SYSTEM_CLASS";
+		case HEAP_ROOT_THREAD:
+			return "HEAP_ROOT_THREAD";
+		case HEAP_ROOT_UNFINALIZED_OBJ:
+			return "HEAP_ROOT_UNFINALIZED_OBJ";
+		case HEAP_ROOT_UNKNOWN:
+			return "HEAP_ROOT_UNKNOWN";
+		default:
+			return "Unknown root type "+rootType;
+		}
+	}
+	
+	/**
+	 * Translate a reachability value into a String with the name of
+	 * the constant.
+	 * 
+	 * @param reachability  value of constant REACHABILITY_*
+	 * @return String with name of the constant the value corresponds with.
+	 */
+	public static String reachabilityString(int reachability) {
+		switch (reachability) {
+		case REACHABILITY_PHANTOM:
+			return "REACHABILITY_PHANTOM";
+		case REACHABILITY_SOFT:
+			return "REACHABILITY_SOFT";
+		case REACHABILITY_STRONG:
+			return "REACHABILITY_STRONG";
+		case REACHABILITY_UNKNOWN:
+			return "REACHABILITY_UNKNOWN";
+		case REACHABILITY_WEAK:
+			return "REACHABILITY_WEAK";
+		default:
+			return "Unknown reachibility " + reachability;
+		}
+	}
+	
+	public static String referenceTypeString(int referenceType) {
+		switch (referenceType) {
+		case REFERENCE_ARRAY_ELEMENT:
+			return "REFERENCE_ARRAY_ELEMENT";
+		case REFERENCE_ASSOCIATED_CLASS:
+			return "REFERENCE_ASSOCIATED_CLASS";
+		case REFERENCE_CLASS:
+			return "REFERENCE_CLASS";
+		case REFERENCE_CLASS_LOADER:
+			return "REFERENCE_CLASS_LOADER";
+		case REFERENCE_CLASS_OBJECT:
+			return "REFERENCE_CLASS_OBJECT";
+		case REFERENCE_CONSTANT_POOL:
+			return "REFERENCE_CONSTANT_POOL";
+		case REFERENCE_FIELD:
+			return "REFERENCE_FIELD";
+		case REFERENCE_INTERFACE:
+			return "REFERENCE_INTERFACE";
+		case REFERENCE_LOADED_CLASS:
+			return "REFERENCE_LOADED_CLASS";
+		case REFERENCE_PROTECTION_DOMAIN:
+			return "REFERENCE_PROTECTION_DOMAIN";
+		case REFERENCE_SIGNERS:
+			return "REFERENCE_SIGNERS";
+		case REFERENCE_STATIC_FIELD:
+			return "REFERENCE_STATIC_FIELD";
+		case REFERENCE_SUPERCLASS:
+			return "REFERENCE_SUPERCLASS";
+		case REFERENCE_UNKNOWN:
+			return "REFERENCE_UNKNOWN";
+		default:
+			return "Unknown reference type "+referenceType;
+		}
+	}
+	
+	@Override
+	public String toString() {
+		return "JavaReference: source="+source+
+		", target=" + target + 
+		", root type="+ rootTypeString(rootType)+
+		", reachability=" + reachabilityString(reachability) +
+		", reference type =" + referenceTypeString(referenceType);		
+	}
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaReferenceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaRuntimeImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaRuntimeImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaRuntimeImpl.java Thu Feb  4 18:15:55 2010
@@ -16,6 +16,7 @@
 import java.io.File;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -24,19 +25,29 @@
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
 import javax.tools.diagnostics.image.ImageAddressSpace;
-import javax.tools.diagnostics.image.ImagePointer;
 import javax.tools.diagnostics.image.MemoryAccessException;
 import javax.tools.diagnostics.runtime.java.EntityType;
 import javax.tools.diagnostics.runtime.java.Handle;
+import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaHeap;
 import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
 import javax.tools.diagnostics.runtime.java.JavaRuntime;
+import javax.tools.diagnostics.runtime.java.JavaThread;
 import javax.tools.diagnostics.runtime.java.JavaVMInitArgs;
 
 import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.IGCRootJNIGlobalRefHeapRecord;
+import org.apache.kato.hprof.IGCRootMonitorUsedHeapRecord;
+import org.apache.kato.hprof.IGCRootNativeStackHeapRecord;
+import org.apache.kato.hprof.IGCRootStickyClassHeapRecord;
+import org.apache.kato.hprof.IGCRootThreadBlockHeapRecord;
+import org.apache.kato.hprof.IGCRootThreadObjHeapRecord;
+import org.apache.kato.hprof.IGCRootUnknownHeapRecord;
 import org.apache.kato.hprof.IJavaThread;
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
 import org.apache.kato.hprof.image.CorruptDataImpl;
-import org.apache.kato.hprof.image.SimpleImagePointer;
 
 public class JavaRuntimeImpl implements JavaRuntime {
 
@@ -57,23 +68,134 @@
 	
 	@Override
 	public List getCompiledMethods() {
-		
-		
 		List l=new LinkedList();
 		return l;
 	}
 
 	@Override
-	public List getHeapRoots() {
-		List l=new LinkedList();
-		return l;
+	/**
+	 * Returns a list with all of the heap roots in the form of JavaRerences
+	 * 
+	 * @return List<JavaReference>
+	 */
+	public List<JavaReference> getHeapRoots() {
+		List<JavaReference> list = new LinkedList<JavaReference>();
+		
+		// populate threadsMap
+		getThreads();
+		
+		IHeapDumpHProfRecord heapRecord=view.getHeapRecord();
+		int heapRecords = heapRecord.getSubRecordCount();
+		
+		for (int index = 0; index < heapRecords; index++) {
+			IHProfRecord record = heapRecord.getSubRecord(index);
+
+			if (record instanceof IGCRootUnknownHeapRecord) {
+				IGCRootUnknownHeapRecord root = (IGCRootUnknownHeapRecord) record;
+				long objID = root.getID();
+
+				JavaObject obj = heap.getObjectByID(objID);
+				if (obj != null) {
+					list.add(new JavaReferenceImpl(null,
+							obj,
+							"Unknown heap root",
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_OTHER));
+				}
+			} else if (record instanceof IGCRootJNIGlobalRefHeapRecord) {
+				IGCRootJNIGlobalRefHeapRecord root = (IGCRootJNIGlobalRefHeapRecord) record;				
+				JavaObject obj = heap.getObjectByID(root.getObjID());
+				if (obj != null) {
+					list.add(new JavaReferenceImpl(null,
+							obj,
+							"JNI Global Reference, ID 0x"+Long.toHexString(root.getJniID()),
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_JNI_GLOBAL));
+				}
+			} else if (record instanceof IGCRootStickyClassHeapRecord) {
+				IGCRootStickyClassHeapRecord root = (IGCRootStickyClassHeapRecord) record;
+				JavaClass obj = heap.getJavaClassByID(root.getID());
+				
+				if (obj != null) {
+					list.add(new JavaReferenceImpl(null,
+							obj,
+							"Sticky system class",
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_SYSTEM_CLASS));
+				}
+			} else if (record instanceof IGCRootMonitorUsedHeapRecord) {
+				IGCRootMonitorUsedHeapRecord root = (IGCRootMonitorUsedHeapRecord) record;
+				JavaObject obj = heap.getObjectByID(root.getID());
+				
+				if (obj != null) {
+					list.add(new JavaReferenceImpl(null,
+							obj,
+							"Monitor heap root",
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_MONITOR));
+				}
+			} else if (record instanceof IGCRootThreadObjHeapRecord) {
+				IGCRootThreadObjHeapRecord root = (IGCRootThreadObjHeapRecord) record;
+				JavaObject obj = heap.getObjectByID(root.getID());
+				int stackTraceSequenceNumber = root.getStackTraceSequenceNumber();
+				int threadSequenceNumber = root.getThreadSequenceNumber();
+				
+				JavaThread thread = threadsMap.get(threadSequenceNumber);
+				
+				if (obj != null && thread != null) {
+					list.add(new JavaReferenceImpl(thread,
+							obj,
+							"Thread object root",
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_THREAD));
+				}
+			} else if (record instanceof IGCRootThreadBlockHeapRecord) {
+				IGCRootThreadBlockHeapRecord root = (IGCRootThreadBlockHeapRecord) record;
+				JavaObject obj = heap.getObjectByID(root.getID());
+				int threadSerialNumber = root.getThreadSerialNumber();
+
+				JavaThread thread = threadsMap.get(threadSerialNumber);
+
+				if (obj != null && thread != null) {
+					list.add(new JavaReferenceImpl(thread,
+							obj,
+							"Thread block root",
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_THREAD));
+				}
+			} else if (record instanceof IGCRootNativeStackHeapRecord) {
+				IGCRootNativeStackHeapRecord root = (IGCRootNativeStackHeapRecord) record;
+				JavaObject obj = heap.getObjectByID(root.getID());
+				int threadSequenceNumber = root.getThreadSequenceNumber();
+
+				JavaThread thread = threadsMap.get(threadSequenceNumber);
+				
+				if (obj != null && thread != null) {
+					list.add(new JavaReferenceImpl(thread,
+							obj,
+							"Thread native stack root",
+							JavaReference.REACHABILITY_STRONG,
+							JavaReference.REFERENCE_UNKNOWN,
+							JavaReference.HEAP_ROOT_THREAD));
+				}
+				
+			}
+		}
+		
+		return list;
 	}
 
 	private JavaHeapImpl heap;
 	
 	@Override
-	public List getHeaps() {
-		List<JavaHeapImpl> l=new LinkedList<JavaHeapImpl>();
+	public List<JavaHeap> getHeaps() {
+		List<JavaHeap> l=new LinkedList<JavaHeap>();
 		l.add(heap);
 		return l;
 	}
@@ -140,19 +262,27 @@
 		return obj;
 	}
 
-	private List<JavaThreadImpl> threads = null;
+	private List<JavaThread> threads = null;
+	
+	// Map of thread serialization IDs to JavaThread objects.
+	private Map<Integer,JavaThread> threadsMap = null;
 	@Override
-	public List getThreads() {
+	public List<JavaThread> getThreads() {
 		if(threads == null) {
-			threads = new LinkedList<JavaThreadImpl>();
-
+			threads = new LinkedList<JavaThread>();
+			threadsMap = new HashMap<Integer,JavaThread>();
+			
 			Collection<IJavaThread> ithreads = view.getActiveThreads();
 			Iterator<IJavaThread> iter = ithreads.iterator();
 			
 			while (iter.hasNext()) {
-				
-				threads.add(new JavaThreadImpl(heap, iter.next()));
-			}		
+				IJavaThread next = iter.next();
+				JavaThreadImpl thread = new JavaThreadImpl(heap, next); 
+				threads.add(thread);
+				threadsMap.put(next.getThreadSerialNumber() ,thread);
+			}	
+			
+			threads = Collections.unmodifiableList(threads);
 		}
 		
 		return threads;

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaStackFrameImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaStackFrameImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaStackFrameImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaStackFrameImpl.java Thu Feb  4 18:15:55 2010
@@ -18,17 +18,16 @@
 
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImagePointer;
 import javax.tools.diagnostics.image.DiagnosticException;
 import javax.tools.diagnostics.runtime.java.Handle;
 import javax.tools.diagnostics.runtime.java.JavaClass;
 import javax.tools.diagnostics.runtime.java.JavaLocation;
 import javax.tools.diagnostics.runtime.java.JavaMethod;
+import javax.tools.diagnostics.runtime.java.JavaReference;
 import javax.tools.diagnostics.runtime.java.JavaStackFrame;
 import javax.tools.diagnostics.runtime.java.JavaVariable;
 
 import org.apache.kato.hprof.IJavaStackFrame;
-import org.apache.kato.hprof.image.ImagePointerImpl;
 
 /**
  * 	A stack frame, wraps a {@link IJavaHeapInternal}.
@@ -46,9 +45,30 @@
 	
 
 	@Override
-	public List getHeapRoots() {
-		// TODO Need implementation here.
-		return null;
+	public List<JavaReference> getHeapRoots() {
+		List<JavaReference> list = new LinkedList<JavaReference>();
+		
+		JavaClass clazz =null;
+		
+		try {
+			clazz = getLocation().getMethod().getDeclaringClass();
+		} catch (CorruptDataException e) {
+			e.printStackTrace();
+		} catch (DataUnavailable e) {
+			e.printStackTrace();
+		}
+		
+		if (clazz != null) {
+			list.add(new JavaReferenceImpl(this,
+					clazz,
+					"Stack frame class",
+					JavaReference.REACHABILITY_STRONG,
+					JavaReference.REFERENCE_UNKNOWN,
+					JavaReference.HEAP_ROOT_STACK_LOCAL));
+		}
+		
+		
+		return list;
 	}
 
 	private JavaLocation location = new JavaLocationImpl();

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaThreadImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaThreadImpl.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaThreadImpl.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaThreadImpl.java Thu Feb  4 18:15:55 2010
@@ -13,14 +13,11 @@
  ******************************************************************************/
 package org.apache.kato.hprof.java;
 
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Vector;
 
 import javax.tools.diagnostics.image.CorruptDataException;
 import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.image.ImageThread;
 import javax.tools.diagnostics.runtime.java.JavaObject;
 import javax.tools.diagnostics.runtime.java.JavaThread;
 import javax.tools.diagnostics.runtime.java.NativeJavaThread;

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/org/apache/kato/hprof/java/JavaHeapImplTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/org/apache/kato/hprof/java/JavaHeapImplTest.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/org/apache/kato/hprof/java/JavaHeapImplTest.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/org/apache/kato/hprof/java/JavaHeapImplTest.java Thu Feb  4 18:15:55 2010
@@ -91,8 +91,8 @@
 
 	
 	@Override
-	public JHandle getHandle(long address) {
-		return new JHandle(EntityType.javaobject,address);
+	public JHandle getHandle(EntityType type, long address) {
+		return new JHandle(type, address);
 	}
 
 }

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNIGlobalRefHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNIGlobalRefHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNIGlobalRefHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNIGlobalRefHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.hprof;
+
+
+/**
+ * 
+ * Contains the root from a JNI Global reference.
+ * 
+ *
+ */
+public interface IGCRootJNIGlobalRefHeapRecord {
+	
+	/**
+	 * Object ID of global reference.
+	 * 
+	 * @return ID of object root.
+	 */
+	public long getObjID();
+
+	/**
+	 *  
+	 * @return Serial number of JNI global reference. 
+	 */
+	public long getJniID();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNIGlobalRefHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNILocalHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNILocalHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNILocalHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNILocalHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootJNILocalHeapRecord {
+	public long getID();
+
+	public int getThreadSerialNumber();
+
+	public int getStackFrameNumber();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJNILocalHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJavaFrameHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJavaFrameHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJavaFrameHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJavaFrameHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootJavaFrameHeapRecord {
+	public long getID();
+
+	public int getThreadSerialNumber();
+
+	public int getStackFrameNumber();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootJavaFrameHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootMonitorUsedHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootMonitorUsedHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootMonitorUsedHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootMonitorUsedHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootMonitorUsedHeapRecord {
+	public long getID();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootMonitorUsedHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootNativeStackHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootNativeStackHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootNativeStackHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootNativeStackHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootNativeStackHeapRecord {
+	public long getID();
+
+	public int getThreadSequenceNumber();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootNativeStackHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootStickyClassHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootStickyClassHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootStickyClassHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootStickyClassHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootStickyClassHeapRecord {
+	public long getID();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootStickyClassHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadBlockHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadBlockHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadBlockHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadBlockHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootThreadBlockHeapRecord {
+	public long getID();
+
+	public int getThreadSerialNumber();
+}
+

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadBlockHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadObjHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadObjHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadObjHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadObjHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.hprof;
+
+public interface IGCRootThreadObjHeapRecord {
+	public long getID();
+
+	public int getThreadSequenceNumber();
+
+	public int getStackTraceSequenceNumber();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootThreadObjHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootUnknownHeapRecord.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootUnknownHeapRecord.java?rev=906592&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootUnknownHeapRecord.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootUnknownHeapRecord.java Thu Feb  4 18:15:55 2010
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.hprof;
+
+/**
+ * A miscellaneous heap root.
+ * 
+ */
+public interface IGCRootUnknownHeapRecord {
+	/** 
+	 * objectID of a root of unspecified type.
+	 *  
+	 * @return id of root.
+	 */
+	public long getID();
+}

Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/IGCRootUnknownHeapRecord.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/ConstantPoolEntry.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/ConstantPoolEntry.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/ConstantPoolEntry.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/ConstantPoolEntry.java Thu Feb  4 18:15:55 2010
@@ -13,9 +13,61 @@
  ******************************************************************************/
 package org.apache.kato.hprof.datalayer;
 
-public class ConstantPoolEntry {
-	public int cpIndex = 0;
-	public short type = 0;
-	public byte[] data = null;
+final public class ConstantPoolEntry {
+	public int cpIndex;
+	public short type;
+	public long data;
 
+	public ConstantPoolEntry(int cpIndex, short type, long data) {
+		this.cpIndex = cpIndex;
+		this.type = type;
+		this.data = data;
+	}
+	public short getType() {
+		return type;
+	}
+
+	public byte getByteField() {
+		return (byte) data;
+	}
+
+
+	public char getCharField() {
+		return (char) data;
+	}
+
+
+	public double getDoubleField() {
+		return Double.longBitsToDouble(data);
+	}
+
+
+	public float getFloatField() {
+		return Float.intBitsToFloat((int) data);
+	}
+
+
+	public long getIDField() {		
+		return data;
+	}
+
+
+	public int getIntegerField() {
+		return (int)data;
+	}
+
+	
+	public long getLongField() {	
+		return data;
+	}
+
+
+	public short getShortField() {
+		return (short)data;
+	}
+
+	public boolean getBooleanField() {
+		return !(data == 0L);
+	}
+	
 }
\ No newline at end of file

Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/HProfFile.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/HProfFile.java?rev=906592&r1=906591&r2=906592&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/HProfFile.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/datalayer/HProfFile.java Thu Feb  4 18:15:55 2010
@@ -25,7 +25,15 @@
 import org.apache.kato.common.IDataProvider;
 import org.apache.kato.common.InvalidFileFormat;
 import org.apache.kato.common.SubsetDataProvider;
-import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.IGCRootJNIGlobalRefHeapRecord;
+import org.apache.kato.hprof.IGCRootJNILocalHeapRecord;
+import org.apache.kato.hprof.IGCRootJavaFrameHeapRecord;
+import org.apache.kato.hprof.IGCRootMonitorUsedHeapRecord;
+import org.apache.kato.hprof.IGCRootNativeStackHeapRecord;
+import org.apache.kato.hprof.IGCRootStickyClassHeapRecord;
+import org.apache.kato.hprof.IGCRootThreadBlockHeapRecord;
+import org.apache.kato.hprof.IGCRootThreadObjHeapRecord;
+import org.apache.kato.hprof.IGCRootUnknownHeapRecord;
  
 public class HProfFile {
 
@@ -281,7 +289,7 @@
 					return new GCRootStickyClassHeapRecord(tag, data);
 
 				case 0x06: // thread block root
-					return new GCRoothreadBlockHeapRecord(tag, data);
+					return new GCRootThreadBlockHeapRecord(tag, data);
 
 				case 0x07: // monitor used
 					return new GCRootMonitorUsedHeapRecord(tag, data);
@@ -821,13 +829,13 @@
 		return counter;
 	}
 
-	class GCRoothreadBlockHeapRecord extends HProfRecord {
+	class GCRootThreadBlockHeapRecord extends HProfRecord implements IGCRootThreadBlockHeapRecord {
 
-		public GCRoothreadBlockHeapRecord(short tag, byte[] data) {
+		public GCRootThreadBlockHeapRecord(short tag, byte[] data) {
 			super(tag, data);
 		}
 
-		public long getId() {
+		public long getID() {
 			return readNumber(0, idSize);
 		}
 
@@ -837,13 +845,13 @@
 
 	}
 
-	class GCRootJavaFrameHeapRecord extends HProfRecord {
+	class GCRootJavaFrameHeapRecord extends HProfRecord implements IGCRootJavaFrameHeapRecord {
 
 		public GCRootJavaFrameHeapRecord(short tag, byte[] data) {
 			super(tag, data);
 		}
 
-		public long getId() {
+		public long getID() {
 			return readNumber(0, idSize);
 		}
 
@@ -857,30 +865,30 @@
 
 	}
 
-	class GCRootJNIGlobalRefHeapRecord extends HProfRecord {
+	class GCRootJNIGlobalRefHeapRecord extends HProfRecord implements IGCRootJNIGlobalRefHeapRecord {
 
 		public GCRootJNIGlobalRefHeapRecord(short tag, byte[] data) {
 			super(tag, data);
 		}
 
-		public long getObjid() {
+		public long getObjID() {
 			return readNumber(0, idSize);
 		}
 
-		public long getJniid() {
+		public long getJniID() {
 			return readNumber(idSize, idSize);
 		}
 
 	}
 
-	class GCRootJNILocalHeapRecord extends HProfRecord {
+	class GCRootJNILocalHeapRecord extends HProfRecord implements IGCRootJNILocalHeapRecord {
 
 		public GCRootJNILocalHeapRecord(short tag, byte[] data) {
 			super(tag, data);
 
 		}
 
-		public long getId() {
+		public long getID() {
 			return readNumber(0, idSize);
 		}
 
@@ -906,7 +914,7 @@
 		}
 	}
 
-	class GCRootMonitorUsedHeapRecord extends IDEntryHeapRecord {
+	class GCRootMonitorUsedHeapRecord extends IDEntryHeapRecord implements IGCRootMonitorUsedHeapRecord {
 
 		public GCRootMonitorUsedHeapRecord(short tag, byte[] data) {
 			super(tag, data);
@@ -915,7 +923,7 @@
 
 	}
 
-	class GCRootStickyClassHeapRecord extends IDEntryHeapRecord {
+	class GCRootStickyClassHeapRecord extends IDEntryHeapRecord implements IGCRootStickyClassHeapRecord {
 
 		public GCRootStickyClassHeapRecord(short tag, byte[] data) {
 			super(tag, data);
@@ -924,7 +932,7 @@
 
 	}
 
-	class GCRootUnknownHeapRecord extends HProfRecord {
+	class GCRootUnknownHeapRecord extends  IDEntryHeapRecord implements IGCRootUnknownHeapRecord {
 
 		public GCRootUnknownHeapRecord(short tag, byte[] data) {
 			super(tag, data);
@@ -933,14 +941,14 @@
 
 	}
 
-	class GCRootThreadObjHeapRecord extends HProfRecord {
+	class GCRootThreadObjHeapRecord extends HProfRecord implements IGCRootThreadObjHeapRecord {
 
 		public GCRootThreadObjHeapRecord(short tag, byte[] data) {
 			super(tag, data);
 
 		}
 
-		public long getId() {
+		public long getID() {
 			return readNumber(0, idSize);
 		}
 
@@ -954,14 +962,14 @@
 
 	}
 
-	class GCRootNativeStackHeapRecord extends HProfRecord {
+	class GCRootNativeStackHeapRecord extends HProfRecord implements IGCRootNativeStackHeapRecord {
 
 		public GCRootNativeStackHeapRecord(short tag, byte[] data) {
 			super(tag, data);
 
 		}
 
-		public long getId() {
+		public long getID() {
 			return readNumber(0, idSize);
 		}
 
@@ -1361,16 +1369,15 @@
 		private ConstantPoolEntry[] readConstantPool(int offset) {
 			int entries = getConstantPoolSize();
 			ConstantPoolEntry[] pool = new ConstantPoolEntry[entries];
-			for (int i = 0; i < entries; i++) {
-				ConstantPoolEntry cpe = new ConstantPoolEntry();
-				cpe.cpIndex = readShort(offset);
+			for (int i = 0; i < entries; i++) {				
+				short cpIndex = readShort(offset);
 				offset += 2;
-				cpe.type = readByte(offset);
+				short type = readByte(offset);
 				offset++;
-				int valueLength = sizes.getLengthFromType(cpe.type);
-				cpe.data = readBytes(offset, valueLength);
+				int valueLength = sizes.getLengthFromType(type);
+				long data = readNumber(offset, valueLength);
 				offset += valueLength;
-				pool[i] = cpe;
+				pool[i] = new ConstantPoolEntry(cpIndex, type, data);
 			}
 			return pool;
 		}



Mime
View raw message