Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jdi/FieldImpl.java
38920 views
/*1* Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.jdi;2627import com.sun.jdi.*;282930public class FieldImpl extends TypeComponentImpl31implements Field, ValueContainer {3233FieldImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,34long ref,35String name, String signature,36String genericSignature, int modifiers) {37super(vm, declaringType, ref, name, signature,38genericSignature, modifiers);39}4041public boolean equals(Object obj) {42if ((obj != null) && (obj instanceof FieldImpl)) {43FieldImpl other = (FieldImpl)obj;44return (declaringType().equals(other.declaringType())) &&45(ref() == other.ref()) &&46super.equals(obj);47} else {48return false;49}50}5152public int hashCode() {53return (int)ref();54}5556public int compareTo(Field field) {57ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();58int rc = declaringType.compareTo(field.declaringType());59if (rc == 0) {60rc = declaringType.indexOf(this) -61declaringType.indexOf(field);62}63return rc;64}6566public Type type() throws ClassNotLoadedException {67return findType(signature());68}6970public Type findType(String signature) throws ClassNotLoadedException {71ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();72return enclosing.findType(signature);73}7475/**76* @return a text representation of the declared type77* of this field.78*/79public String typeName() {80JNITypeParser parser = new JNITypeParser(signature());81return parser.typeName();82}8384public boolean isTransient() {85return isModifierSet(VMModifiers.TRANSIENT);86}8788public boolean isVolatile() {89return isModifierSet(VMModifiers.VOLATILE);90}9192public boolean isEnumConstant() {93return isModifierSet(VMModifiers.ENUM_CONSTANT);94}9596public String toString() {97StringBuffer buf = new StringBuffer();9899buf.append(declaringType().name());100buf.append('.');101buf.append(name());102103return buf.toString();104}105}106107108