< prev index next >
src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
Print this page
rev 16767 : 8175561: Memory churn in jimage code affects startup after resource encapsulation changes
Reviewed-by: jlaskey
rev 16768 : imported patch imgstr_oneup
@@ -247,45 +247,61 @@
public ImageStringsReader getStrings() {
return stringsReader;
}
- public ImageLocation findLocation(String mn, String rn) {
- Objects.requireNonNull(mn);
- Objects.requireNonNull(rn);
+ public synchronized ImageLocation findLocation(String module, String name) {
+ Objects.requireNonNull(module);
+ Objects.requireNonNull(name);
+ // Details of the algorithm used here can be found in
+ // jdk.tools.jlink.internal.PerfectHashBuilder.
+ int count = header.getTableLength();
+ int index = redirect.get(ImageStringsReader.hashCode(module, name) % count);
+
+ if (index < 0) {
+ // index is twos complement of location attributes index.
+ index = -index - 1;
+ } else if (index > 0) {
+ // index is hash seed needed to compute location attributes index.
+ index = ImageStringsReader.hashCode(module, name, index) % count;
+ } else {
+ // No entry.
+ return null;
+ }
+
+ long[] attributes = getAttributes(offsets.get(index));
- return findLocation("/" + mn + "/" + rn);
+ if (!ImageLocation.verify(module, name, attributes, stringsReader)) {
+ return null;
+ }
+ return new ImageLocation(attributes, stringsReader);
}
public synchronized ImageLocation findLocation(String name) {
Objects.requireNonNull(name);
// Details of the algorithm used here can be found in
// jdk.tools.jlink.internal.PerfectHashBuilder.
- byte[] bytes = ImageStringsReader.mutf8FromString(name);
int count = header.getTableLength();
- int index = redirect.get(ImageStringsReader.hashCode(bytes) % count);
+ int index = redirect.get(ImageStringsReader.hashCode(name) % count);
if (index < 0) {
// index is twos complement of location attributes index.
index = -index - 1;
} else if (index > 0) {
// index is hash seed needed to compute location attributes index.
- index = ImageStringsReader.hashCode(bytes, index) % count;
+ index = ImageStringsReader.hashCode(name, index) % count;
} else {
// No entry.
return null;
}
long[] attributes = getAttributes(offsets.get(index));
- ImageLocation imageLocation = new ImageLocation(attributes, stringsReader);
-
- if (!imageLocation.verify(name)) {
+ if (!ImageLocation.verify(name, attributes, stringsReader)) {
return null;
}
-
- return imageLocation;
+ return new ImageLocation(attributes, stringsReader);
}
public String[] getEntryNames() {
int[] attributeOffsets = new int[offsets.capacity()];
offsets.get(attributeOffsets);
< prev index next >