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 sp...@apache.org on 2009/11/30 16:19:55 UTC

svn commit: r885479 - in /incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof: image/SimpleImagePointer.java java/JavaRuntimeImpl.java

Author: spoole
Date: Mon Nov 30 16:19:54 2009
New Revision: 885479

URL: http://svn.apache.org/viewvc?rev=885479&view=rev
Log:
fixes to hprof JavaRuntime impl to support basic legacy contract for API

Added:
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/image/SimpleImagePointer.java
Modified:
    incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/java/JavaRuntimeImpl.java

Added: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/image/SimpleImagePointer.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/image/SimpleImagePointer.java?rev=885479&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/image/SimpleImagePointer.java (added)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/main/java/org/apache/kato/hprof/image/SimpleImagePointer.java Mon Nov 30 16:19:54 2009
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.image;
+
+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;
+
+public final class SimpleImagePointer implements ImagePointer {
+	private long address=0;
+	public SimpleImagePointer(long id) {
+		this.address=id;
+	}
+
+	@Override
+	public ImagePointer add(long offset) {
+		return new SimpleImagePointer(offset + address);
+	}
+
+	@Override
+	public long getAddress() {		
+		return address;
+	}
+
+	@Override
+	public ImageAddressSpace getAddressSpace() {
+		return null;
+	}
+
+	@Override
+	public byte getByteAt(long index) throws MemoryAccessException,
+			CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public double getDoubleAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public float getFloatAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public int getIntAt(long index) throws MemoryAccessException,
+			CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public long getLongAt(long index) throws MemoryAccessException,
+			CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public ImagePointer getPointerAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public short getShortAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		throw new MemoryAccessException(this, "No memory is available in this dump type.");
+	}
+
+	@Override
+	public boolean isExecutable() throws DataUnavailable {
+		throw new DataUnavailable("No memory is available in this dump type.");
+	}
+
+	@Override
+	public boolean isReadOnly() throws DataUnavailable {
+		throw new DataUnavailable("No memory is available in this dump type.");
+	}
+
+	@Override
+	public boolean isShared() throws DataUnavailable {
+		throw new DataUnavailable("No memory is available in this dump type.");
+	}
+}
\ No newline at end of file

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=885479&r1=885478&r2=885479&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 Mon Nov 30 16:19:54 2009
@@ -32,6 +32,7 @@
 import org.apache.kato.hprof.HProfView;
 import org.apache.kato.hprof.IJavaThread;
 import org.apache.kato.hprof.image.CorruptDataImpl;
+import org.apache.kato.hprof.image.SimpleImagePointer;
 
 public class JavaRuntimeImpl implements JavaRuntime {
 
@@ -60,8 +61,8 @@
 
 	@Override
 	public List getHeapRoots() {
-		// TODO Auto-generated method stub
-		return null;
+		List l=new LinkedList();
+		return l;
 	}
 
 	private JavaHeapImpl heap;
@@ -89,8 +90,8 @@
 	
 	@Override
 	public ImagePointer getJavaVM() throws CorruptDataException {
-		// TODO Auto-generated method stub
-		return null;
+		
+		return new SimpleImagePointer(0);
 	}
 
 	@Override
@@ -124,6 +125,10 @@
 	public JavaObject getObjectAtAddress(ImagePointer address)
 			throws CorruptDataException, IllegalArgumentException,
 			MemoryAccessException, DataUnavailable {
+		
+		if(address==null) {
+			throw new IllegalArgumentException("address is null");	
+		}
 		JavaObject obj = heap.getObjectByID(address.getAddress());
 		
 		if (obj == null) {