src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
changeset 55647 f60890de1dfb
parent 54955 46409371a691
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java	Wed Jul 10 08:20:41 2019 -0700
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java	Tue Jul 02 08:43:44 2019 -0700
@@ -1098,10 +1098,15 @@
     private void writeSymbol(Symbol sym) throws IOException {
         // If name is already written don't write it again.
         if (names.add(sym)) {
-            byte[] buf = sym.asString().getBytes("UTF-8");
-            writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE);
-            writeSymbolID(sym);
-            out.write(buf);
+            if(sym != null) {
+              byte[] buf = sym.asString().getBytes("UTF-8");
+              writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE);
+              writeSymbolID(sym);
+              out.write(buf);
+           } else {
+              writeHeader(HPROF_UTF8, 0 + OBJ_ID_SIZE);
+              writeSymbolID(null);
+           }
         }
     }
 
@@ -1152,7 +1157,8 @@
 
     private void writeSymbolID(Symbol sym) throws IOException {
         assert names.contains(sym);
-        writeObjectID(getAddressValue(sym.getAddress()));
+        long address = (sym != null) ? getAddressValue(sym.getAddress()) : getAddressValue(null);
+        writeObjectID(address);
     }
 
     private void writeObjectID(long address) throws IOException {