< prev index next >

src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java

Print this page

128         // make sure that cache and listener management are synchronized
129         synchronized (vm.state()) {
130             if (cache != null && (vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
131                 vm.printTrace("Clearing temporary cache for " + description());
132             }
133             disableCache();
134             if (addedListener) {
135                 /*
136                  * If a listener was added (i.e. this is not a
137                  * ObjectReference that adds a listener on startup),
138                  * remove it here.
139                  */
140                 addedListener = false;
141                 return false;  // false says remove
142             } else {
143                 return true;
144             }
145         }
146     }
147 







148     public boolean equals(Object obj) {
149         if (obj instanceof ObjectReferenceImpl other) {
150             return (ref() == other.ref()) &&
151                    super.equals(obj);
152         } else {
153             return false;










154         }

155     }
156 
157     @Override
158     public int hashCode() {







159         return Long.hashCode(ref());
160     }
161 
162     public Type type() {
163         return referenceType();
164     }
165 
166     public ReferenceType referenceType() {
167         if (type == null) {
168             try {
169                 JDWP.ObjectReference.ReferenceType rtinfo =
170                     JDWP.ObjectReference.ReferenceType.process(vm, this);
171                 type = vm.referenceType(rtinfo.typeID,
172                                         rtinfo.refTypeTag);
173             } catch (JDWPException exc) {
174                 throw exc.toJDIException();
175             }
176         }
177         return type;
178     }

128         // make sure that cache and listener management are synchronized
129         synchronized (vm.state()) {
130             if (cache != null && (vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
131                 vm.printTrace("Clearing temporary cache for " + description());
132             }
133             disableCache();
134             if (addedListener) {
135                 /*
136                  * If a listener was added (i.e. this is not a
137                  * ObjectReference that adds a listener on startup),
138                  * remove it here.
139                  */
140                 addedListener = false;
141                 return false;  // false says remove
142             } else {
143                 return true;
144             }
145         }
146     }
147 
148     boolean isValueObject() {
149         if (referenceType() instanceof ClassTypeImpl classType) {
150             return classType.isValueClass();
151         }
152         return false;
153     }
154 
155     public boolean equals(Object obj) {
156         if (obj instanceof ObjectReferenceImpl other) {
157             if (!super.equals(obj)) { // checks if the references belong to the same VM
158                 return false;
159             }
160             if (ref() == other.ref()) {
161                 return true;
162             }
163             // We can get equal value objects with different IDs.
164             if (isValueObject()) {
165                 try {
166                     return JDWP.ObjectReference.IsSameObject.process(vm, this, other).isSameObject;
167                 } catch (JDWPException exc) {
168                     throw exc.toJDIException();
169                 }
170             }
171         }
172         return false;
173     }
174 
175     @Override
176     public int hashCode() {
177         if (isValueObject()) {
178             try {
179                 return JDWP.ObjectReference.ObjectHashCode.process(vm, this).hashCode;
180             } catch (JDWPException exc) {
181                 throw exc.toJDIException();
182             }
183         }
184         return Long.hashCode(ref());
185     }
186 
187     public Type type() {
188         return referenceType();
189     }
190 
191     public ReferenceType referenceType() {
192         if (type == null) {
193             try {
194                 JDWP.ObjectReference.ReferenceType rtinfo =
195                     JDWP.ObjectReference.ReferenceType.process(vm, this);
196                 type = vm.referenceType(rtinfo.typeID,
197                                         rtinfo.refTypeTag);
198             } catch (JDWPException exc) {
199                 throw exc.toJDIException();
200             }
201         }
202         return type;
203     }
< prev index next >