src/share/classes/com/sun/tools/javac/jvm/Pool.java

changeset 1541
4cc73ec94686
parent 1452
de1ec6fc93fe
child 1617
d0178bd8125c
equal deleted inserted replaced
1540:55cca2f38ee6 1541:4cc73ec94686
1 /* 1 /*
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
138 public int get(Object o) { 138 public int get(Object o) {
139 Integer n = indices.get(o); 139 Integer n = indices.get(o);
140 return n == null ? -1 : n.intValue(); 140 return n == null ? -1 : n.intValue();
141 } 141 }
142 142
143 static class Method extends DelegatedSymbol { 143 static class Method extends DelegatedSymbol<MethodSymbol> {
144 MethodSymbol m;
145 UniqueType uniqueType; 144 UniqueType uniqueType;
146 Method(MethodSymbol m, Types types) { 145 Method(MethodSymbol m, Types types) {
147 super(m); 146 super(m);
148 this.m = m;
149 this.uniqueType = new UniqueType(m.type, types); 147 this.uniqueType = new UniqueType(m.type, types);
150 } 148 }
151 public boolean equals(Object other) { 149 public boolean equals(Object any) {
152 if (!(other instanceof Method)) return false; 150 if (!(any instanceof Method)) return false;
153 MethodSymbol o = ((Method)other).m; 151 MethodSymbol o = ((Method)any).other;
152 MethodSymbol m = this.other;
154 return 153 return
155 o.name == m.name && 154 o.name == m.name &&
156 o.owner == m.owner && 155 o.owner == m.owner &&
157 ((Method)other).uniqueType.equals(uniqueType); 156 ((Method)any).uniqueType.equals(uniqueType);
158 } 157 }
159 public int hashCode() { 158 public int hashCode() {
159 MethodSymbol m = this.other;
160 return 160 return
161 m.name.hashCode() * 33 + 161 m.name.hashCode() * 33 +
162 m.owner.hashCode() * 9 + 162 m.owner.hashCode() * 9 +
163 uniqueType.hashCode(); 163 uniqueType.hashCode();
164 } 164 }
171 super(m, types); 171 super(m, types);
172 uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types); 172 uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types);
173 } 173 }
174 174
175 @Override 175 @Override
176 public boolean equals(Object other) { 176 public boolean equals(Object any) {
177 if (!super.equals(other)) return false; 177 if (!super.equals(any)) return false;
178 if (!(other instanceof DynamicMethod)) return false; 178 if (!(any instanceof DynamicMethod)) return false;
179 DynamicMethodSymbol dm1 = (DynamicMethodSymbol)m; 179 DynamicMethodSymbol dm1 = (DynamicMethodSymbol)other;
180 DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)other).m; 180 DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)any).other;
181 return dm1.bsm == dm2.bsm && 181 return dm1.bsm == dm2.bsm &&
182 dm1.bsmKind == dm2.bsmKind && 182 dm1.bsmKind == dm2.bsmKind &&
183 Arrays.equals(uniqueStaticArgs, 183 Arrays.equals(uniqueStaticArgs,
184 ((DynamicMethod)other).uniqueStaticArgs); 184 ((DynamicMethod)any).uniqueStaticArgs);
185 } 185 }
186 186
187 @Override 187 @Override
188 public int hashCode() { 188 public int hashCode() {
189 int hash = super.hashCode(); 189 int hash = super.hashCode();
190 DynamicMethodSymbol dm = (DynamicMethodSymbol)m; 190 DynamicMethodSymbol dm = (DynamicMethodSymbol)other;
191 hash += dm.bsmKind * 7 + 191 hash += dm.bsmKind * 7 +
192 dm.bsm.hashCode() * 11; 192 dm.bsm.hashCode() * 11;
193 for (int i = 0; i < dm.staticArgs.length; i++) { 193 for (int i = 0; i < dm.staticArgs.length; i++) {
194 hash += (uniqueStaticArgs[i].hashCode() * 23); 194 hash += (uniqueStaticArgs[i].hashCode() * 23);
195 } 195 }
207 } 207 }
208 return result; 208 return result;
209 } 209 }
210 } 210 }
211 211
212 static class Variable extends DelegatedSymbol { 212 static class Variable extends DelegatedSymbol<VarSymbol> {
213 VarSymbol v;
214 UniqueType uniqueType; 213 UniqueType uniqueType;
215 Variable(VarSymbol v, Types types) { 214 Variable(VarSymbol v, Types types) {
216 super(v); 215 super(v);
217 this.v = v;
218 this.uniqueType = new UniqueType(v.type, types); 216 this.uniqueType = new UniqueType(v.type, types);
219 } 217 }
220 public boolean equals(Object other) { 218 public boolean equals(Object any) {
221 if (!(other instanceof Variable)) return false; 219 if (!(any instanceof Variable)) return false;
222 VarSymbol o = ((Variable)other).v; 220 VarSymbol o = ((Variable)any).other;
221 VarSymbol v = other;
223 return 222 return
224 o.name == v.name && 223 o.name == v.name &&
225 o.owner == v.owner && 224 o.owner == v.owner &&
226 ((Variable)other).uniqueType.equals(uniqueType); 225 ((Variable)any).uniqueType.equals(uniqueType);
227 } 226 }
228 public int hashCode() { 227 public int hashCode() {
228 VarSymbol v = other;
229 return 229 return
230 v.name.hashCode() * 33 + 230 v.name.hashCode() * 33 +
231 v.owner.hashCode() * 9 + 231 v.owner.hashCode() * 9 +
232 uniqueType.hashCode(); 232 uniqueType.hashCode();
233 } 233 }

mercurial