Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.jdi/share/classes/com/sun/tools/jdi/FieldImpl.java
41161 views
1
/*
2
* Copyright (c) 1998, 2017, 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
23
* questions.
24
*/
25
26
package com.sun.tools.jdi;
27
28
import com.sun.jdi.ClassNotLoadedException;
29
import com.sun.jdi.Field;
30
import com.sun.jdi.Type;
31
import com.sun.jdi.VirtualMachine;
32
33
public class FieldImpl extends TypeComponentImpl
34
implements Field, ValueContainer {
35
36
FieldImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
37
long ref, String name, String signature,
38
String genericSignature, int modifiers) {
39
super(vm, declaringType, ref, name, signature,
40
genericSignature, modifiers);
41
}
42
43
public boolean equals(Object obj) {
44
if ((obj != null) && (obj instanceof FieldImpl)) {
45
FieldImpl other = (FieldImpl)obj;
46
return (declaringType().equals(other.declaringType())) &&
47
(ref() == other.ref()) &&
48
super.equals(obj);
49
} else {
50
return false;
51
}
52
}
53
54
public int hashCode() {
55
return (int)ref();
56
}
57
58
public int compareTo(Field field) {
59
ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();
60
int rc = declaringType.compareTo(field.declaringType());
61
if (rc == 0) {
62
rc = declaringType.indexOf(this) -
63
declaringType.indexOf(field);
64
}
65
return rc;
66
}
67
68
public Type type() throws ClassNotLoadedException {
69
return findType(signature());
70
}
71
72
public Type findType(String signature) throws ClassNotLoadedException {
73
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
74
return enclosing.findType(signature);
75
}
76
77
/**
78
* @return a text representation of the declared type
79
* of this field.
80
*/
81
public String typeName() {
82
JNITypeParser parser = new JNITypeParser(signature());
83
return parser.typeName();
84
}
85
86
public boolean isTransient() {
87
return isModifierSet(VMModifiers.TRANSIENT);
88
}
89
90
public boolean isVolatile() {
91
return isModifierSet(VMModifiers.VOLATILE);
92
}
93
94
public boolean isEnumConstant() {
95
return isModifierSet(VMModifiers.ENUM_CONSTANT);
96
}
97
98
public String toString() {
99
StringBuilder sb = new StringBuilder();
100
101
sb.append(declaringType().name());
102
sb.append('.');
103
sb.append(name());
104
105
return sb.toString();
106
}
107
}
108
109