8066777: OptimisticTypesPersistence.java should use Files.readAllBytes instead of getting size and then read
authorsundar
Fri, 05 Dec 2014 20:17:51 +0530
changeset 27967 b6ffb73f6ca4
parent 27966 09c70b35a806
child 27968 52e31251a179
8066777: OptimisticTypesPersistence.java should use Files.readAllBytes instead of getting size and then read Reviewed-by: attila, lagergren Contributed-by: paul.sandoz@oracle.com
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java
--- 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);
                     }