< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/PerfDataEntry.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -129,77 +129,77 @@
     }
 
     public boolean booleanValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tBoolean, "not a boolean");
+                        dataType() == BasicType.getTBoolean(), "not a boolean");
         }
         return addr.getJBooleanAt(dataOffset());
     }
 
     public char charValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tChar, "not a char");
+                        dataType() == BasicType.getTChar(), "not a char");
         }
         return addr.getJCharAt(dataOffset());
     }
 
     public byte byteValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tByte, "not a byte");
+                        dataType() == BasicType.getTByte(), "not a byte");
         }
         return addr.getJByteAt(dataOffset());
 
     }
 
     public short shortValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tShort, "not a short");
+                        dataType() == BasicType.getTShort(), "not a short");
         }
         return addr.getJShortAt(dataOffset());
     }
 
     public int intValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tInt, "not an int");
+                        dataType() == BasicType.getTInt(), "not an int");
         }
         return addr.getJIntAt(dataOffset());
     }
 
     public long longValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tLong, "not a long");
+                        dataType() == BasicType.getTLong(), "not a long");
         }
         return addr.getJLongAt(dataOffset());
     }
 
     public float floatValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tFloat, "not a float");
+                        dataType() == BasicType.getTFloat(), "not a float");
         }
         return addr.getJFloatAt(dataOffset());
     }
 
     public double doubleValue() {
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(vectorLength() == 0 &&
-                        dataType() == BasicType.tDouble, "not a double");
+                        dataType() == BasicType.getTDouble(), "not a double");
         }
         return addr.getJDoubleAt(dataOffset());
     }
 
     public boolean[] booleanArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tBoolean, "not a boolean vector");
+                        dataType() == BasicType.getTBoolean(), "not a boolean vector");
         }
         boolean[] res = new boolean[len];
         final int off = dataOffset();
         final long size =  getHeap().getBooleanSize();
         for (int i = 0; i < len; i++) {

@@ -210,11 +210,11 @@
 
     public char[] charArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tChar, "not a char vector");
+                        dataType() == BasicType.getTChar(), "not a char vector");
         }
         char[] res = new char[len];
         final int off = dataOffset();
         final long size = getHeap().getCharSize();
         for (int i = 0; i < len; i++) {

@@ -225,11 +225,11 @@
 
     public byte[] byteArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tByte, "not a byte vector");
+                        dataType() == BasicType.getTByte(), "not a byte vector");
         }
         byte[] res = new byte[len];
         final int off = dataOffset();
         final long size = getHeap().getByteSize();
         for (int i = 0; i < len; i++) {

@@ -240,11 +240,11 @@
 
     public short[] shortArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tShort, "not a short vector");
+                        dataType() == BasicType.getTShort(), "not a short vector");
         }
         short[] res = new short[len];
         final int off = dataOffset();
         final long size = getHeap().getShortSize();
         for (int i = 0; i < len; i++) {

@@ -255,11 +255,11 @@
 
     public int[] intArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tInt, "not an int vector");
+                        dataType() == BasicType.getTInt(), "not an int vector");
         }
         int[] res = new int[len];
         final int off = dataOffset();
         final long size = getHeap().getIntSize();
         for (int i = 0; i < len; i++) {

@@ -270,11 +270,11 @@
 
     public long[] longArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tLong, "not a long vector");
+                        dataType() == BasicType.getTLong(), "not a long vector");
         }
         long[] res = new long[len];
         final int off = dataOffset();
         final long size = getHeap().getLongSize();
         for (int i = 0; i < len; i++) {

@@ -285,11 +285,11 @@
 
     public float[] floatArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tFloat, "not a float vector");
+                        dataType() == BasicType.getTFloat(), "not a float vector");
         }
         float[] res = new float[len];
         final int off = dataOffset();
         final long size = getHeap().getFloatSize();
         for (int i = 0; i < len; i++) {

@@ -300,11 +300,11 @@
 
     public double[] doubleArrayValue() {
         int len = vectorLength();
         if (Assert.ASSERTS_ENABLED) {
             Assert.that(len > 0 &&
-                        dataType() == BasicType.tDouble, "not a double vector");
+                        dataType() == BasicType.getTDouble(), "not a double vector");
         }
         double[] res = new double[len];
         final int off = dataOffset();
         final long size = getHeap().getDoubleSize();
         for (int i = 0; i < len; i++) {

@@ -317,138 +317,102 @@
     public String valueAsString() {
         int dataType = dataType();
         int len = vectorLength();
         String str = null;
         if (len == 0) { // scalar
-            switch (dataType) {
-            case BasicType.tBoolean:
+            if (dataType == BasicType.getTBoolean()) {
                 str = Boolean.toString(booleanValue());
-                break;
-            case BasicType.tChar:
+            } else if (dataType == BasicType.getTChar()) {
                 str = "'" + Character.toString(charValue()) + "'";
-                break;
-            case BasicType.tByte:
+            } else if (dataType == BasicType.getTByte()) {
                 str = Byte.toString(byteValue());
-                break;
-            case BasicType.tShort:
+            } else if (dataType == BasicType.getTShort()) {
                 str = Short.toString(shortValue());
-                break;
-            case BasicType.tInt:
+            } else if (dataType ==  BasicType.getTInt()) {
                 str = Integer.toString(intValue());
-                break;
-            case BasicType.tLong:
+            } else if (dataType == BasicType.getTLong()) {
                 str = Long.toString(longValue());
-                break;
-            case BasicType.tFloat:
+            } else if (dataType == BasicType.getTFloat()) {
                 str = Float.toString(floatValue());
-                break;
-            case BasicType.tDouble:
+            } else if (dataType == BasicType.getTDouble()) {
                 str = Double.toString(doubleValue());
-                break;
-            default:
+            } else {
                 str = "<unknown scalar value>";
-                break;
             }
         } else { // vector
-            switch (dataType) {
-            case BasicType.tBoolean: {
+            if (dataType == BasicType.getTBoolean()) {
                 boolean[] res = booleanArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
                     buf.append(Boolean.toString(res[i]));
                     buf.append(", ");
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tChar: {
+            } else if (dataType == BasicType.getTChar()) {
                 // char[] is returned as a String
                 str = new String(charArrayValue());
-                break;
-            }
-
-            case BasicType.tByte: {
+            } else if (dataType == BasicType.getTByte()) {
                 // byte[] is returned as a String
                 try {
                     str = new String(byteArrayValue(), "US-ASCII");
                 } catch (java.io.UnsupportedEncodingException e) {
                     str = "can't decode string : " + e.getMessage();
                 }
-                break;
-            }
-
-            case BasicType.tShort: {
+            } else if (dataType == BasicType.getTShort()) {
                 short[] res = shortArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
                     buf.append(Short.toString(res[i]));
                     buf.append(", ");
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tInt: {
+            } else if (dataType ==  BasicType.getTInt()) {
                 int[] res = intArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
                     buf.append(Integer.toString(res[i]));
                     buf.append(", ");
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tLong: {
+            } else if (dataType == BasicType.getTLong()) {
                 long[] res = longArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
                     buf.append(Long.toString(res[i]));
                     buf.append(", ");
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tFloat: {
+            } else if (dataType == BasicType.getTFloat()) {
                 float[] res = floatArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
                     buf.append(Float.toString(res[i]));
                     buf.append(", ");
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tDouble: {
+            } else if (dataType == BasicType.getTDouble()) {
                 double[] res = doubleArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
                 for (int i = 0; i < res.length; i++) {
                     buf.append(Double.toString(res[i]));
                     buf.append(", ");
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            default:
+            } else {
                 str = "<unknown vector value>";
-                break;
             }
         }
 
         // add units
         switch (dataUnits()) {
< prev index next >