mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
6716452: (classfile) need a method to get the index of an attribute
Reviewed-by: ksrini
This commit is contained in:
parent
a2ef1138ad
commit
d1e9333931
2 changed files with 126 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue