incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r889268 - in /incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti: javaruntime/model/JField.java javaruntime/model/JObject.java reader/CJVMTIBinReader.java
Date Thu, 10 Dec 2009 14:06:50 GMT
Author: spoole
Date: Thu Dec 10 14:06:48 2009
New Revision: 889268

URL: http://svn.apache.org/viewvc?rev=889268&view=rev
Log:
Formalised relationship between the JavaObject isArray and the objArray value.  Setting the
value is encapsulated behind a method now - rather than allowing caller to manipulate each
field separately

Modified:
    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/JObject.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/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=889268&r1=889267&r2=889268&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
Thu Dec 10 14:06:48 2009
@@ -219,7 +219,7 @@
 		}
 
 		
-		Character[] stringField = (Character[])((JObject)valueField.get(stringObj)).objArray;
+		Character[] stringField = (Character[])((JObject)valueField.get(stringObj)).getObjArray();
 		int offset = offsetField.getInt(stringObj);
 		int count = countField.getInt(stringObj);
 		char[] charArray = new char[count];

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=889268&r1=889267&r2=889268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JObject.java
Thu Dec 10 14:06:48 2009
@@ -19,6 +19,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CancellationException;
 import java.util.logging.Level;
 
 import javax.tools.diagnostics.image.CorruptDataException;
@@ -45,8 +46,17 @@
 	private JClass clazz = null;
 	private boolean visited = false;
 	
-	public boolean isArray = false;	
-	public Object[] objArray;
+	private boolean isArray = false;	
+	private Object[] objArray=null;
+	public Object[] getObjArray() {
+		return objArray;
+	}
+
+	public void setObjArray(Object[] objArray) {
+		this.objArray = objArray;
+		isArray=true;
+	}
+
 	public int objectSize = 0;
 	
 	private JObject superClazzObject = null;
@@ -349,6 +359,7 @@
 	@Override
 	public int getArraySize() throws CorruptDataException {
 		if(isArray==false) throw new IllegalArgumentException("object is not an array");
+		if(objArray==null) throw new CancellationException("underlying array object is null");
 		return objArray.length;
 	}
 

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java?rev=889268&r1=889267&r2=889268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
Thu Dec 10 14:06:48 2009
@@ -765,8 +765,8 @@
 				}
 				obj = model
 				.getObject(arrayClass.getID().getAddress(), position);
-				obj.objArray = objA;
-				obj.isArray = true;
+				obj.setObjArray(objA);
+				
 				return obj;
 			case CJVMTI_BYTE_ARRAY:
 				length = variablesIn.readInt();
@@ -775,8 +775,7 @@
 					ba[counter] = variablesIn.readByte();
 				}
 				obj = model.getObject(byteArray.classid, position);
-				obj.objArray = ba;
-				obj.isArray = true;
+				obj.setObjArray(ba);
 
 				return obj;
 			case CJVMTI_CHAR_ARRAY:
@@ -786,8 +785,7 @@
 					ca[counter] = (char) variablesIn.readShort();
 				}
 				obj = model.getObject(charArray.classid, position);
-				obj.objArray = ca;
-				obj.isArray = true;
+				obj.setObjArray(ca);
 				return obj;
 			case CJVMTI_DOUBLE_ARRAY:
 				length = variablesIn.readInt();
@@ -796,8 +794,7 @@
 					da[counter] = variablesIn.readDouble();
 				}
 				obj = model.getObject(doubleArray.classid, position);
-				obj.objArray = da;
-				obj.isArray = true;
+				obj.setObjArray(da);
 				return obj;
 			case CJVMTI_FLOAT_ARRAY:
 				length = variablesIn.readInt();
@@ -806,8 +803,7 @@
 					fa[counter] = variablesIn.readFloat();
 				}
 				obj = model.getObject(floatArray.classid, position);
-				obj.objArray = fa;
-				obj.isArray = true;
+				obj.setObjArray(fa);
 				return obj;
 			case CJVMTI_INT_ARRAY:
 				length = variablesIn.readInt();
@@ -816,8 +812,7 @@
 					i[counter] = variablesIn.readInt();
 				}
 				obj = model.getObject(intArray.classid, position);
-				obj.objArray = i;
-				obj.isArray = true;
+				obj.setObjArray(i);
 				return obj;
 			case CJVMTI_LONG_ARRAY:
 				length = variablesIn.readInt();
@@ -826,8 +821,7 @@
 					la[counter] = variablesIn.readLong();
 				}
 				obj = model.getObject(longArray.classid, position);
-				obj.objArray = la;
-				obj.isArray = true;
+				obj.setObjArray(la);
 				return obj;
 			case CJVMTI_SHORT_ARRAY:
 				length = variablesIn.readInt();
@@ -836,8 +830,7 @@
 					sa[counter] = variablesIn.readShort();
 				}
 				obj = model.getObject(shortArray.classid, position);
-				obj.objArray = sa;
-				obj.isArray = true;
+				obj.setObjArray(sa);
 				return obj;
 			case CJVMTI_BOOLEAN_ARRAY:
 				length = variablesIn.readInt();
@@ -846,8 +839,7 @@
 					za[counter] = variablesIn.readBoolean();
 				}
 				obj = model.getObject(booleanArray.classid, position);
-				obj.objArray = za;
-				obj.isArray = true;
+				obj.setObjArray(za);
 				return obj;
 			case CJVMTI_NULL_OBJECT:
 				return null;



Mime
View raw message