8066777: OptimisticTypesPersistence.java should use Files.readAllBytes instead of getting size and then read
Reviewed-by: attila, lagergren
Contributed-by: paul.sandoz@oracle.com
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java Fri Dec 05 19:01:26 2014 +0530
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java Fri Dec 05 20:17:51 2014 +0530
@@ -569,12 +569,8 @@
public void accept(Path p) {
// take only the .class resources.
if (Files.isRegularFile(p) && p.toString().endsWith(".class")) {
- try (final InputStream in = Files.newInputStream(p)) {
- // get actual (uncompressed) size from file attribute
- final int sz = ((Number)Files.getAttribute(p, "size")).intValue();
- final byte[] buf = new byte[sz];
- in.read(buf);
- digest.update(buf);
+ try {
+ digest.update(Files.readAllBytes(p));
} catch (final IOException ioe) {
throw new UncheckedIOException(ioe);
}