6716452: (classfile) need a method to get the index of an attribute

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2008-07-08 17:53:03 -07:00
parent a2ef1138ad
commit d1e9333931
2 changed files with 126 additions and 0 deletions

View file

@ -78,6 +78,19 @@ public class Attributes implements Iterable<Attribute> {
return map.get(name);
}
public int getIndex(ConstantPool constant_pool, String name) {
for (int i = 0; i < attrs.length; i++) {
Attribute attr = attrs[i];
try {
if (attr != null && attr.getName(constant_pool).equals(name))
return i;
} catch (ConstantPoolException e) {
// ignore invalid entries
}
}
return -1;
}
public int size() {
return attrs.length;
}