1 /*
2 * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
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();
|
1 /*
2 * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
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 /* No longer needed, but kept for future reference
149 boolean isValueObject() {
150 if (referenceType() instanceof ClassTypeImpl classType) {
151 return classType.isValueClass();
152 }
153 return false;
154 }
155 */
156
157 public boolean equals(Object obj) {
158 if (obj instanceof ObjectReferenceImpl other) {
159 if (!super.equals(obj)) { // checks if the references belong to the same VM
160 return false;
161 }
162 if (ref() == other.ref()) {
163 return true;
164 }
165 }
166 return false;
167 }
168
169 @Override
170 public int hashCode() {
171 return Long.hashCode(ref());
172 }
173
174 public Type type() {
175 return referenceType();
176 }
177
178 public ReferenceType referenceType() {
179 if (type == null) {
180 try {
181 JDWP.ObjectReference.ReferenceType rtinfo =
182 JDWP.ObjectReference.ReferenceType.process(vm, this);
183 type = vm.referenceType(rtinfo.typeID,
184 rtinfo.refTypeTag);
185 } catch (JDWPException exc) {
186 throw exc.toJDIException();
|