changeset 1131:f2b8db166d11

8066777: OptimisticTypesPersistence.java should use Files.readAllBytes instead of getting size and then read Reviewed-by: attila, lagergren Contributed-by: paul.sandoz@oracle.com
author sundar
date Fri, 05 Dec 2014 20:17:51 +0530
parents 7fcaec1cf5ac
children 83951bd95ac2
files src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Fri Dec 05 19:01:26 2014 +0530
+++ b/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);
                     }