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/09/18 16:10:35 UTC
svn commit: r816693 [1/2] - in
/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti:
javaruntime/ javaruntime/model/ reader/
Author: monteith
Date: Fri Sep 18 16:10:34 2009
New Revision: 816693
URL: http://svn.apache.org/viewvc?rev=816693&view=rev
Log:
Apply Pual Sobek's patch from KATO-10
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/JField.java
incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.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/Model.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=816693&r1=816692&r2=816693&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 Fri Sep 18 16:10:34 2009
@@ -1,114 +1,113 @@
-/*******************************************************************************
- * 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.javaruntime;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.image.MemoryAccessException;
-import javax.tools.diagnostics.runtime.java.JavaObject;
-import javax.tools.diagnostics.runtime.java.JavaRuntime;
-import javax.tools.diagnostics.runtime.java.JavaVMInitArgs;
-
-import org.apache.kato.jvmti.javaruntime.model.Model;
-import org.apache.kato.jvmti.reader.CLogger;
-
-public class JavaRuntimeImpl implements JavaRuntime {
-
-
- private Model base=null;
-
- public JavaRuntimeImpl(Model m) throws IOException {
- this.base=m;
-
- }
-
- @Override
- public List getCompiledMethods() {
- return new LinkedList();
- }
-
- @Override
- public List getHeapRoots() {
- return new LinkedList();
- }
-
- @Override
- public List getHeaps() {
- return new LinkedList();
- }
-
- @Override
- public List getJavaClassLoaders() {
-
- return base.getJavaClassLoader();
- }
-
- @Override
- public ImagePointer getJavaVM() throws CorruptDataException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public JavaVMInitArgs getJavaVMInitArgs() throws DataUnavailable,
- CorruptDataException {
- throw new DataUnavailable();
- }
-
- @Override
- public List getMonitors() {
-
- return base.getJavaMonitors();
- }
-
- @Override
- public JavaObject getObjectAtAddress(ImagePointer arg0)
- throws CorruptDataException, IllegalArgumentException,
- MemoryAccessException, DataUnavailable {
- CLogger.logr.log(Level.FINEST,"Ask for object at"+arg0.getAddress());
- return base.getObjectAtAddress(arg0.getAddress());
- }
-
- @Override
- public List getThreads() {
-
- return base.getThreads();
- }
-
- @Override
- public Object getTraceBuffer(String arg0, boolean arg1)
- throws CorruptDataException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getFullVersion() throws CorruptDataException {
-
- return "PYJVMTI 1.6.0";
- }
-
- @Override
- public String getVersion() throws CorruptDataException {
- return "1.6.0";
- }
-
-}
+/*******************************************************************************
+ * 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.javaruntime;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaRuntime;
+import javax.tools.diagnostics.runtime.java.JavaVMInitArgs;
+
+import org.apache.kato.jvmti.javaruntime.model.Model;
+import org.apache.kato.jvmti.reader.CLogger;
+
+public class JavaRuntimeImpl implements JavaRuntime {
+
+
+ private Model base=null;
+
+ public JavaRuntimeImpl(Model m) throws IOException {
+ this.base=m;
+ }
+
+ @Override
+ public List getCompiledMethods() {
+ return new LinkedList();
+ }
+
+ @Override
+ public List getHeapRoots() {
+ return new LinkedList();
+ }
+
+ @Override
+ public List getHeaps() {
+ return new LinkedList();
+ }
+
+ @Override
+ public List getJavaClassLoaders() {
+
+ return base.getJavaClassLoader();
+ }
+
+ @Override
+ public ImagePointer getJavaVM() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public JavaVMInitArgs getJavaVMInitArgs() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public List getMonitors() {
+
+ return base.getJavaMonitors();
+ }
+
+ @Override
+ public JavaObject getObjectAtAddress(ImagePointer arg0)
+ throws CorruptDataException, IllegalArgumentException,
+ MemoryAccessException, DataUnavailable {
+ CLogger.logr.log(Level.FINEST,"Ask for object at"+arg0.getAddress());
+ return base.getObjectAtAddress(arg0.getAddress());
+ }
+
+ @Override
+ public List getThreads() {
+
+ return base.getThreads();
+ }
+
+ @Override
+ public Object getTraceBuffer(String arg0, boolean arg1)
+ throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getFullVersion() throws CorruptDataException {
+
+ return "CJVMTI v0.1";
+ }
+
+ @Override
+ public String getVersion() throws CorruptDataException {
+ return "0.1.0";
+ }
+
+}
Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JField.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JField.java?rev=816693&r1=816692&r2=816693&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JField.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JField.java Fri Sep 18 16:10:34 2009
@@ -1,236 +1,240 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-import java.util.logging.Level;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.MemoryAccessException;
-import javax.tools.diagnostics.runtime.java.JavaClass;
-import javax.tools.diagnostics.runtime.java.JavaField;
-import javax.tools.diagnostics.runtime.java.JavaObject;
-
-import org.apache.kato.jvmti.reader.CLogger;
-
-public class JField implements JavaField, JValueHolder {
-
- private JClass clazzid = null;
- private long id = 0;
-
- public String genericsignature;
- public String signature;
- public String name;
- public boolean staticField = false;
- public Object staticValue = null;
- public int index = 0;
- public int modifiers = 0;
-
- public JField(JClass classid, long fid) {
- this.clazzid = classid;
- id = fid;
-
- }
-
- public long getFieldID() {
- return id;
- }
-
- @Override
- public Object get(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return staticValue;
- }
-
- CLogger.logr.log(Level.FINEST," " + this.name + " " + this.index + " "
- + this.signature);
- JObject job = (JObject) arg0;
-
- return job.getValue(id);
-
- }
-
- @Override
- public boolean getBoolean(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Boolean) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getBooleanValue(id);
- }
-
- @Override
- public byte getByte(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Byte) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getByteValue(id);
- }
-
- @Override
- public char getChar(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Character) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getCharValue(id);
- }
-
- @Override
- public double getDouble(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Double) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getDoubleValue(id);
- }
-
- @Override
- public float getFloat(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Float) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getFloatValue(id);
- }
-
- @Override
- public int getInt(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Integer) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getIntValue(id);
- }
-
- @Override
- public long getLong(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Long) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getLongValue(id);
- }
-
- @Override
- public short getShort(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- if (staticValue != null) {
- return (Short) staticValue;
- }
- JObject job = (JObject) arg0;
- return job.getShortValue(id);
- }
-
- @Override
- public String getString(JavaObject arg0) throws CorruptDataException,
- MemoryAccessException {
- // Incorrect
- if (staticValue != null) {
- JObject stringObj = (JObject) staticValue;
- JavaClass stringClass = stringObj.getJavaClass();
- while (!stringClass.getName().equals("java/lang/String")) {
- if ((stringClass = stringClass.getSuperclass()) == null) {
- break;
- }
- }
-
- if (stringClass != null) {
- for (JavaField field : stringObj.getJavaClass()
- .getDeclaredFields()) {
- if (field.getSignature().equals("[C")) {
- Character[] stringField = (Character[])((JObject)field.get(stringObj)).objArray;
- char[] charArray = new char[stringField.length];
- for (int i = 0; i < stringField.length; i++){
- charArray[i] = stringField[i];
- }
- CLogger.logr.log(Level.FINEST,"From static field from "+field.getName()+" "+(new String(charArray)));
- return new String(charArray);
- }
- }
- }
- }
-
-
-
-
- if (arg0 != null) {
- JObject obj = (JObject)arg0;
- JavaObject stringObj = (JavaObject)obj.getValue(id);
- JavaClass stringClass = stringObj.getJavaClass();
- while (!stringClass.getName().equals("java/lang/String")) {
- if ((stringClass = stringClass.getSuperclass()) == null) {
- break;
- }
- }
-
- if (stringClass != null) {
- for (JavaField field : stringObj.getJavaClass()
- .getDeclaredFields()) {
- if (field.getSignature().equals("[C")) {
- Character[] stringField = (Character[])((JObject)field.get(stringObj)).objArray;
- char[] charArray = new char[stringField.length];
- for (int i = 0; i < stringField.length; i++){
- charArray[i] = stringField[i];
- }
- CLogger.logr.log(Level.FINEST,"From field "+field.getName()+" "+ (new String(charArray)));
- return new String(charArray);
- }
- }
- }
- }
- return "testTest";
- }
-
- @Override
- public JavaClass getDeclaringClass() throws CorruptDataException,
- DataUnavailable {
-
- return clazzid;
- }
-
- @Override
- public int getModifiers() throws CorruptDataException {
- // TODO Auto-generated method stub
- return modifiers;
- }
-
- @Override
- public String getName() throws CorruptDataException {
-
- return name;
- }
-
- @Override
- public String getSignature() throws CorruptDataException {
-
- return signature;
- }
-
- @Override
- public void setValue(Object o) {
- staticValue = o;
- }
-
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import java.util.logging.Level;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+import org.apache.kato.jvmti.reader.CLogger;
+
+public class JField implements JavaField, JValueHolder {
+
+ private JClass clazzid = null;
+ private long id = 0;
+
+ public String genericsignature;
+ public String signature;
+ public String name;
+ public boolean staticField = false;
+ public Object staticValue = null;
+ public int index = 0;
+ public int modifiers = 0;
+
+ public JField(JClass classid, long fid) {
+ this.clazzid = classid;
+ id = fid;
+
+ }
+
+ public long getFieldID() {
+ return id;
+ }
+
+ @Override
+ public Object get(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return staticValue;
+ }
+
+ CLogger.logr.log(Level.FINEST," " + this.name + " " + this.index + " "
+ + this.signature);
+ JObject job = (JObject) arg0;
+
+ return job.getValue(id);
+
+ }
+
+ @Override
+ public boolean getBoolean(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Boolean) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getBooleanValue(id);
+ }
+
+ @Override
+ public byte getByte(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Byte) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getByteValue(id);
+ }
+
+ @Override
+ public char getChar(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Character) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getCharValue(id);
+ }
+
+ @Override
+ public double getDouble(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Double) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getDoubleValue(id);
+ }
+
+ @Override
+ public float getFloat(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Float) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getFloatValue(id);
+ }
+
+ @Override
+ public int getInt(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Integer) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getIntValue(id);
+ }
+
+ @Override
+ public long getLong(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Long) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getLongValue(id);
+ }
+
+ @Override
+ public short getShort(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ if (staticValue != null) {
+ return (Short) staticValue;
+ }
+ JObject job = (JObject) arg0;
+ return job.getShortValue(id);
+ }
+
+ @Override
+ public String getString(JavaObject arg0) throws CorruptDataException,
+ MemoryAccessException {
+ // Manually look for the string class
+
+ // First check static value
+ if (staticValue != null) {
+ JObject stringObj = (JObject) staticValue;
+ JavaClass stringClass = stringObj.getJavaClass();
+ while (!stringClass.getName().equals("java/lang/String")) {
+ if ((stringClass = stringClass.getSuperclass()) == null) {
+ break;
+ }
+ }
+
+ if (stringClass != null) {
+ for (JavaField field : stringObj.getJavaClass()
+ .getDeclaredFields()) {
+ // Assume this is the correct field
+ if (field.getSignature().equals("[C")) {
+ Character[] stringField = (Character[])((JObject)field.get(stringObj)).objArray;
+ char[] charArray = new char[stringField.length];
+ for (int i = 0; i < stringField.length; i++){
+ charArray[i] = stringField[i];
+ }
+ CLogger.logr.log(Level.FINEST,"From static field from "+field.getName()+" "+(new String(charArray)));
+ return new String(charArray);
+ }
+ }
+ }
+ }
+
+
+
+
+ if (arg0 != null) {
+ JObject obj = (JObject)arg0;
+ JavaObject stringObj = (JavaObject)obj.getValue(id);
+ JavaClass stringClass = stringObj.getJavaClass();
+ while (!stringClass.getName().equals("java/lang/String")) {
+ if ((stringClass = stringClass.getSuperclass()) == null) {
+ break;
+ }
+ }
+
+ if (stringClass != null) {
+ for (JavaField field : stringObj.getJavaClass()
+ .getDeclaredFields()) {
+ // Assume this is the correct field
+ if (field.getSignature().equals("[C")) {
+ Character[] stringField = (Character[])((JObject)field.get(stringObj)).objArray;
+ char[] charArray = new char[stringField.length];
+ for (int i = 0; i < stringField.length; i++){
+ charArray[i] = stringField[i];
+ }
+ CLogger.logr.log(Level.FINEST,"From field "+field.getName()+" "+ (new String(charArray)));
+ return new String(charArray);
+ }
+ }
+ }
+ }
+ return "testTest";
+ }
+
+ @Override
+ public JavaClass getDeclaringClass() throws CorruptDataException,
+ DataUnavailable {
+
+ return clazzid;
+ }
+
+ @Override
+ public int getModifiers() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return modifiers;
+ }
+
+ @Override
+ public String getName() throws CorruptDataException {
+
+ return name;
+ }
+
+ @Override
+ public String getSignature() throws CorruptDataException {
+
+ return signature;
+ }
+
+ @Override
+ public void setValue(Object o) {
+ staticValue = o;
+ }
+
}
\ No newline at end of file
Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java?rev=816693&r1=816692&r2=816693&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JLocalVariable.java Fri Sep 18 16:10:34 2009
@@ -1,80 +1,79 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.runtime.java.JavaVariable;
-
-public class JLocalVariable implements JValueHolder,JavaVariable{
-
- public Object value=null;
- public int slot=0;
- private JLocation location;
-
-
- public JLocalVariable() {
-
- }
- @Override
- public void setValue(Object o) {
- value=o;
-
- }
-
- @Override
- public int getLength() {
- JLocalVariableTableEntry entry=location.method.getEntry(slot);
- if(entry==null) return 0;
- return entry.length;
- }
-
- @Override
- public String getName() throws DataUnavailable {
-
- JLocalVariableTableEntry entry=location.method.getEntry(slot);
- if(entry==null) return null;
- return entry.getName();
- }
-
- @Override
- public String getSignature() {
- JLocalVariableTableEntry entry=location.method.getEntry(slot);
- if(entry==null) return null;
- return entry.sig;
- }
-
- @Override
- public int getSlot() {
-
- return slot;
- }
-
- @Override
- public int getStart() {
- JLocalVariableTableEntry entry=location.method.getEntry(slot);
- if(entry==null) return 0;
- return entry.start;
- }
-
- @Override
- public Object getValue() {
- return value;
- }
- public void setLocation(JLocation loc) {
- this.location=loc;
-
- }
-
-}
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.runtime.java.JavaVariable;
+
+public class JLocalVariable implements JValueHolder,JavaVariable{
+
+ public Object value=null;
+ public int slot=0;
+ private JLocation location;
+
+
+ public JLocalVariable() {
+
+ }
+ @Override
+ public void setValue(Object o) {
+ value=o;
+ }
+
+ @Override
+ public int getLength() {
+ JLocalVariableTableEntry entry=location.method.getEntry(slot, location);
+ if(entry==null) return 0;
+ return entry.length;
+ }
+
+ @Override
+ public String getName() throws DataUnavailable {
+
+ JLocalVariableTableEntry entry=location.method.getEntry(slot, location);
+ if(entry==null) return null;
+ return entry.getName();
+ }
+
+ @Override
+ public String getSignature() {
+ JLocalVariableTableEntry entry=location.method.getEntry(slot, location);
+ if(entry==null) return null;
+ return entry.sig;
+ }
+
+ @Override
+ public int getSlot() {
+
+ return slot;
+ }
+
+ @Override
+ public int getStart() {
+ JLocalVariableTableEntry entry=location.method.getEntry(slot, location);
+ if(entry==null) return 0;
+ return entry.start;
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+ public void setLocation(JLocation loc) {
+ this.location=loc;
+
+ }
+
+}
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=816693&r1=816692&r2=816693&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 Fri Sep 18 16:10:34 2009
@@ -1,136 +1,149 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Vector;
-import java.util.logging.Level;
-
-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.JavaMethod;
-
-import org.apache.kato.jvmti.reader.CLogger;
-
-public class JMethod implements JavaMethod {
-
-
- public String genericsignature;
- public int nativemethod;
- public int argumentsize;
- public int maxlocals;
- public String name=null;
- public String signature=null;
- public int mods=0;
- public JClass parent=null;
- public HashMap<Long, Integer> lineNumberTable;
- private ObjectMapList<Integer,JLocalVariableTableEntry> localVars=null;
- public JMethod() {
- }
-
- public void setParent(JClass class1) {
- parent=class1;
- }
-
- public void addLocalVariableTableEntry(JLocalVariableTableEntry entry) {
- if(localVars==null) {
- localVars=new ObjectMapList<Integer, JLocalVariableTableEntry>();
- }
-
- localVars.put(entry.slot,entry);
- }
-
- public void addLineNumberEntry(int lNum, long bytePos){
- if (lineNumberTable == null){
- lineNumberTable = new HashMap<Long, Integer>();
- }
- lineNumberTable.put(bytePos, lNum);
- }
-
- public int getLineNumber(long bytePos){
- if(lineNumberTable == null){
- return 0;
- }
- Vector<Long> v = new Vector<Long>(lineNumberTable.keySet());
- Collections.sort(v);
- Iterator<Long> it = v.iterator();
- while(it.hasNext()){
- long val = it.next();
- CLogger.logr.log(Level.FINEST,"Value "+bytePos+" index "+val);
- if(val>=bytePos){
- return lineNumberTable.get(val);
- }
- }
- return 0;
- }
-
-
- @Override
- public List getBytecodeSections() {
-
- return new LinkedList();
- }
-
- @Override
- public List getCompiledSections() {
- return new LinkedList();
- }
-
- @Override
- public JavaClass getDeclaringClass() throws CorruptDataException,
- DataUnavailable {
-
- return parent;
- }
-
- @Override
- public int getModifiers() throws CorruptDataException {
-
- return mods;
- }
-
- @Override
- public String getName() throws CorruptDataException {
- return name;
- }
-
- @Override
- public String getSignature() throws CorruptDataException {
- return signature;
- }
-
- @Override
- public List getVariables() {
- if(localVars==null) {
- localVars=new ObjectMapList<Integer, JLocalVariableTableEntry>();
- }
-
- return localVars.values();
- }
-
- public JLocalVariableTableEntry getEntry(int slot) {
- if(localVars==null) {
- localVars=new ObjectMapList<Integer, JLocalVariableTableEntry>();
- }
- return localVars.get(slot);
-
- }
-
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Vector;
+import java.util.logging.Level;
+
+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.JavaMethod;
+
+import org.apache.kato.jvmti.reader.CLogger;
+
+public class JMethod implements JavaMethod {
+
+
+ public String genericsignature;
+ public int nativemethod;
+ public int argumentsize;
+ public int maxlocals;
+ public String name=null;
+ public String signature=null;
+ public int mods=0;
+ public JClass parent=null;
+ public HashMap<Long, Integer> lineNumberTable;
+ private LinkedList<JLocalVariableTableEntry> localVars=null;
+ public JMethod() {
+ }
+
+ public void setParent(JClass class1) {
+ parent=class1;
+ }
+
+ public void addLocalVariableTableEntry(JLocalVariableTableEntry entry) {
+ if(localVars==null) {
+ localVars=new LinkedList<JLocalVariableTableEntry>();
+ }
+ localVars.add(entry);
+ }
+
+ public void addLineNumberEntry(int lNum, long bytePos){
+ if (lineNumberTable == null){
+ lineNumberTable = new HashMap<Long, Integer>();
+ }
+ lineNumberTable.put(bytePos, lNum);
+ }
+
+ public int getLineNumber(long bytePos){
+ if(lineNumberTable == null){
+ return 0;
+ }
+ Vector<Long> v = new Vector<Long>(lineNumberTable.keySet());
+ Collections.sort(v);
+ Iterator<Long> it = v.iterator();
+ while(it.hasNext()){
+ long val = it.next();
+ CLogger.logr.log(Level.FINEST,"Value "+bytePos+" index "+val);
+ if(val>=bytePos){
+ return lineNumberTable.get(val);
+ }
+ }
+ return 0;
+ }
+
+
+ @Override
+ public List getBytecodeSections() {
+
+ return new LinkedList();
+ }
+
+ @Override
+ public List getCompiledSections() {
+ return new LinkedList();
+ }
+
+ @Override
+ public JavaClass getDeclaringClass() throws CorruptDataException,
+ DataUnavailable {
+
+ return parent;
+ }
+
+ @Override
+ public int getModifiers() throws CorruptDataException {
+
+ return mods;
+ }
+
+ @Override
+ public String getName() throws CorruptDataException {
+ return name;
+ }
+
+ @Override
+ public String getSignature() throws CorruptDataException {
+ return signature;
+ }
+
+ @Override
+ public List getVariables() {
+ if(localVars==null) {
+ localVars=new LinkedList<JLocalVariableTableEntry>();
+ }
+
+ return localVars;
+ }
+
+ public JLocalVariableTableEntry getEntry(int slot, JLocation loc) {
+ if(localVars==null) {
+ localVars=new LinkedList<JLocalVariableTableEntry>();
+ }
+ for (JLocalVariableTableEntry jlvte: localVars){
+ if (jlvte.getSlot() == slot){
+ try {
+ if (jlvte.start+jlvte.length >= loc.getAddress().getAddress() && jlvte.start <= loc.getAddress().getAddress()){
+ return jlvte;
+ }
+ } catch (CorruptDataException e) {
+ }
+ }
+ }
+ for (JLocalVariableTableEntry jlvte: localVars){
+ if (jlvte.getSlot() == slot){
+ return jlvte;
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file
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=816693&r1=816692&r2=816693&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 Fri Sep 18 16:10:34 2009
@@ -1,337 +1,337 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.apache.kato.jvmti.reader.CJVMTIBinReader;
-import org.apache.kato.jvmti.reader.CLogger;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.image.MemoryAccessException;
-import javax.tools.diagnostics.runtime.java.JavaClass;
-import javax.tools.diagnostics.runtime.java.JavaHeap;
-import javax.tools.diagnostics.runtime.java.JavaObject;
-
-public class JObject implements JavaObject {
-
- private long objid = 0;
- private long size = 0;
- private Map<Long, Object> data = new HashMap<Long, Object>();
- private JClass clazz = null;
- public boolean visited = false;
- public boolean isArray = false;
- public Object[] objArray;
- public int objectSize = 0;
- private JObject superClazzObject = null;
-
- public JObject(JClass clazz, long objID) {
- this.clazz = clazz;
- this.objid = objID;
- if (clazz != null) {
- try {
- this.isArray = clazz.isArray();
- } catch (CorruptDataException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public void addValue(long fieldid, Object data) {
- this.data.put(fieldid, data);
- }
-
- public double getDoubleValue(long id) {
- Double d = (Double) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getDoubleValue(id);
- }
- return d;
- }
-
- public long getLongValue(long id) {
- Long d = (Long) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getLongValue(id);
- }
- return d;
- }
-
- public char getCharValue(long id) {
- Character d = (Character) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getCharValue(id);
- }
- return d;
-
- }
-
- public boolean getBooleanValue(long id) {
- Boolean d = (Boolean) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getBooleanValue(id);
- }
- return d;
- }
-
- public byte getByteValue(long id) {
- Byte d = (Byte) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getByteValue(id);
- }
- return d;
- }
-
- public float getFloatValue(long id) {
- Float d = (Float) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getFloatValue(id);
- }
- return d;
- }
-
- public int getIntValue(long id) {
- Integer d = (Integer) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getIntValue(id);
- }
- return d;
- }
-
- public short getShortValue(long id) {
- Short d = (Short) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getShortValue(id);
- }
- return d;
- }
-
- public String getStringValue(long id) {
- String d = (String) data.get(id);
- if (d == null && superClazzObject != null) {
- return superClazzObject.getStringValue(id);
- }
- return d;
- }
-
- public Object getValue(long id) {
- if (data.containsKey(id)) {
- return data.get(id);
- } else {
- if (superClazzObject != null) {
- return superClazzObject.getValue(id);
- } else {
- System.out
- .println("Missing field entry, this should not happen");
- return null;
- }
- }
- }
-
- @Override
- public void arraycopy(int srcStart, Object dst, int dstStart, int length)
- throws CorruptDataException, MemoryAccessException {
- // // TODO Implement array copy
- // JClass intArray;// "[int"
- // //
- // JClass floatArray; // "[float"
- // //
- // JClass shortArray; // "[short"
- // //
- // JClass longArray; // "[long"
- // //
- // JClass byteArray; // "[byte"
- // //
- // JClass booleanArray; // "[boolean"
- // //
- // JClass doubleArray; // "[double"
- // //
- // JClass charArray; // "[char"
-
- if (clazz.classSig.equals("[I")) {
- CLogger.logr.log(Level.FINEST,"Array copy for int");
- Integer[] ia = (Integer[]) objArray;
- int index = 0;
- int[] outArray = (int[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = ia[i];
- index++;
- }
- } else if (clazz.classSig.equals("[F")) {
- CLogger.logr.log(Level.FINEST,"Array copy for float");
- Float[] fa = (Float[]) objArray;
- int index = 0;
- float[] outArray = (float[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = fa[i];
- index++;
- }
- } else if (clazz.classSig.equals("[S")) {
- CLogger.logr.log(Level.FINEST,"Array copy for short");
- Short[] sa = (Short[]) objArray;
- int index = 0;
- short[] outArray = (short[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = sa[i];
- index++;
- }
- } else if (clazz.classSig.equals("[J")) {
- CLogger.logr.log(Level.FINEST,"Array copy for long");
- Long[] ja = (Long[]) objArray;
- int index = 0;
- long[] outArray = (long[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = ja[i];
- index++;
- }
- } else if (clazz.classSig.equals("[B")) {
- CLogger.logr.log(Level.FINEST,"Array copy for byte");
- Byte[] ba = (Byte[]) objArray;
- int index = 0;
- byte[] outArray = (byte[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = ba[i];
- index++;
- }
- } else if (clazz.classSig.equals("[Z")) {
- CLogger.logr.log(Level.FINEST,"Array copy for boolean");
- Boolean[] za = (Boolean[]) objArray;
- int index = 0;
- byte[] outArray = (byte[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- if (za[i]) {
- outArray[index] = 1;
- } else {
- outArray[index] = 0;
- }
- index++;
- }
- } else if (clazz.classSig.equals("[D")) {
- CLogger.logr.log(Level.FINEST,"Array copy for double");
- Double[] da = (Double[]) objArray;
- int index = 0;
- double[] outArray = (double[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = da[i];
- index++;
- }
- } else if (clazz.classSig.equals("[C")) {
- CLogger.logr.log(Level.FINEST,"Array copy for char");
- Character[] ca = (Character[]) objArray;
- int index = 0;
- char[] outArray = (char[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = ca[i];
- index++;
- }
- } else {
- CLogger.logr.log(Level.FINEST,"...Object array");
- JObject[] ca = (JObject[]) objArray;
- int index = 0;
- JavaObject[] outArray = (JavaObject[]) dst;
- for (int i = srcStart; i < srcStart + length; i++) {
- outArray[index] = ca[i];
- index++;
- }
- }
- }
-
- @Override
- public int getArraySize() throws CorruptDataException {
- return objArray.length;
- }
-
- @Override
- public long getHashcode() throws DataUnavailable, CorruptDataException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public JavaHeap getHeap() throws CorruptDataException, DataUnavailable {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ImagePointer getID() {
- return new SimpleImagePointer(objid);
- }
-
- @Override
- public JavaClass getJavaClass() throws CorruptDataException {
-
- CLogger.logr.log(Level.FINEST,"asking for class " + clazz);
- return clazz;
- }
-
- @Override
- public long getPersistentHashcode() throws DataUnavailable,
- CorruptDataException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public List getReferences() {
- return new LinkedList();
- }
-
- @Override
- public List getSections() {
-
- return new LinkedList();
- }
-
- @Override
- public long getSize() throws CorruptDataException {
-
- return size;
- }
-
- @Override
- public boolean isArray() throws CorruptDataException {
-
- return isArray;
- }
-
- public String toString() {
- if (clazz == null) {
- return "<unknown>@" + objid;
- }
- try {
- return clazz.getName() + "@" + objid;
- } catch (CorruptDataException e) {
-
- return super.toString();
- }
- }
-
- public void setSuperClazzObj(JObject supClazz) {
- this.superClazzObject = supClazz;
- }
-
- public int getNumFields(){
- return data.size();
- }
-
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.apache.kato.jvmti.reader.CJVMTIBinReader;
+import org.apache.kato.jvmti.reader.CLogger;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+public class JObject implements JavaObject {
+
+ private long objid = 0;
+ private long size = 0;
+ private Map<Long, Object> data = new HashMap<Long, Object>();
+ private JClass clazz = null;
+ public boolean visited = false;
+ public boolean isArray = false;
+ public Object[] objArray;
+ public int objectSize = 0;
+ private JObject superClazzObject = null;
+
+ public JObject(JClass clazz, long objID) {
+ this.clazz = clazz;
+ this.objid = objID;
+ if (clazz != null) {
+ try {
+ this.isArray = clazz.isArray();
+ } catch (CorruptDataException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void addValue(long fieldid, Object data) {
+ this.data.put(fieldid, data);
+ }
+
+ public double getDoubleValue(long id) {
+ Double d = (Double) data.get(id); // First try from this object
+ if (d == null && superClazzObject != null) { // Then follow through the hierarchy
+ return superClazzObject.getDoubleValue(id);
+ }
+ return d;
+ }
+
+ public long getLongValue(long id) {
+ Long d = (Long) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getLongValue(id);
+ }
+ return d;
+ }
+
+ public char getCharValue(long id) {
+ Character d = (Character) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getCharValue(id);
+ }
+ return d;
+
+ }
+
+ public boolean getBooleanValue(long id) {
+ Boolean d = (Boolean) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getBooleanValue(id);
+ }
+ return d;
+ }
+
+ public byte getByteValue(long id) {
+ Byte d = (Byte) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getByteValue(id);
+ }
+ return d;
+ }
+
+ public float getFloatValue(long id) {
+ Float d = (Float) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getFloatValue(id);
+ }
+ return d;
+ }
+
+ public int getIntValue(long id) {
+ Integer d = (Integer) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getIntValue(id);
+ }
+ return d;
+ }
+
+ public short getShortValue(long id) {
+ Short d = (Short) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getShortValue(id);
+ }
+ return d;
+ }
+
+ public String getStringValue(long id) {
+ String d = (String) data.get(id);
+ if (d == null && superClazzObject != null) {
+ return superClazzObject.getStringValue(id);
+ }
+ return d;
+ }
+
+ public Object getValue(long id) {
+ if (data.containsKey(id)) {
+ return data.get(id);
+ } else {
+ if (superClazzObject != null) {
+ return superClazzObject.getValue(id);
+ } else {
+ System.out
+ .println("Missing field entry, this should not happen");
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public void arraycopy(int srcStart, Object dst, int dstStart, int length)
+ throws CorruptDataException, MemoryAccessException {
+ // // TODO Implement array copy
+ // JClass intArray;// "[int"
+ // //
+ // JClass floatArray; // "[float"
+ // //
+ // JClass shortArray; // "[short"
+ // //
+ // JClass longArray; // "[long"
+ // //
+ // JClass byteArray; // "[byte"
+ // //
+ // JClass booleanArray; // "[boolean"
+ // //
+ // JClass doubleArray; // "[double"
+ // //
+ // JClass charArray; // "[char"
+
+ if (clazz.classSig.equals("[I")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for int");
+ Integer[] ia = (Integer[]) objArray;
+ int index = 0;
+ int[] outArray = (int[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = ia[i];
+ index++;
+ }
+ } else if (clazz.classSig.equals("[F")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for float");
+ Float[] fa = (Float[]) objArray;
+ int index = 0;
+ float[] outArray = (float[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = fa[i];
+ index++;
+ }
+ } else if (clazz.classSig.equals("[S")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for short");
+ Short[] sa = (Short[]) objArray;
+ int index = 0;
+ short[] outArray = (short[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = sa[i];
+ index++;
+ }
+ } else if (clazz.classSig.equals("[J")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for long");
+ Long[] ja = (Long[]) objArray;
+ int index = 0;
+ long[] outArray = (long[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = ja[i];
+ index++;
+ }
+ } else if (clazz.classSig.equals("[B")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for byte");
+ Byte[] ba = (Byte[]) objArray;
+ int index = 0;
+ byte[] outArray = (byte[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = ba[i];
+ index++;
+ }
+ } else if (clazz.classSig.equals("[Z")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for boolean");
+ Boolean[] za = (Boolean[]) objArray;
+ int index = 0;
+ byte[] outArray = (byte[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ if (za[i]) {
+ outArray[index] = 1;
+ } else {
+ outArray[index] = 0;
+ }
+ index++;
+ }
+ } else if (clazz.classSig.equals("[D")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for double");
+ Double[] da = (Double[]) objArray;
+ int index = 0;
+ double[] outArray = (double[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = da[i];
+ index++;
+ }
+ } else if (clazz.classSig.equals("[C")) {
+ CLogger.logr.log(Level.FINEST,"Array copy for char");
+ Character[] ca = (Character[]) objArray;
+ int index = 0;
+ char[] outArray = (char[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = ca[i];
+ index++;
+ }
+ } else {
+ CLogger.logr.log(Level.FINEST,"...Object array");
+ JObject[] ca = (JObject[]) objArray;
+ int index = 0;
+ JavaObject[] outArray = (JavaObject[]) dst;
+ for (int i = srcStart; i < srcStart + length; i++) {
+ outArray[index] = ca[i];
+ index++;
+ }
+ }
+ }
+
+ @Override
+ public int getArraySize() throws CorruptDataException {
+ return objArray.length;
+ }
+
+ @Override
+ public long getHashcode() throws DataUnavailable, CorruptDataException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public JavaHeap getHeap() throws CorruptDataException, DataUnavailable {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ImagePointer getID() {
+ return new SimpleImagePointer(objid);
+ }
+
+ @Override
+ public JavaClass getJavaClass() throws CorruptDataException {
+
+ CLogger.logr.log(Level.FINEST,"asking for class " + clazz);
+ return clazz;
+ }
+
+ @Override
+ public long getPersistentHashcode() throws DataUnavailable,
+ CorruptDataException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public List getReferences() {
+ return new LinkedList();
+ }
+
+ @Override
+ public List getSections() {
+
+ return new LinkedList();
+ }
+
+ @Override
+ public long getSize() throws CorruptDataException {
+
+ return size;
+ }
+
+ @Override
+ public boolean isArray() throws CorruptDataException {
+
+ return isArray;
+ }
+
+ public String toString() {
+ if (clazz == null) {
+ return "<unknown>@" + objid;
+ }
+ try {
+ return clazz.getName() + "@" + objid;
+ } catch (CorruptDataException e) {
+
+ return super.toString();
+ }
+ }
+
+ public void setSuperClazzObj(JObject supClazz) {
+ this.superClazzObject = supClazz;
+ }
+
+ public int getNumFields(){
+ return data.size();
+ }
+
}
\ No newline at end of file
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=816693&r1=816692&r2=816693&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 Fri Sep 18 16:10:34 2009
@@ -1,88 +1,97 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.runtime.java.JavaLocation;
-import javax.tools.diagnostics.runtime.java.JavaStackFrame;
-import javax.tools.diagnostics.runtime.java.JavaVariable;
-
-import org.apache.kato.jvmti.reader.CLogger;
-
-public class JStackFrame implements JavaStackFrame {
- private static int stackFrameIDCount = 1;
- private JLocation location=null;
- private int stackFrameID;
- private ObjectMapList<Integer,JavaVariable> vars=new ObjectMapList<Integer, JavaVariable>();
-
-
- public JStackFrame(){
- stackFrameID = stackFrameIDCount;
- stackFrameIDCount++;
- }
- @Override
- public ImagePointer getBasePointer() throws CorruptDataException {
-
- return new SimpleImagePointer(stackFrameID);
- }
-
- public void setLocation(JLocation loc) {
- this.location=loc;
- }
- @Override
- public List getHeapRoots() {
- return new LinkedList();
- }
-
- @Override
- public JavaLocation getLocation() throws CorruptDataException {
-
- return location;
- }
-
- @Override
- public Object getVariable(int slot) throws CorruptDataException,
- DataUnavailable, IndexOutOfBoundsException {
- Object r=vars.get(slot).getValue();
- CLogger.logr.log(Level.FINEST,"asked for variable at slot "+slot+" ("+r+")");
- return r;
-
- }
-
- public void addVariable(JLocalVariable value) {
- value.setLocation(location);
- vars.put(value.slot, value);
- }
-
- @Override
- public List<JavaVariable> getVariables() {
-
- return vars.values();
- }
-
- public void addVariable(int slot, Object data) {
- JLocalVariable var=new JLocalVariable();
- var.slot=slot;
- var.value=data;
- addVariable(var);
-
- }
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.runtime.java.JavaLocation;
+import javax.tools.diagnostics.runtime.java.JavaStackFrame;
+import javax.tools.diagnostics.runtime.java.JavaVariable;
+
+import org.apache.kato.jvmti.reader.CLogger;
+
+public class JStackFrame implements JavaStackFrame {
+ private static int stackFrameIDCount = 1;
+ private JLocation location=null;
+ private int stackFrameID;
+ private ObjectMapList<Integer,JavaVariable> vars=new ObjectMapList<Integer, JavaVariable>();
+
+
+ public JStackFrame(){
+ stackFrameID = stackFrameIDCount;
+ stackFrameIDCount++;
+ }
+ @Override
+ public ImagePointer getBasePointer() throws CorruptDataException {
+
+ return new SimpleImagePointer(stackFrameID);
+ }
+
+ public void setLocation(JLocation loc) {
+ this.location=loc;
+ }
+ @Override
+ public List getHeapRoots() {
+ return new LinkedList();
+ }
+
+ @Override
+ public JavaLocation getLocation() throws CorruptDataException {
+
+ return location;
+ }
+
+ @Override
+ public Object getVariable(int slot) throws CorruptDataException,
+ DataUnavailable, IndexOutOfBoundsException {
+ if (vars == null){
+ CLogger.logr.log(Level.FINEST,"Null variables "+slot);
+ return null;
+ }// TODO Correct this, behaviour is inconsistent
+ JavaVariable jv =vars.get(slot);
+ if (jv == null) {
+ CLogger.logr.log(Level.FINEST,"Null variables in "+slot);
+ return null;
+ }
+ Object r = jv.getValue();
+ CLogger.logr.log(Level.FINEST,"asked for variable at slot "+slot+" ("+r+")");
+ return r;
+
+ }
+
+ public void addVariable(JLocalVariable value) {
+ value.setLocation(location);
+ vars.put(value.slot, value);
+ }
+
+ @Override
+ public List<JavaVariable> getVariables() {
+
+ return vars.values();
+ }
+
+ public void addVariable(int slot, Object data) {
+ JLocalVariable var=new JLocalVariable();
+ var.slot=slot;
+ var.value=data;
+ addVariable(var);
+
+ }
}
\ No newline at end of file
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=816693&r1=816692&r2=816693&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 Fri Sep 18 16:10:34 2009
@@ -1,166 +1,170 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-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.ImagePointer;
-import javax.tools.diagnostics.image.ImageThread;
-import javax.tools.diagnostics.image.MemoryAccessException;
-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.JavaStackFrame;
-import javax.tools.diagnostics.runtime.java.JavaThread;
-
-public class JThread implements JavaThread{
- public JMonitor contendedMonitor=null;
- public long id=0;
- public short priority=0;
- public short daemon=0;
- public int groupID=0;
- public String threadName=null;
-
-
- private List<JavaStackFrame> frames=new LinkedList<JavaStackFrame>();
-
-
- public JThread(long id) {
- this.id=id;
- }
-
- @Override
- public ImageThread getImageThread() throws CorruptDataException,
- DataUnavailable {
-
- throw new DataUnavailable();
- }
-
-
- public void addStackFrame(JStackFrame frame) {
- frames.add(frame);
-
-
- }
- @Override
- public ImagePointer getJNIEnv() throws CorruptDataException {
-
- return new SimpleImagePointer(id);
- }
- @Override
- public String getName() throws CorruptDataException {
-
- return threadName;
- }
- @Override
- public JavaObject getObject() throws CorruptDataException {
-
- return new JavaObject(){
-
- @Override
- public void arraycopy(int srcStart, Object dst, int dstStart,
- int length) throws CorruptDataException,
- MemoryAccessException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public int getArraySize() throws CorruptDataException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public long getHashcode() throws DataUnavailable,
- CorruptDataException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public JavaHeap getHeap() throws CorruptDataException,
- DataUnavailable {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ImagePointer getID() {
- return new SimpleImagePointer(id);
- }
-
- @Override
- public JavaClass getJavaClass() throws CorruptDataException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public long getPersistentHashcode() throws DataUnavailable,
- CorruptDataException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public List getReferences() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List getSections() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public long getSize() throws CorruptDataException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean isArray() throws CorruptDataException {
- // TODO Auto-generated method stub
- return false;
- }};
-
-
- }
- @Override
- public int getPriority() throws CorruptDataException {
-
- return priority;
- }
- @Override
- public List getStackFrames() {
- return frames;
- }
- @Override
- public List getStackSections() {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- public int getState() throws CorruptDataException {
-
- return 0;
- }
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+
+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.image.MemoryAccessException;
+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.JavaStackFrame;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+
+import org.apache.kato.jvmti.reader.CLogger;
+
+public class JThread implements JavaThread{
+ public JMonitor contendedMonitor=null;
+ public long id=0;
+ public short priority=0;
+ public short daemon=0;
+ public int groupID=0;
+ public String threadName=null;
+
+
+ private List<JavaStackFrame> frames=new LinkedList<JavaStackFrame>();
+
+
+ public JThread(long id) {
+ this.id=id;
+ }
+
+ @Override
+ public ImageThread getImageThread() throws CorruptDataException,
+ DataUnavailable {
+
+ throw new DataUnavailable();
+ }
+
+
+ public void addStackFrame(JStackFrame frame) {
+ frames.add(frame);
+
+
+ }
+ @Override
+ public ImagePointer getJNIEnv() throws CorruptDataException {
+
+ return new SimpleImagePointer(id);
+ }
+ @Override
+ public String getName() throws CorruptDataException {
+
+ return threadName;
+ }
+ @Override
+ public JavaObject getObject() throws CorruptDataException {
+
+ return new JavaObject(){
+
+ @Override
+ public void arraycopy(int srcStart, Object dst, int dstStart,
+ int length) throws CorruptDataException,
+ MemoryAccessException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getArraySize() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public long getHashcode() throws DataUnavailable,
+ CorruptDataException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public JavaHeap getHeap() throws CorruptDataException,
+ DataUnavailable {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ImagePointer getID() {
+ return new SimpleImagePointer(id);
+ }
+
+ @Override
+ public JavaClass getJavaClass() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getPersistentHashcode() throws DataUnavailable,
+ CorruptDataException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public List getReferences() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List getSections() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public long getSize() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isArray() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return false;
+ }};
+
+
+ }
+ @Override
+ public int getPriority() throws CorruptDataException {
+
+ return priority;
+ }
+ @Override
+ public List getStackFrames() {
+ CLogger.logr.log(Level.FINEST,"Asked for stack frames");
+ return frames;
+ }
+ @Override
+ public List getStackSections() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public int getState() throws CorruptDataException {
+
+ return 0;
+ }
}
\ No newline at end of file
Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/Model.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/Model.java?rev=816693&r1=816692&r2=816693&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/Model.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/Model.java Fri Sep 18 16:10:34 2009
@@ -1,121 +1,119 @@
-/*******************************************************************************
- * 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.javaruntime.model;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-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.JavaMonitor;
-import javax.tools.diagnostics.runtime.java.JavaObject;
-import javax.tools.diagnostics.runtime.java.JavaThread;
-
-public class Model {
-
- private ObjectMapList<Long,JavaThread> threadMap=new ObjectMapList<Long,JavaThread>();
- Map<Long,JavaClass> classMap=new HashMap<Long,JavaClass>();
- private ObjectMapList<Long,JavaClassLoader> loadersMap=new ObjectMapList<Long,JavaClassLoader>();
- private ObjectMapList<Long,JavaMonitor> monitorsMap=new ObjectMapList<Long,JavaMonitor>();
- private ObjectMapList<Long,JavaMethod> methodMap=new ObjectMapList<Long,JavaMethod>();
- private ObjectMapList<Long,JavaObject> objectMap=new ObjectMapList<Long,JavaObject>();
-
-
- public JClass getClass(long id) {
- if(id==0) return null;
- JClass m=(JClass) classMap.get(id);
- if(m==null) {
- m=new JClass(this);
- m.classid=id;
- classMap.put(id,m);
- }
- return m;
- }
-
-
-
- // TODO is this needed?
- public JavaObject getObjectAtAddress(long loc){
- return objectMap.get(loc);
- }
-
-
- public JMethod getMethod(long methodid) {
- if(methodid==0) return null;
- JMethod m=(JMethod) methodMap.get(methodid);
- if(m==null) {
- m=new JMethod();
-
- methodMap.put(methodid,m);
- }
- return m;
-
- }
- public JClassLoader getLoader(long classloaderid) {
-
- JClassLoader loader=(JClassLoader) loadersMap.get(classloaderid);
- if(loader==null) {
- loader=new JClassLoader();
- loadersMap.put(classloaderid, loader);
- }
- return loader;
- }
-
-
-public JObject getObject(long classid, long objectid) {
-
- JObject o=(JObject) objectMap.get(objectid);
- if(o==null) {
-
- JClass clazz = null;
-
- // TODO this is potentially wrong
- if (classid !=0 ){
- clazz=getClass(classid);}
- o=new JObject(clazz,objectid);
- objectMap.put(objectid,o);
- }
- return o;
- }
- public JMonitor getMonitor(long monitorid) {
- if(monitorid==0) return null;
- JMonitor m=(JMonitor) monitorsMap.get(monitorid);
- if(m==null) {
- m=new JMonitor(monitorid);
- monitorsMap.put(monitorid,m);
- }
- return m;
- }
- public List getThreads() {
- return threadMap.values();
- }
-public List getJavaClassLoader() {
-
- return loadersMap.values();
- }
- public List getJavaMonitors() {
- return monitorsMap.values();
- }
- public JThread getThread(long id) {
- JThread t=(JThread) threadMap.get(id);
- if(t!=null) return t;
- t=new JThread(id);
- threadMap.put(t.id, t);
- return t;
- }
-
-}
+/*******************************************************************************
+ * 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.javaruntime.model;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.JavaMonitor;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+
+public class Model {
+
+ private ObjectMapList<Long,JavaThread> threadMap=new ObjectMapList<Long,JavaThread>();
+ Map<Long,JavaClass> classMap=new HashMap<Long,JavaClass>();
+ private ObjectMapList<Long,JavaClassLoader> loadersMap=new ObjectMapList<Long,JavaClassLoader>();
+ private ObjectMapList<Long,JavaMonitor> monitorsMap=new ObjectMapList<Long,JavaMonitor>();
+ private ObjectMapList<Long,JavaMethod> methodMap=new ObjectMapList<Long,JavaMethod>();
+ private ObjectMapList<Long,JavaObject> objectMap=new ObjectMapList<Long,JavaObject>();
+
+
+ public JClass getClass(long id) {
+ if(id==0) return null;
+ JClass m=(JClass) classMap.get(id);
+ if(m==null) {
+ m=new JClass(this);
+ m.classid=id;
+ classMap.put(id,m);
+ }
+ return m;
+ }
+
+
+
+ public JavaObject getObjectAtAddress(long loc){
+ return objectMap.get(loc);
+ }
+
+
+ public JMethod getMethod(long methodid) {
+ if(methodid==0) return null;
+ JMethod m=(JMethod) methodMap.get(methodid);
+ if(m==null) {
+ m=new JMethod();
+
+ methodMap.put(methodid,m);
+ }
+ return m;
+
+ }
+ public JClassLoader getLoader(long classloaderid) {
+
+ JClassLoader loader=(JClassLoader) loadersMap.get(classloaderid);
+ if(loader==null) {
+ loader=new JClassLoader();
+ loadersMap.put(classloaderid, loader);
+ }
+ return loader;
+ }
+
+
+public JObject getObject(long classid, long objectid) {
+
+ JObject o=(JObject) objectMap.get(objectid);
+ if(o==null) {
+
+ JClass clazz = null;
+
+ // TODO this is potentially wrong
+ if (classid !=0 ){
+ clazz=getClass(classid);}
+ o=new JObject(clazz,objectid);
+ objectMap.put(objectid,o);
+ }
+ return o;
+ }
+ public JMonitor getMonitor(long monitorid) {
+ if(monitorid==0) return null;
+ JMonitor m=(JMonitor) monitorsMap.get(monitorid);
+ if(m==null) {
+ m=new JMonitor(monitorid);
+ monitorsMap.put(monitorid,m);
+ }
+ return m;
+ }
+ public List getThreads() {
+ return threadMap.values();
+ }
+public List getJavaClassLoader() {
+ return loadersMap.values();
+ }
+ public List getJavaMonitors() {
+ return monitorsMap.values();
+ }
+ public JThread getThread(long id) {
+ JThread t=(JThread) threadMap.get(id);
+ if(t!=null) return t;
+ t=new JThread(id);
+ threadMap.put(t.id, t);
+ return t;
+ }
+
+}