src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java
changeset 53013 c8b2a408628b
parent 52981 4eff16f47ae2
child 53142 5c0ec35d0533
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java	Thu Dec 13 10:25:50 2018 +0100
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java	Thu Dec 13 14:21:04 2018 +0100
@@ -315,11 +315,7 @@
             printArray((Object[]) value);
             return;
         }
-        if (field.getContentType() != null) {
-            if (printFormatted(field, value)) {
-                return;
-            }
-        }
+
         if (value instanceof Double) {
             Double d = (Double) value;
             if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY) {
@@ -349,6 +345,12 @@
             }
         }
 
+        if (field.getContentType() != null) {
+            if (printFormatted(field, value)) {
+                return;
+            }
+        }
+
         String text = String.valueOf(value);
         if (value instanceof String) {
             text = "\"" + text + "\"";
@@ -472,7 +474,7 @@
     private boolean printFormatted(ValueDescriptor field, Object value) {
         if (value instanceof Duration) {
             Duration d = (Duration) value;
-            if (d.getSeconds() == Long.MIN_VALUE)  {
+            if (d.getSeconds() == Long.MIN_VALUE && d.getNano() == 0)  {
                 println("N/A");
                 return true;
             }
@@ -513,12 +515,26 @@
         if (dataAmount != null) {
             if (value instanceof Number) {
                 Number n = (Number) value;
-                String bytes = Utils.formatBytes(n.longValue(), " ");
+                long amount = n.longValue();
                 if (field.getAnnotation(Frequency.class) != null) {
-                    bytes += "/s";
+                    if (dataAmount.value().equals(DataAmount.BYTES)) {
+                        println(Utils.formatBytesPerSecond(amount));
+                        return true;
+                    }
+                    if (dataAmount.value().equals(DataAmount.BITS)) {
+                        println(Utils.formatBitsPerSecond(amount));
+                        return true;
+                    }
+                } else {
+                    if (dataAmount.value().equals(DataAmount.BYTES)) {
+                        println(Utils.formatBytes(amount));
+                        return true;
+                    }
+                    if (dataAmount.value().equals(DataAmount.BITS)) {
+                        println(Utils.formatBits(amount));
+                        return true;
+                    }
                 }
-                println(bytes);
-                return true;
             }
         }
         MemoryAddress memoryAddress = field.getAnnotation(MemoryAddress.class);
@@ -529,6 +545,14 @@
                 return true;
             }
         }
+        Frequency frequency = field.getAnnotation(Frequency.class);
+        if (frequency != null) {
+            if (value instanceof Number) {
+                println(value + " Hz");
+                return true;
+            }
+        }
+
         return false;
     }