< prev index next >

src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java

Print this page
rev 14631 : 8156209: Add argument checks to BasicImageReader calls
Reviewed-by: sundar

*** 24,33 **** --- 24,34 ---- */ package jdk.internal.jimage; import java.nio.ByteBuffer; + import java.util.Objects; /** * @implNote This class needs to maintain JDK 8 source compatibility. * * It is used internally in the JDK to implement jimage/jrtfs access,
*** 48,57 **** --- 49,60 ---- protected final long[] attributes; protected final ImageStrings strings; public ImageLocation(long[] attributes, ImageStrings strings) { + Objects.requireNonNull(attributes); + Objects.requireNonNull(strings); this.attributes = attributes; this.strings = strings; } ImageStrings getStrings() {
*** 65,74 **** --- 68,78 ---- private static int attributeKind(int data) { return data >>> 3; } static long[] decompress(ByteBuffer bytes) { + Objects.requireNonNull(bytes); long[] attributes = new long[ATTRIBUTE_COUNT]; if (bytes != null) { while (bytes.hasRemaining()) { int data = bytes.get() & 0xFF;
*** 101,110 **** --- 105,115 ---- return attributes; } public static byte[] compress(long[] attributes) { + Objects.requireNonNull(attributes); ImageStream stream = new ImageStream(16); for (int kind = ATTRIBUTE_END + 1; kind < ATTRIBUTE_COUNT; kind++) { long value = attributes[kind];
*** 122,131 **** --- 127,138 ---- return stream.toArray(); } public boolean verify(String name) { + Objects.requireNonNull(name); + return name.equals(getFullName()); } long getAttribute(int kind) { if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
*** 248,257 **** --- 255,265 ---- public long getUncompressedSize() { return getAttribute(ATTRIBUTE_UNCOMPRESSED); } static ImageLocation readFrom(BasicImageReader reader, int offset) { + Objects.requireNonNull(reader); long[] attributes = reader.getAttributes(offset); ImageStringsReader strings = reader.getStrings(); return new ImageLocation(attributes, strings); }
< prev index next >