Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/ObjectReferenceImpl.java')
-rw-r--r--org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/ObjectReferenceImpl.java470
1 files changed, 261 insertions, 209 deletions
diff --git a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/ObjectReferenceImpl.java b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/ObjectReferenceImpl.java
index 71e5fa170..0c3bf753e 100644
--- a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/ObjectReferenceImpl.java
+++ b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/ObjectReferenceImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jdi.internal;
-
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -43,23 +42,22 @@ import com.sun.jdi.VMDisconnectedException;
import com.sun.jdi.Value;
/**
- * this class implements the corresponding interfaces
- * declared by the JDI specification. See the com.sun.jdi package
- * for more information.
- *
+ * this class implements the corresponding interfaces declared by the JDI
+ * specification. See the com.sun.jdi package for more information.
+ *
*/
public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
/** JDWP Tag. */
public static final byte tag = JdwpID.OBJECT_TAG;
-
+
/** ObjectID of object that corresponds to this reference. */
private JdwpObjectID fObjectID;
/**
- * Cached reference type. This value is safe for caching because
- * the type of an object never changes.
+ * Cached reference type. This value is safe for caching because the type of
+ * an object never changes.
*/
private ReferenceType fReferenceType;
-
+
/**
* Creates new ObjectReferenceImpl.
*/
@@ -70,18 +68,20 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
/**
* Creates new ObjectReferenceImpl.
*/
- public ObjectReferenceImpl(String description, VirtualMachineImpl vmImpl, JdwpObjectID objectID) {
+ public ObjectReferenceImpl(String description, VirtualMachineImpl vmImpl,
+ JdwpObjectID objectID) {
super(description, vmImpl);
fObjectID = objectID;
}
-
+
/**
* @returns tag.
*/
+ @Override
public byte getTag() {
return tag;
}
-
+
/**
* @return Returns Jdwp Object ID.
*/
@@ -89,42 +89,44 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
return fObjectID;
}
- /**
- * Prevents garbage collection for this object.
+ /**
+ * Prevents garbage collection for this object.
*/
public void disableCollection() {
initJdwpRequest();
try {
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_DISABLE_COLLECTION, this);
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_DISABLE_COLLECTION, this);
defaultReplyErrorHandler(replyPacket.errorCode());
} finally {
handledJdwpRequest();
}
}
-
- /**
- * Permits garbage collection for this object.
+
+ /**
+ * Permits garbage collection for this object.
*/
public void enableCollection() {
initJdwpRequest();
try {
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_ENABLE_COLLECTION, this);
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_ENABLE_COLLECTION, this);
defaultReplyErrorHandler(replyPacket.errorCode());
} finally {
handledJdwpRequest();
}
}
-
- /**
+
+ /**
* Inner class used to return monitor info.
*/
private class MonitorInfo {
ThreadReferenceImpl owner;
int entryCount;
- ArrayList waiters;
+ ArrayList<ThreadReference> waiters;
}
-
- /**
+
+ /**
* @return Returns monitor info.
*/
private MonitorInfo monitorInfo() throws IncompatibleThreadStateException {
@@ -134,22 +136,23 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
// Note that this information should not be cached.
initJdwpRequest();
try {
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_MONITOR_INFO, this);
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_MONITOR_INFO, this);
switch (replyPacket.errorCode()) {
- case JdwpReplyPacket.INVALID_THREAD:
- throw new IncompatibleThreadStateException();
- case JdwpReplyPacket.THREAD_NOT_SUSPENDED:
- throw new IncompatibleThreadStateException();
+ case JdwpReplyPacket.INVALID_THREAD:
+ throw new IncompatibleThreadStateException();
+ case JdwpReplyPacket.THREAD_NOT_SUSPENDED:
+ throw new IncompatibleThreadStateException();
}
-
+
defaultReplyErrorHandler(replyPacket.errorCode());
-
+
DataInputStream replyData = replyPacket.dataInStream();
MonitorInfo result = new MonitorInfo();
result.owner = ThreadReferenceImpl.read(this, replyData);
result.entryCount = readInt("entry count", replyData); //$NON-NLS-1$
int nrOfWaiters = readInt("nr of waiters", replyData); //$NON-NLS-1$
- result.waiters = new ArrayList(nrOfWaiters);
+ result.waiters = new ArrayList<ThreadReference>(nrOfWaiters);
for (int i = 0; i < nrOfWaiters; i++)
result.waiters.add(ThreadReferenceImpl.read(this, replyData));
return result;
@@ -160,47 +163,56 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
handledJdwpRequest();
}
}
-
- /**
- * @return Returns an ThreadReference for the thread, if any, which currently owns this object's monitor.
+
+ /**
+ * @return Returns an ThreadReference for the thread, if any, which
+ * currently owns this object's monitor.
*/
- public ThreadReference owningThread() throws IncompatibleThreadStateException {
+ public ThreadReference owningThread()
+ throws IncompatibleThreadStateException {
return monitorInfo().owner;
}
- /**
- * @return Returns the number times this object's monitor has been entered by the current owning thread.
+ /**
+ * @return Returns the number times this object's monitor has been entered
+ * by the current owning thread.
*/
public int entryCount() throws IncompatibleThreadStateException {
return monitorInfo().entryCount;
}
- /**
- * @return Returns a List containing a ThreadReference for each thread currently waiting for this object's monitor.
+ /**
+ * @return Returns a List containing a ThreadReference for each thread
+ * currently waiting for this object's monitor.
*/
- public List waitingThreads() throws IncompatibleThreadStateException {
+ public List<ThreadReference> waitingThreads() throws IncompatibleThreadStateException {
return monitorInfo().waiters;
}
-
- /**
- * @return Returns the value of a given instance or static field in this object.
+
+ /**
+ * @return Returns the value of a given instance or static field in this
+ * object.
*/
public Value getValue(Field field) {
- ArrayList list = new ArrayList(1);
+ ArrayList<Field> list = new ArrayList<Field>(1);
list.add(field);
- return (ValueImpl)getValues(list).get(field);
+ return getValues(list).get(field);
}
-
+
/**
- * @return Returns objects that directly reference this object.
- * Only objects that are reachable for the purposes of garbage collection are returned.
- * Note that an object can also be referenced in other ways, such as from a local variable in a stack frame, or from a JNI global reference. Such non-object referrers are not returned by this method.
+ * @return Returns objects that directly reference this object. Only objects
+ * that are reachable for the purposes of garbage collection are
+ * returned. Note that an object can also be referenced in other
+ * ways, such as from a local variable in a stack frame, or from a
+ * JNI global reference. Such non-object referrers are not returned
+ * by this method.
*
* @since 3.3
*/
- public List referringObjects(long maxReferrers) throws UnsupportedOperationException, IllegalArgumentException {
+ public List<Value> referringObjects(long maxReferrers)
+ throws UnsupportedOperationException, IllegalArgumentException {
try {
- int max = (int)maxReferrers;
+ int max = (int) maxReferrers;
if (maxReferrers >= Integer.MAX_VALUE) {
max = Integer.MAX_VALUE;
}
@@ -208,80 +220,85 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
DataOutputStream outData = new DataOutputStream(outBytes);
this.getObjectID().write(outData);
writeInt(max, "max referrers", outData); //$NON-NLS-1$
-
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_REFERRING_OBJECTS, outBytes);
- switch(replyPacket.errorCode()) {
- case JdwpReplyPacket.NOT_IMPLEMENTED:
- throw new UnsupportedOperationException(JDIMessages.ReferenceTypeImpl_27);
- case JdwpReplyPacket.ILLEGAL_ARGUMENT:
- throw new IllegalArgumentException(JDIMessages.ReferenceTypeImpl_26);
- case JdwpReplyPacket.INVALID_OBJECT:
- throw new ObjectCollectedException(JDIMessages.ObjectReferenceImpl_object_not_known);
- case JdwpReplyPacket.VM_DEAD:
- throw new VMDisconnectedException(JDIMessages.vm_dead);
+
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_REFERRING_OBJECTS, outBytes);
+ switch (replyPacket.errorCode()) {
+ case JdwpReplyPacket.NOT_IMPLEMENTED:
+ throw new UnsupportedOperationException(
+ JDIMessages.ReferenceTypeImpl_27);
+ case JdwpReplyPacket.ILLEGAL_ARGUMENT:
+ throw new IllegalArgumentException(
+ JDIMessages.ReferenceTypeImpl_26);
+ case JdwpReplyPacket.INVALID_OBJECT:
+ throw new ObjectCollectedException(
+ JDIMessages.ObjectReferenceImpl_object_not_known);
+ case JdwpReplyPacket.VM_DEAD:
+ throw new VMDisconnectedException(JDIMessages.vm_dead);
}
defaultReplyErrorHandler(replyPacket.errorCode());
-
+
DataInputStream replyData = replyPacket.dataInStream();
int elements = readInt("elements", replyData); //$NON-NLS-1$
- if(max > 0 && elements > max) {
+ if (max > 0 && elements > max) {
elements = max;
}
- ArrayList list = new ArrayList();
- for(int i = 0; i < elements; i++) {
+ ArrayList<Value> list = new ArrayList<Value>();
+ for (int i = 0; i < elements; i++) {
list.add(ValueImpl.readWithTag(this, replyData));
}
return list;
- }
- catch(IOException e) {
+ } catch (IOException e) {
defaultIOExceptionHandler(e);
return null;
} finally {
handledJdwpRequest();
}
}
-
- /**
- * @return Returns the value of multiple instance and/or static fields in this object.
+
+ /**
+ * @return Returns the value of multiple instance and/or static fields in
+ * this object.
*/
- public Map getValues(List allFields) {
+ public Map<Field, Value> getValues(List<? extends Field> allFields) {
// if the field list is empty, nothing to do.
if (allFields.isEmpty()) {
- return new HashMap();
+ return new HashMap<Field, Value>();
}
// Note that this information should not be cached.
initJdwpRequest();
try {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
DataOutputStream outData = new DataOutputStream(outBytes);
-
+
/*
- * Distinguish static fields from non-static fields:
- * For static fields ReferenceTypeImpl.getValues() must be used.
+ * Distinguish static fields from non-static fields: For static
+ * fields ReferenceTypeImpl.getValues() must be used.
*/
- List staticFields = new ArrayList();
- List nonStaticFields = new ArrayList();
-
+ List<Field> staticFields = new ArrayList<Field>();
+ List<FieldImpl> nonStaticFields = new ArrayList<FieldImpl>();
+
// Separate static and non-static fields.
int allFieldsSize = allFields.size();
for (int i = 0; i < allFieldsSize; i++) {
- FieldImpl field = (FieldImpl)allFields.get(i);
+ FieldImpl field = (FieldImpl) allFields.get(i);
checkVM(field);
- if (field.isStatic())
- staticFields.add(field);
- else
- nonStaticFields.add(field);
+ if (field.isStatic())
+ staticFields.add(field);
+ else
+ nonStaticFields.add(field);
}
-
+
// First get values for the static fields.
- Map resultMap;
+ Map<Field, Value> resultMap;
if (staticFields.isEmpty()) {
- resultMap= new HashMap();
+ resultMap = new HashMap<Field, Value>();
} else {
- resultMap= referenceType().getValues(staticFields);
+ resultMap = referenceType().getValues(staticFields);
}
-
- // if no non-static fields are requested, return directly the result.
+
+ // if no non-static fields are requested, return directly the
+ // result.
if (nonStaticFields.isEmpty()) {
return resultMap;
}
@@ -290,20 +307,23 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
write(this, outData);
writeInt(nonStaticFieldsSize, "size", outData); //$NON-NLS-1$
for (int i = 0; i < nonStaticFieldsSize; i++) {
- FieldImpl field = (FieldImpl)nonStaticFields.get(i);
+ FieldImpl field = nonStaticFields.get(i);
field.write(this, outData);
}
-
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_GET_VALUES, outBytes);
+
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_GET_VALUES, outBytes);
defaultReplyErrorHandler(replyPacket.errorCode());
-
+
DataInputStream replyData = replyPacket.dataInStream();
int nrOfElements = readInt("elements", replyData); //$NON-NLS-1$
- if (nrOfElements != nonStaticFieldsSize)
- throw new InternalError(JDIMessages.ObjectReferenceImpl_Retrieved_a_different_number_of_values_from_the_VM_than_requested_1);
-
+ if (nrOfElements != nonStaticFieldsSize)
+ throw new InternalError(
+ JDIMessages.ObjectReferenceImpl_Retrieved_a_different_number_of_values_from_the_VM_than_requested_1);
+
for (int i = 0; i < nrOfElements; i++) {
- resultMap.put(nonStaticFields.get(i), ValueImpl.readWithTag(this, replyData));
+ resultMap.put(nonStaticFields.get(i),
+ ValueImpl.readWithTag(this, replyData));
}
return resultMap;
} catch (IOException e) {
@@ -313,62 +333,74 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
handledJdwpRequest();
}
}
-
- /**
+
+ /**
* @return Returns the hash code value.
*/
+ @Override
public int hashCode() {
return fObjectID.hashCode();
}
-
+
/**
- * @return Returns true if two mirrors refer to the same entity in the target VM.
+ * @return Returns true if two mirrors refer to the same entity in the
+ * target VM.
* @see java.lang.Object#equals(Object)
*/
+ @Override
public boolean equals(Object object) {
return object != null
- && object.getClass().equals(this.getClass())
- && fObjectID.equals(((ObjectReferenceImpl)object).fObjectID)
- && virtualMachine().equals(((MirrorImpl)object).virtualMachine());
+ && object.getClass().equals(this.getClass())
+ && fObjectID.equals(((ObjectReferenceImpl) object).fObjectID)
+ && virtualMachine().equals(
+ ((MirrorImpl) object).virtualMachine());
}
-
+
/**
* @return Returns Jdwp version of given options.
*/
private int optionsToJdwpOptions(int options) {
int jdwpOptions = 0;
- if ((options & INVOKE_SINGLE_THREADED) != 0) {
- jdwpOptions |= MethodImpl.INVOKE_SINGLE_THREADED_JDWP;
- }
- if ((options & INVOKE_NONVIRTUAL) != 0) {
- jdwpOptions |= MethodImpl.INVOKE_NONVIRTUAL_JDWP;
- }
- return jdwpOptions;
+ if ((options & INVOKE_SINGLE_THREADED) != 0) {
+ jdwpOptions |= MethodImpl.INVOKE_SINGLE_THREADED_JDWP;
+ }
+ if ((options & INVOKE_NONVIRTUAL) != 0) {
+ jdwpOptions |= MethodImpl.INVOKE_NONVIRTUAL_JDWP;
+ }
+ return jdwpOptions;
}
-
+
/**
* Invokes the specified static Method in the target VM.
+ *
* @return Returns a Value mirror of the invoked method's return value.
*/
- public Value invokeMethod(ThreadReference thread, Method method, List arguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException {
- checkVM(thread);
+ public Value invokeMethod(ThreadReference thread, Method method, List<? extends Value> arguments, int options) throws InvalidTypeException,
+ ClassNotLoadedException, IncompatibleThreadStateException,
+ InvocationException {
+ checkVM(thread);
checkVM(method);
- ThreadReferenceImpl threadImpl = (ThreadReferenceImpl)thread;
- MethodImpl methodImpl = (MethodImpl)method;
-
+ ThreadReferenceImpl threadImpl = (ThreadReferenceImpl) thread;
+ MethodImpl methodImpl = (MethodImpl) method;
+
// Perform some checks for IllegalArgumentException.
if (!isAValidMethod(method))
- throw new IllegalArgumentException(JDIMessages.ObjectReferenceImpl_Class_does_not_contain_given_method_2);
+ throw new IllegalArgumentException(
+ JDIMessages.ObjectReferenceImpl_Class_does_not_contain_given_method_2);
if (method.argumentTypeNames().size() != arguments.size())
- throw new IllegalArgumentException(JDIMessages.ObjectReferenceImpl_Number_of_arguments_doesn__t_match_3);
+ throw new IllegalArgumentException(
+ JDIMessages.ObjectReferenceImpl_Number_of_arguments_doesn__t_match_3);
if (method.isConstructor() || method.isStaticInitializer())
- throw new IllegalArgumentException(JDIMessages.ObjectReferenceImpl_Method_is_constructor_or_intitializer_4);
+ throw new IllegalArgumentException(
+ JDIMessages.ObjectReferenceImpl_Method_is_constructor_or_intitializer_4);
if ((options & INVOKE_NONVIRTUAL) != 0 && method.isAbstract())
- throw new IllegalArgumentException(JDIMessages.ObjectReferenceImpl_Method_is_abstract_and_can_therefore_not_be_invoked_nonvirtual_5);
+ throw new IllegalArgumentException(
+ JDIMessages.ObjectReferenceImpl_Method_is_abstract_and_can_therefore_not_be_invoked_nonvirtual_5);
- // check the type and the vm of the argument, convert the value if needed.
- List checkedArguments= ValueImpl.checkValues(arguments, method.argumentTypes(), virtualMachineImpl());
+ // check the type and the vm of the argument, convert the value if
+ // needed.
+ List<Value> checkedArguments = ValueImpl.checkValues(arguments, method.argumentTypes(), virtualMachineImpl());
initJdwpRequest();
try {
@@ -376,39 +408,43 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
DataOutputStream outData = new DataOutputStream(outBytes);
write(this, outData);
threadImpl.write(this, outData);
- ((ReferenceTypeImpl)referenceType()).write(this, outData);
+ ((ReferenceTypeImpl) referenceType()).write(this, outData);
methodImpl.write(this, outData);
-
+
writeInt(checkedArguments.size(), "size", outData); //$NON-NLS-1$
- Iterator iter = checkedArguments.iterator();
- while(iter.hasNext()) {
- ValueImpl elt = (ValueImpl)iter.next();
+ Iterator<Value> iter = checkedArguments.iterator();
+ while (iter.hasNext()) {
+ ValueImpl elt = (ValueImpl) iter.next();
if (elt != null) {
elt.writeWithTag(this, outData);
} else {
ValueImpl.writeNullWithTag(this, outData);
}
}
-
- writeInt(optionsToJdwpOptions(options),"options", MethodImpl.getInvokeOptions(), outData); //$NON-NLS-1$
-
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_INVOKE_METHOD, outBytes);
+
+ writeInt(optionsToJdwpOptions(options),
+ "options", MethodImpl.getInvokeOptions(), outData); //$NON-NLS-1$
+
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_INVOKE_METHOD, outBytes);
switch (replyPacket.errorCode()) {
- case JdwpReplyPacket.TYPE_MISMATCH:
- throw new InvalidTypeException();
- case JdwpReplyPacket.INVALID_CLASS:
- throw new ClassNotLoadedException(JDIMessages.ObjectReferenceImpl_One_of_the_arguments_of_ObjectReference_invokeMethod___6);
- case JdwpReplyPacket.INVALID_THREAD:
- throw new IncompatibleThreadStateException();
- case JdwpReplyPacket.THREAD_NOT_SUSPENDED:
- throw new IncompatibleThreadStateException();
- case JdwpReplyPacket.INVALID_TYPESTATE:
- throw new IncompatibleThreadStateException();
+ case JdwpReplyPacket.TYPE_MISMATCH:
+ throw new InvalidTypeException();
+ case JdwpReplyPacket.INVALID_CLASS:
+ throw new ClassNotLoadedException(
+ JDIMessages.ObjectReferenceImpl_One_of_the_arguments_of_ObjectReference_invokeMethod___6);
+ case JdwpReplyPacket.INVALID_THREAD:
+ throw new IncompatibleThreadStateException();
+ case JdwpReplyPacket.THREAD_NOT_SUSPENDED:
+ throw new IncompatibleThreadStateException();
+ case JdwpReplyPacket.INVALID_TYPESTATE:
+ throw new IncompatibleThreadStateException();
}
defaultReplyErrorHandler(replyPacket.errorCode());
DataInputStream replyData = replyPacket.dataInStream();
ValueImpl value = ValueImpl.readWithTag(this, replyData);
- ObjectReferenceImpl exception = ObjectReferenceImpl.readObjectRefWithTag(this, replyData);
+ ObjectReferenceImpl exception = ObjectReferenceImpl
+ .readObjectRefWithTag(this, replyData);
if (exception != null)
throw new InvocationException(exception);
return value;
@@ -421,37 +457,40 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
}
private boolean isAValidMethod(Method method) {
- ReferenceType refType= referenceType();
+ ReferenceType refType = referenceType();
if (refType instanceof ArrayType) {
- // if the object is an array, check if the method is declared in java.lang.Object
+ // if the object is an array, check if the method is declared in
+ // java.lang.Object
return "java.lang.Object".equals(method.declaringType().name()); //$NON-NLS-1$
}
return refType.allMethods().contains(method);
}
-
+
/**
- * @return Returns if this object has been garbage collected in the target VM.
+ * @return Returns if this object has been garbage collected in the target
+ * VM.
*/
public boolean isCollected() {
// Note that this information should not be cached.
initJdwpRequest();
try {
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_IS_COLLECTED, this);
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_IS_COLLECTED, this);
switch (replyPacket.errorCode()) {
- case JdwpReplyPacket.INVALID_OBJECT:
+ case JdwpReplyPacket.INVALID_OBJECT:
+ return true;
+ case JdwpReplyPacket.NOT_IMPLEMENTED:
+ // Workaround for problem in J2ME WTK (wireless toolkit)
+ // @see Bug 12966
+ try {
+ referenceType();
+ } catch (ObjectCollectedException e) {
return true;
- case JdwpReplyPacket.NOT_IMPLEMENTED:
- // Workaround for problem in J2ME WTK (wireless toolkit)
- // @see Bug 12966
- try {
- referenceType();
- } catch (ObjectCollectedException e) {
- return true;
- }
- return false;
- default:
- defaultReplyErrorHandler(replyPacket.errorCode());
- break;
+ }
+ return false;
+ default:
+ defaultReplyErrorHandler(replyPacket.errorCode());
+ break;
}
DataInputStream replyData = replyPacket.dataInStream();
boolean result = readBoolean("is collected", replyData); //$NON-NLS-1$
@@ -464,7 +503,6 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
}
}
-
/**
* @return Returns the ReferenceType that mirrors the type of this object.
*/
@@ -474,10 +512,11 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
}
initJdwpRequest();
try {
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_REFERENCE_TYPE, this);
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_REFERENCE_TYPE, this);
defaultReplyErrorHandler(replyPacket.errorCode());
DataInputStream replyData = replyPacket.dataInStream();
- fReferenceType= ReferenceTypeImpl.readWithTypeTag(this, replyData);
+ fReferenceType = ReferenceTypeImpl.readWithTypeTag(this, replyData);
return fReferenceType;
} catch (IOException e) {
defaultIOExceptionHandler(e);
@@ -486,43 +525,48 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
handledJdwpRequest();
}
}
-
+
/**
* @return Returns the Type that mirrors the type of this object.
*/
+ @Override
public Type type() {
return referenceType();
}
-
+
/**
- * Sets the value of a given instance or static field in this object.
+ * Sets the value of a given instance or static field in this object.
*/
- public void setValue(Field field, Value value) throws InvalidTypeException, ClassNotLoadedException {
+ public void setValue(Field field, Value value) throws InvalidTypeException,
+ ClassNotLoadedException {
// Note that this information should not be cached.
initJdwpRequest();
try {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
DataOutputStream outData = new DataOutputStream(outBytes);
write(this, outData);
- writeInt(1, "size", outData); // We only set one field //$NON-NLS-1$
+ writeInt(1, "size", outData); // We only set one field //$NON-NLS-1$
checkVM(field);
- ((FieldImpl)field).write(this, outData);
+ ((FieldImpl) field).write(this, outData);
- // check the type and the vm of the value. Convert the value if needed
- ValueImpl checkedValue= ValueImpl.checkValue(value, field.type(), virtualMachineImpl());
+ // check the type and the vm of the value. Convert the value if
+ // needed
+ ValueImpl checkedValue = ValueImpl.checkValue(value, field.type(),
+ virtualMachineImpl());
if (checkedValue != null) {
checkedValue.write(this, outData);
} else {
ValueImpl.writeNull(this, outData);
}
-
- JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.OR_SET_VALUES, outBytes);
+
+ JdwpReplyPacket replyPacket = requestVM(
+ JdwpCommandPacket.OR_SET_VALUES, outBytes);
switch (replyPacket.errorCode()) {
- case JdwpReplyPacket.TYPE_MISMATCH:
- throw new InvalidTypeException();
- case JdwpReplyPacket.INVALID_CLASS:
- throw new ClassNotLoadedException(referenceType().name());
+ case JdwpReplyPacket.TYPE_MISMATCH:
+ throw new InvalidTypeException();
+ case JdwpReplyPacket.INVALID_CLASS:
+ throw new ClassNotLoadedException(referenceType().name());
}
defaultReplyErrorHandler(replyPacket.errorCode());
} catch (IOException e) {
@@ -531,14 +575,14 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
handledJdwpRequest();
}
}
-
+
/**
- * @return Returns a unique identifier for this ObjectReference.
+ * @return Returns a unique identifier for this ObjectReference.
*/
public long uniqueID() {
return fObjectID.value();
}
-
+
/**
* @return Returns string with value of ID.
*/
@@ -549,11 +593,13 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
/**
* @return Returns description of Mirror object.
*/
+ @Override
public String toString() {
try {
return type().toString() + " " + idString(); //$NON-NLS-1$
} catch (ObjectCollectedException e) {
- return JDIMessages.ObjectReferenceImpl__Garbage_Collected__ObjectReference__8 + idString();
+ return JDIMessages.ObjectReferenceImpl__Garbage_Collected__ObjectReference__8
+ + idString();
} catch (Exception e) {
return fDescription;
}
@@ -562,7 +608,8 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
/**
* @return Reads JDWP representation and returns new instance.
*/
- public static ObjectReferenceImpl readObjectRefWithoutTag(MirrorImpl target, DataInputStream in) throws IOException {
+ public static ObjectReferenceImpl readObjectRefWithoutTag(
+ MirrorImpl target, DataInputStream in) throws IOException {
VirtualMachineImpl vmImpl = target.virtualMachineImpl();
JdwpObjectID ID = new JdwpObjectID(vmImpl);
ID.read(in);
@@ -571,41 +618,46 @@ public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
if (ID.isNull())
return null;
-
+
ObjectReferenceImpl mirror = new ObjectReferenceImpl(vmImpl, ID);
return mirror;
}
-
+
/**
* @return Reads JDWP representation and returns new instance.
*/
- public static ObjectReferenceImpl readObjectRefWithTag(MirrorImpl target, DataInputStream in) throws IOException {
+ public static ObjectReferenceImpl readObjectRefWithTag(MirrorImpl target,
+ DataInputStream in) throws IOException {
byte objectTag = target.readByte("object tag", JdwpID.tagMap(), in); //$NON-NLS-1$
switch (objectTag) {
- case 0:
- return null;
- case ObjectReferenceImpl.tag:
- return ObjectReferenceImpl.readObjectRefWithoutTag(target, in);
- case ArrayReferenceImpl.tag:
- return ArrayReferenceImpl.read(target, in);
- case ClassLoaderReferenceImpl.tag:
- return ClassLoaderReferenceImpl.read(target, in);
- case ClassObjectReferenceImpl.tag:
- return ClassObjectReferenceImpl.read(target, in);
- case StringReferenceImpl.tag:
- return StringReferenceImpl.read(target, in);
- case ThreadGroupReferenceImpl.tag:
- return ThreadGroupReferenceImpl.read(target, in);
- case ThreadReferenceImpl.tag:
- return ThreadReferenceImpl.read(target, in);
- }
- throw new InternalException(JDIMessages.ObjectReferenceImpl_Invalid_ObjectID_tag_encountered___9 + objectTag);
+ case 0:
+ return null;
+ case ObjectReferenceImpl.tag:
+ return ObjectReferenceImpl.readObjectRefWithoutTag(target, in);
+ case ArrayReferenceImpl.tag:
+ return ArrayReferenceImpl.read(target, in);
+ case ClassLoaderReferenceImpl.tag:
+ return ClassLoaderReferenceImpl.read(target, in);
+ case ClassObjectReferenceImpl.tag:
+ return ClassObjectReferenceImpl.read(target, in);
+ case StringReferenceImpl.tag:
+ return StringReferenceImpl.read(target, in);
+ case ThreadGroupReferenceImpl.tag:
+ return ThreadGroupReferenceImpl.read(target, in);
+ case ThreadReferenceImpl.tag:
+ return ThreadReferenceImpl.read(target, in);
+ }
+ throw new InternalException(
+ JDIMessages.ObjectReferenceImpl_Invalid_ObjectID_tag_encountered___9
+ + objectTag);
}
/**
* Writes JDWP representation without tag.
*/
- public void write(MirrorImpl target, DataOutputStream out) throws IOException {
+ @Override
+ public void write(MirrorImpl target, DataOutputStream out)
+ throws IOException {
fObjectID.write(out);
if (target.fVerboseWriter != null)
target.fVerboseWriter.println("objectReference", fObjectID.value()); //$NON-NLS-1$

Back to the top