JavaObject jObject = getObject(object);
if (jObject != null){
try{
int refTypeTag = 1;
JavaClass jClass = jObject.getJavaClass();
if (jClass == null){
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)1);
logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Cannot get class type, returning object instead"); //$NON-NLS-1$
JavaClass jOutClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
addLongToVector(vctr, jOutClass.getID().getAddress());
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Cannot get class type"); //$NON-NLS-1$
return rpckt;
}
long typeID = jObject.getJavaClass().getID().getAddress();
if (!classes.containsKey(typeID)){
logr.log(JDILogger.LEVEL_VERYVERBOSE, " Client may not have classID"); //$NON-NLS-1$
}
if (jObject.isArray()){
refTypeTag = 3;
}else if(isInterface(typeID)){
refTypeTag = 2;
}
logr.log(JDILogger.LEVEL_VERYVERBOSE, " refTagType " + refTypeTag); //$NON-NLS-1$
logr.log(JDILogger.LEVEL_VERYVERBOSE, " name " + jObject.getJavaClass().getName() + "{"+jObject.getJavaClass().getID().getAddress()+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)refTypeTag);
addLongToVector(vctr, typeID);
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
return rpckt;
}catch(CorruptDataException exxy){
logr.logError(JDILogger.LEVEL_VERBOSE, " Corrupt data!"); //$NON-NLS-1$
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)1);
JavaClass jClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
addLongToVector(vctr, jClass.getID().getAddress());
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
rpckt.setData(vectorToByte(vctr));
return rpckt;
}
}
}else{
JavaClass javaClass = getClass(object);
if (javaClass != null){
int refTypeTag = 1;
long typeID = javaClass.getID().getAddress();
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)refTypeTag);
addLongToVector(vctr, typeID);
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
return rpckt;
}
JavaObject jObject = getObject(object);
if (jObject != null){
// This is a copy from above, could be made into a method
try{
int refTypeTag = 1;
JavaClass jClass = jObject.getJavaClass();
if (jClass == null){
logr.log(JDILogger.LEVEL_VERYVERBOSE, "Found the object the slow route");
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)1);
JavaClass jOutClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
addLongToVector(vctr, jOutClass.getID().getAddress());
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Cannot get class type"); //$NON-NLS-1$
return rpckt;
}
long typeID = jObject.getJavaClass().getID().getAddress();
if (!classes.containsKey(typeID)){
logr.log(JDILogger.LEVEL_VERYVERBOSE, " Client may not have classID"); //$NON-NLS-1$
}
if (jObject.isArray()){
refTypeTag = 3;
}else if(isInterface(typeID)){
refTypeTag = 2;
}
logr.log(JDILogger.LEVEL_VERYVERBOSE, " refTagType " + refTypeTag); //$NON-NLS-1$
logr.log(JDILogger.LEVEL_VERYVERBOSE, " name " + jObject.getJavaClass().getName() + "{"+jObject.getJavaClass().getID().getAddress()+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)refTypeTag);
addLongToVector(vctr, typeID);
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
return rpckt;
}catch(CorruptDataException exxy){
logr.logError(JDILogger.LEVEL_VERBOSE, " Corrupt data!"); //$NON-NLS-1$
Vector<Byte> vctr = new Vector<Byte>();
vctr.add((byte)1);
JavaClass jClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
addLongToVector(vctr, jClass.getID().getAddress());
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
rpckt.setData(vectorToByte(vctr));
return rpckt;
}
}
}
logr.log(JDILogger.LEVEL_VERYVERBOSE, "No matches"); //$NON-NLS-1$
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
return rpckt;
}else if (cpckt.getCommand() == 2){
byte [] inData = cpckt.getByteData();
long object = createLongFromBytes(inData, 0, 8);
int fields = createIntFromBytes(inData, 8, 4);
logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.GetValues(" + object + "," + fields + ",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Vector<Byte> vctr = new Vector<Byte>();
addIntToVector(vctr, fields);
for (int i = 0; i < fields; i++){
long fieldID = createLongFromBytes(inData, 12 + (8*i), 8);
if (objectMap.containsKey(object)){
logr.log(JDILogger.LEVEL_VERYVERBOSE, " O:" + fieldID); //$NON-NLS-1$
if (!getFieldFromObject(vctr, object, fieldID)){
logr.log(JDILogger.LEVEL_VERYVERBOSE, " O:" + fieldID+" Invalid Object/Field"); //$NON-NLS-1$
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
return rpckt;
}
}else{
logr.log(JDILogger.LEVEL_VERYVERBOSE, " C:" + fieldID); //$NON-NLS-1$
if (!getFieldFromClass(vctr, object, fieldID)){
logr.log(JDILogger.LEVEL_VERYVERBOSE, " O:" + fieldID+" Invalid Object/Field"); //$NON-NLS-1$
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
return rpckt;
}
}
}
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
return rpckt;
}else if (cpckt.getCommand() == 5){
// Monitor information, assume JNIEnv is the same as threadID...
byte[] inData = cpckt.getByteData();
long object = createLongFromBytes(inData, 0, 8);
Vector<Byte> vctr = new Vector<Byte>();
JavaMonitor jm = null;
logr.log(JDILogger.LEVEL_VERBOSE,"ObjectReference.MonitorInfo("+object+")");
if ((jm = monitorMap.get(objectMap))!= null){
JavaThread owningThread = jm.getOwner();
if (owningThread != null){
addLongToVector(vctr, owningThread.getJNIEnv().getAddress());
}else{
addLongToVector(vctr, 0);
}
addIntToVector(vctr, 1);
addIntToVector(vctr, jm.getEnterWaiters().size());
for (JavaThread thr : jm.getEnterWaiters()){
addLongToVector(vctr, thr.getJNIEnv().getAddress());
}
logr.log(JDILogger.LEVEL_VERYVERBOSE," "+jm.getEnterWaiters().size()+" waiting and owner is "+owningThread);
}else{
addLongToVector(vctr, 0);
addIntToVector(vctr, 0);
addIntToVector(vctr, 0);
logr.log(JDILogger.LEVEL_VERYVERBOSE," no monitor information");
}
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
rpckt.setData(vectorToByte(vctr));
return rpckt;
}else if (cpckt.getCommand() == 6){
byte [] inData = cpckt.getByteData();
long object = createLongFromBytes(inData, 0, 8);
long thread = createLongFromBytes(inData, 8, 8);
long clazz = createLongFromBytes(inData, 16, 8);
long method = createLongFromBytes(inData, 24, 8);
int arguments = createIntFromBytes(inData, 32, 4);
Vector<Byte> vctr = new Vector<Byte>();
logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.InvokeMethod(" + object + "," + thread + ","+clazz+","+method+","+arguments+",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
if (!isClass(object)){
JavaObject jObject = getObject(object);
if (jObject != null){
//
JavaClass jClass = jObject.getJavaClass();
logr.log(JDILogger.LEVEL_VERYVERBOSE, " object: " + jClass.getName() + ">>" + jObject.getJavaClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
vctr.add((byte)'s');
this.vctrs.put(jObject.getID().getAddress(), jObject.getJavaClass().getName());
addLongToVector(vctr, jObject.getID().getAddress());
vctr.add((byte)0);
}
}else{
JavaClass javaClass = getClass(clazz);
if (javaClass != null){
logr.log(JDILogger.LEVEL_VERYVERBOSE, " class: " + javaClass.getName()); //$NON-NLS-1$
vctr.add((byte)'s');
this.vctrs.put(javaClass.getID().getAddress(), javaClass.getName());
addLongToVector(vctr, javaClass.getID().getAddress());
vctr.add((byte)0);
}