changeset 521:dc604a6da888

6614052: jhat fails to read heap dump > 2GB. Summary: Modified the jhat code to use long for unsigned int. This is a forward port of changes from Kevin Walls. Reviewed-by: jjh
author swamyv
date Fri, 29 Aug 2008 14:33:05 -0700
parents 5d278726f0dc
children ad45ffa62646 f9cf71f806eb
files src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java	Fri Aug 29 17:46:45 2008 +0100
+++ b/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java	Fri Aug 29 14:33:05 2008 -0700
@@ -120,7 +120,7 @@
     private int version;        // The version of .hprof being read
 
     private int debugLevel;
-    private int currPos;        // Current position in the file
+    private long currPos;        // Current position in the file
 
     private int dumpsToSkip;
     private boolean callStack;  // If true, read the call stack of objects
@@ -196,7 +196,9 @@
                 break;
             }
             in.readInt();       // Timestamp of this record
-            int length = in.readInt();
+            // Length of record: readInt() will return negative value for record
+            // length >2GB.  so store 32bit value in long to keep it unsigned.
+            long length = in.readInt() & 0xffffffffL;
             if (debugLevel > 0) {
                 System.out.println("Read record type " + type
                                    + ", length " + length
@@ -211,7 +213,7 @@
             switch (type) {
                 case HPROF_UTF8: {
                     long id = readID();
-                    byte[] chars = new byte[length - identifierSize];
+                    byte[] chars = new byte[(int)length - identifierSize];
                     in.readFully(chars);
                     names.put(new Long(id), new String(chars));
                     break;
@@ -351,8 +353,8 @@
         return snapshot;
     }
 
-    private void skipBytes(int length) throws IOException {
-        in.skipBytes(length);
+    private void skipBytes(long length) throws IOException {
+        in.skipBytes((int)length);
     }
 
     private int readVersionHeader() throws IOException {
@@ -381,7 +383,7 @@
         throw new IOException("Version string not recognized at byte " + (pos+3));
     }
 
-    private void readHeapDump(int bytesLeft, int posAtEnd) throws IOException {
+    private void readHeapDump(long bytesLeft, long posAtEnd) throws IOException {
         while (bytesLeft > 0) {
             int type = in.readUnsignedByte();
             if (debugLevel > 0) {