< prev index next >

test/jdk/internal/jimage/VerifyJimage.java

Print this page




 200             for (Path jimage: jimages) {
 201                 result.add(new JImageReader(jimage));
 202                 System.out.println("opened " + jimage);
 203             }
 204             return result;
 205         }
 206     }
 207 
 208     static class JImageReader extends BasicImageReader {
 209         final Path jimage;
 210         JImageReader(Path p) throws IOException {
 211             super(p.toString());
 212             this.jimage = p;
 213         }
 214 
 215         String imageName() {
 216             return jimage.getFileName().toString();
 217         }
 218 
 219         int entries() {
 220             return getHeader().getLocationCount();





 221         }
 222 
 223         void compare(String entry, Path p) {
 224             try {
 225                 byte[] bytes = Files.readAllBytes(p);
 226                 byte[] imagebytes = getResource(entry);
 227                 if (!Arrays.equals(bytes, imagebytes)) {
 228                     failed.add(imageName() + ": bytes differs than " + p.toString());
 229                 }
 230             } catch (IOException e) {
 231                 throw new UncheckedIOException(e);
 232             }
 233         }
 234     }
 235 }


 200             for (Path jimage: jimages) {
 201                 result.add(new JImageReader(jimage));
 202                 System.out.println("opened " + jimage);
 203             }
 204             return result;
 205         }
 206     }
 207 
 208     static class JImageReader extends BasicImageReader {
 209         final Path jimage;
 210         JImageReader(Path p) throws IOException {
 211             super(p.toString());
 212             this.jimage = p;
 213         }
 214 
 215         String imageName() {
 216             return jimage.getFileName().toString();
 217         }
 218 
 219         int entries() {
 220             try {
 221                 return getHeader().getTableLength();
 222             } catch (IOException ex) {
 223                 failed.add(imageName() + ": can't access header");
 224                 return 0;
 225             }
 226         }
 227 
 228         void compare(String entry, Path p) {
 229             try {
 230                 byte[] bytes = Files.readAllBytes(p);
 231                 byte[] imagebytes = getResource(entry);
 232                 if (!Arrays.equals(bytes, imagebytes)) {
 233                     failed.add(imageName() + ": bytes differs than " + p.toString());
 234                 }
 235             } catch (IOException e) {
 236                 throw new UncheckedIOException(e);
 237             }
 238         }
 239     }
 240 }
< prev index next >