232
233 public ByteOrder getByteOrder() {
234 return byteOrder;
235 }
236
237 public Path getImagePath() {
238 return imagePath;
239 }
240
241 @Override
242 public void close() throws IOException {
243 if (channel != null) {
244 channel.close();
245 }
246 }
247
248 public ImageStringsReader getStrings() {
249 return stringsReader;
250 }
251
252 public ImageLocation findLocation(String mn, String rn) {
253 Objects.requireNonNull(mn);
254 Objects.requireNonNull(rn);
255
256 return findLocation("/" + mn + "/" + rn);
257 }
258
259 public synchronized ImageLocation findLocation(String name) {
260 Objects.requireNonNull(name);
261 // Details of the algorithm used here can be found in
262 // jdk.tools.jlink.internal.PerfectHashBuilder.
263 int count = header.getTableLength();
264 int index = redirect.get(ImageStringsReader.hashCode(name) % count);
265
266 if (index < 0) {
267 // index is twos complement of location attributes index.
268 index = -index - 1;
269 } else if (index > 0) {
270 // index is hash seed needed to compute location attributes index.
271 index = ImageStringsReader.hashCode(name, index) % count;
272 } else {
273 // No entry.
274 return null;
275 }
276
|
232
233 public ByteOrder getByteOrder() {
234 return byteOrder;
235 }
236
237 public Path getImagePath() {
238 return imagePath;
239 }
240
241 @Override
242 public void close() throws IOException {
243 if (channel != null) {
244 channel.close();
245 }
246 }
247
248 public ImageStringsReader getStrings() {
249 return stringsReader;
250 }
251
252 public synchronized ImageLocation findLocation(String module, String name) {
253 Objects.requireNonNull(module);
254 Objects.requireNonNull(name);
255 // Details of the algorithm used here can be found in
256 // jdk.tools.jlink.internal.PerfectHashBuilder.
257 int count = header.getTableLength();
258 int index = redirect.get(ImageStringsReader.hashCode(module, name) % count);
259
260 if (index < 0) {
261 // index is twos complement of location attributes index.
262 index = -index - 1;
263 } else if (index > 0) {
264 // index is hash seed needed to compute location attributes index.
265 index = ImageStringsReader.hashCode(module, name, index) % count;
266 } else {
267 // No entry.
268 return null;
269 }
270
271 long[] attributes = getAttributes(offsets.get(index));
272
273 if (!ImageLocation.verify(module, name, attributes, stringsReader)) {
274 return null;
275 }
276 return new ImageLocation(attributes, stringsReader);
277 }
278
279 public synchronized ImageLocation findLocation(String name) {
280 Objects.requireNonNull(name);
281 // Details of the algorithm used here can be found in
282 // jdk.tools.jlink.internal.PerfectHashBuilder.
283 int count = header.getTableLength();
284 int index = redirect.get(ImageStringsReader.hashCode(name) % count);
285
286 if (index < 0) {
287 // index is twos complement of location attributes index.
288 index = -index - 1;
289 } else if (index > 0) {
290 // index is hash seed needed to compute location attributes index.
291 index = ImageStringsReader.hashCode(name, index) % count;
292 } else {
293 // No entry.
294 return null;
295 }
296
|