8190837: BasicType and BasicTypeSize should refer to HotSpot values
authorysuenaga
Fri, 01 Dec 2017 10:04:31 +0900
changeset 48175 babef393c286
parent 48174 0a52219cfb16
child 48176 59ebea050a0d
8190837: BasicType and BasicTypeSize should refer to HotSpot values Reviewed-by: dholmes, jgeorge
src/hotspot/share/runtime/vmStructs.cpp
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicType.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicTypeSize.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/PerfDataEntry.java
--- a/src/hotspot/share/runtime/vmStructs.cpp	Thu Nov 30 16:28:47 2017 -0800
+++ b/src/hotspot/share/runtime/vmStructs.cpp	Fri Dec 01 10:04:31 2017 +0900
@@ -2643,6 +2643,46 @@
   declare_constant(Deoptimization::_reason_shift)                         \
   declare_constant(Deoptimization::_debug_id_shift)                       \
                                                                           \
+  /******************************************/                            \
+  /* BasicType enum (globalDefinitions.hpp) */                            \
+  /******************************************/                            \
+                                                                          \
+  declare_constant(T_BOOLEAN)                                             \
+  declare_constant(T_CHAR)                                                \
+  declare_constant(T_FLOAT)                                               \
+  declare_constant(T_DOUBLE)                                              \
+  declare_constant(T_BYTE)                                                \
+  declare_constant(T_SHORT)                                               \
+  declare_constant(T_INT)                                                 \
+  declare_constant(T_LONG)                                                \
+  declare_constant(T_OBJECT)                                              \
+  declare_constant(T_ARRAY)                                               \
+  declare_constant(T_VOID)                                                \
+  declare_constant(T_ADDRESS)                                             \
+  declare_constant(T_NARROWOOP)                                           \
+  declare_constant(T_METADATA)                                            \
+  declare_constant(T_NARROWKLASS)                                         \
+  declare_constant(T_CONFLICT)                                            \
+  declare_constant(T_ILLEGAL)                                             \
+                                                                          \
+  /**********************************************/                        \
+  /* BasicTypeSize enum (globalDefinitions.hpp) */                        \
+  /**********************************************/                        \
+                                                                          \
+  declare_constant(T_BOOLEAN_size)                                        \
+  declare_constant(T_CHAR_size)                                           \
+  declare_constant(T_FLOAT_size)                                          \
+  declare_constant(T_DOUBLE_size)                                         \
+  declare_constant(T_BYTE_size)                                           \
+  declare_constant(T_SHORT_size)                                          \
+  declare_constant(T_INT_size)                                            \
+  declare_constant(T_LONG_size)                                           \
+  declare_constant(T_OBJECT_size)                                         \
+  declare_constant(T_ARRAY_size)                                          \
+  declare_constant(T_NARROWOOP_size)                                      \
+  declare_constant(T_NARROWKLASS_size)                                    \
+  declare_constant(T_VOID_size)                                           \
+                                                                          \
   /*********************/                                                 \
   /* Matcher (C2 only) */                                                 \
   /*********************/                                                 \
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicType.java	Thu Nov 30 16:28:47 2017 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicType.java	Fri Dec 01 10:04:31 2017 +0900
@@ -24,133 +24,159 @@
 
 package sun.jvm.hotspot.runtime;
 
+import java.util.Observer;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+
 /** Encapsulates the BasicType enum in globalDefinitions.hpp in the
     VM. */
 
 public class BasicType {
-  public static final int tBoolean     = 4;
-  public static final int tChar        = 5;
-  public static final int tFloat       = 6;
-  public static final int tDouble      = 7;
-  public static final int tByte        = 8;
-  public static final int tShort       = 9;
-  public static final int tInt         = 10;
-  public static final int tLong        = 11;
-  public static final int tObject      = 12;
-  public static final int tArray       = 13;
-  public static final int tVoid        = 14;
-  public static final int tAddress     = 15;
-  public static final int tNarrowOop   = 16;
-  public static final int tMetadata    = 17;
-  public static final int tNarrowKlass = 18;
-  public static final int tConflict    = 19;
-  public static final int tIllegal     = 99;
+  public static final BasicType T_BOOLEAN = new BasicType();
+  public static final BasicType T_CHAR = new BasicType();
+  public static final BasicType T_FLOAT = new BasicType();
+  public static final BasicType T_DOUBLE = new BasicType();
+  public static final BasicType T_BYTE = new BasicType();
+  public static final BasicType T_SHORT = new BasicType();
+  public static final BasicType T_INT = new BasicType();
+  public static final BasicType T_LONG = new BasicType();
+  public static final BasicType T_OBJECT = new BasicType();
+  public static final BasicType T_ARRAY = new BasicType();
+  public static final BasicType T_VOID = new BasicType();
+  public static final BasicType T_ADDRESS = new BasicType();
+  public static final BasicType T_NARROWOOP = new BasicType();
+  public static final BasicType T_METADATA = new BasicType();
+  public static final BasicType T_NARROWKLASS = new BasicType();
+  public static final BasicType T_CONFLICT = new BasicType();
+  public static final BasicType T_ILLEGAL = new BasicType();
 
-  public static final BasicType T_BOOLEAN = new BasicType(tBoolean);
-  public static final BasicType T_CHAR = new BasicType(tChar);
-  public static final BasicType T_FLOAT = new BasicType(tFloat);
-  public static final BasicType T_DOUBLE = new BasicType(tDouble);
-  public static final BasicType T_BYTE = new BasicType(tByte);
-  public static final BasicType T_SHORT = new BasicType(tShort);
-  public static final BasicType T_INT = new BasicType(tInt);
-  public static final BasicType T_LONG = new BasicType(tLong);
-  public static final BasicType T_OBJECT = new BasicType(tObject);
-  public static final BasicType T_ARRAY = new BasicType(tArray);
-  public static final BasicType T_VOID = new BasicType(tVoid);
-  public static final BasicType T_ADDRESS = new BasicType(tAddress);
-  public static final BasicType T_NARROWOOP = new BasicType(tNarrowOop);
-  public static final BasicType T_METADATA = new BasicType(tMetadata);
-  public static final BasicType T_NARROWKLASS = new BasicType(tNarrowKlass);
-  public static final BasicType T_CONFLICT = new BasicType(tConflict);
-  public static final BasicType T_ILLEGAL = new BasicType(tIllegal);
+  static {
+    VM.registerVMInitializedObserver(
+        (o, d) -> initialize(VM.getVM().getTypeDataBase()));
+  }
+
+  private static synchronized void initialize(TypeDataBase db) {
+    T_BOOLEAN.setType(db.lookupIntConstant("T_BOOLEAN").intValue());
+    T_CHAR.setType(db.lookupIntConstant("T_CHAR").intValue());
+    T_FLOAT.setType(db.lookupIntConstant("T_FLOAT").intValue());
+    T_DOUBLE.setType(db.lookupIntConstant("T_DOUBLE").intValue());
+    T_BYTE.setType(db.lookupIntConstant("T_BYTE").intValue());
+    T_SHORT.setType(db.lookupIntConstant("T_SHORT").intValue());
+    T_INT.setType(db.lookupIntConstant("T_INT").intValue());
+    T_LONG.setType(db.lookupIntConstant("T_LONG").intValue());
+    T_OBJECT.setType(db.lookupIntConstant("T_OBJECT").intValue());
+    T_ARRAY.setType(db.lookupIntConstant("T_ARRAY").intValue());
+    T_VOID.setType(db.lookupIntConstant("T_VOID").intValue());
+    T_ADDRESS.setType(db.lookupIntConstant("T_ADDRESS").intValue());
+    T_NARROWOOP.setType(db.lookupIntConstant("T_NARROWOOP").intValue());
+    T_METADATA.setType(db.lookupIntConstant("T_METADATA").intValue());
+    T_NARROWKLASS.setType(db.lookupIntConstant("T_NARROWKLASS").intValue());
+    T_CONFLICT.setType(db.lookupIntConstant("T_CONFLICT").intValue());
+    T_ILLEGAL.setType(db.lookupIntConstant("T_ILLEGAL").intValue());
+  }
 
   public static int getTBoolean() {
-    return tBoolean;
+    return T_BOOLEAN.getType();
   }
 
   public static int getTChar() {
-    return tChar;
+    return T_CHAR.getType();
   }
 
   public static int getTFloat() {
-    return tFloat;
+    return T_FLOAT.getType();
   }
 
   public static int getTDouble() {
-    return tDouble;
+    return T_DOUBLE.getType();
   }
 
   public static int getTByte() {
-    return tByte;
+    return T_BYTE.getType();
   }
 
   public static int getTShort() {
-    return tShort;
+    return T_SHORT.getType();
   }
 
   public static int getTInt() {
-    return tInt;
+    return T_INT.getType();
   }
 
   public static int getTLong() {
-    return tLong;
+    return T_LONG.getType();
   }
 
   public static int getTObject() {
-    return tObject;
+    return T_OBJECT.getType();
   }
 
   public static int getTArray() {
-    return tArray;
+    return T_ARRAY.getType();
   }
 
   public static int getTVoid() {
-    return tVoid;
+    return T_VOID.getType();
   }
 
   public static int getTAddress() {
-    return tAddress;
+    return T_ADDRESS.getType();
   }
 
   public static int getTNarrowOop() {
-    return tNarrowOop;
+    return T_NARROWOOP.getType();
   }
 
   public static int getTMetadata() {
-    return tMetadata;
+    return T_METADATA.getType();
   }
 
   public static int getTNarrowKlass() {
-    return tNarrowKlass;
+    return T_NARROWKLASS.getType();
   }
 
   /** For stack value type with conflicting contents */
   public static int getTConflict() {
-    return tConflict;
+    return T_CONFLICT.getType();
   }
 
   public static int getTIllegal() {
-    return tIllegal;
+    return T_ILLEGAL.getType();
   }
 
   public static BasicType intToBasicType(int i) {
-    switch(i) {
-      case tBoolean:     return T_BOOLEAN;
-      case tChar:        return T_CHAR;
-      case tFloat:       return T_FLOAT;
-      case tDouble:      return T_DOUBLE;
-      case tByte:        return T_BYTE;
-      case tShort:       return T_SHORT;
-      case tInt:         return T_INT;
-      case tLong:        return T_LONG;
-      case tObject:      return T_OBJECT;
-      case tArray:       return T_ARRAY;
-      case tVoid:        return T_VOID;
-      case tAddress:     return T_ADDRESS;
-      case tNarrowOop:   return T_NARROWOOP;
-      case tMetadata:    return T_METADATA;
-      case tNarrowKlass: return T_NARROWKLASS;
-      default:           return T_ILLEGAL;
+    if (i == T_BOOLEAN.getType()) {
+      return T_BOOLEAN;
+    } else if (i == T_CHAR.getType()) {
+      return T_CHAR;
+    } else if (i == T_FLOAT.getType()) {
+      return T_FLOAT;
+    } else if (i == T_DOUBLE.getType()) {
+      return T_DOUBLE;
+    } else if (i == T_BYTE.getType()) {
+      return T_BYTE;
+    } else if (i == T_SHORT.getType()) {
+      return T_SHORT;
+    } else if (i == T_INT.getType()) {
+      return T_INT;
+    } else if (i == T_LONG.getType()) {
+      return T_LONG;
+    } else if (i == T_OBJECT.getType()) {
+      return T_OBJECT;
+    } else if (i == T_ARRAY.getType()) {
+      return T_ARRAY;
+    } else if (i == T_VOID.getType()) {
+      return T_VOID;
+    } else if (i == T_ADDRESS.getType()) {
+      return T_ADDRESS;
+    } else if (i == T_NARROWOOP.getType()) {
+      return T_NARROWOOP;
+    } else if (i == T_METADATA.getType()) {
+      return T_METADATA;
+    } else if (i == T_NARROWKLASS.getType()) {
+      return T_NARROWKLASS;
+    } else {
+      return T_ILLEGAL;
     }
   }
 
@@ -180,29 +206,48 @@
   }
 
   public String getName() {
-    switch (type) {
-      case tBoolean:     return "boolean";
-      case tChar:        return "char";
-      case tFloat:       return "float";
-      case tDouble:      return "double";
-      case tByte:        return "byte";
-      case tShort:       return "short";
-      case tInt:         return "int";
-      case tLong:        return "long";
-      case tObject:      return "object";
-      case tArray:       return "array";
-      case tVoid:        return "void";
-      case tAddress:     return "address";
-      case tNarrowOop:   return "narrow oop";
-      case tMetadata:    return "metadata";
-      case tNarrowKlass: return "narrow klass";
-      case tConflict:    return "conflict";
-      default:           return "ILLEGAL TYPE";
+    if (type == T_BOOLEAN.getType()) {
+      return "boolean";
+    } else if (type == T_CHAR.getType()) {
+      return "char";
+    } else if (type == T_FLOAT.getType()) {
+      return "float";
+    } else if (type == T_DOUBLE.getType()) {
+      return "double";
+    } else if (type == T_BYTE.getType()) {
+      return "byte";
+    } else if (type == T_SHORT.getType()) {
+      return "short";
+    } else if (type == T_INT.getType()) {
+      return "int";
+    } else if (type == T_LONG.getType()) {
+      return "long";
+    } else if (type == T_OBJECT.getType()) {
+      return "object";
+    } else if (type == T_ARRAY.getType()) {
+      return "array";
+    } else if (type == T_VOID.getType()) {
+      return "void";
+    } else if (type == T_ADDRESS.getType()) {
+      return "address";
+    } else if (type == T_NARROWOOP.getType()) {
+      return "narrow oop";
+    } else if (type == T_METADATA.getType()) {
+      return "metadata";
+    } else if (type == T_NARROWKLASS.getType()) {
+      return "narrow klass";
+    } else if (type == T_CONFLICT.getType()) {
+      return "conflict";
+    } else {
+      return "ILLEGAL TYPE";
     }
   }
 
   //-- Internals only below this point
-  private BasicType(int type) {
+  private BasicType() {
+  }
+
+  private void setType(int type) {
     this.type = type;
   }
 
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicTypeSize.java	Thu Nov 30 16:28:47 2017 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/BasicTypeSize.java	Fri Dec 01 10:04:31 2017 +0900
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -24,22 +24,48 @@
 
 package sun.jvm.hotspot.runtime;
 
+import java.util.Observer;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+
 /** Encapsulates the BasicTypeSize enum in globalDefinitions.hpp in
     the VM. */
 
 public class BasicTypeSize {
-  private static boolean initialized = false;
-  private static int tBooleanSize = 1;
-  private static int tCharSize    = 1;
-  private static int tFloatSize   = 1;
-  private static int tDoubleSize  = 2;
-  private static int tByteSize    = 1;
-  private static int tShortSize   = 1;
-  private static int tIntSize     = 1;
-  private static int tLongSize    = 2;
-  private static int tObjectSize  = 1;
-  private static int tArraySize   = 1;
-  private static int tVoidSize    = 0;
+  private static int tBooleanSize;
+  private static int tCharSize;
+  private static int tFloatSize;
+  private static int tDoubleSize;
+  private static int tByteSize;
+  private static int tShortSize;
+  private static int tIntSize;
+  private static int tLongSize;
+  private static int tObjectSize;
+  private static int tArraySize;
+  private static int tNarrowOopSize;
+  private static int tNarrowKlassSize;
+  private static int tVoidSize;
+
+  static {
+    VM.registerVMInitializedObserver(
+        (o, d) -> initialize(VM.getVM().getTypeDataBase()));
+  }
+
+  private static synchronized void initialize(TypeDataBase db) {
+    tBooleanSize     = db.lookupIntConstant("T_BOOLEAN_size").intValue();
+    tCharSize        = db.lookupIntConstant("T_INT_size").intValue();
+    tFloatSize       = db.lookupIntConstant("T_FLOAT_size").intValue();
+    tDoubleSize      = db.lookupIntConstant("T_DOUBLE_size").intValue();
+    tByteSize        = db.lookupIntConstant("T_BYTE_size").intValue();
+    tShortSize       = db.lookupIntConstant("T_SHORT_size").intValue();
+    tIntSize         = db.lookupIntConstant("T_INT_size").intValue();
+    tLongSize        = db.lookupIntConstant("T_LONG_size").intValue();
+    tObjectSize      = db.lookupIntConstant("T_OBJECT_size").intValue();
+    tArraySize       = db.lookupIntConstant("T_ARRAY_size").intValue();
+    tNarrowOopSize   = db.lookupIntConstant("T_NARROWOOP_size").intValue();
+    tNarrowKlassSize = db.lookupIntConstant("T_NARROWKLASS_size").intValue();
+    tVoidSize        = db.lookupIntConstant("T_VOID_size").intValue();
+  }
 
   public static int getTBooleanSize() {
     return tBooleanSize;
@@ -81,6 +107,14 @@
     return tArraySize;
   }
 
+  public static int getTNarrowOopSize() {
+    return tNarrowOopSize;
+  }
+
+  public static int getTNarrowKlassSize() {
+    return tNarrowKlassSize;
+  }
+
   public static int getTVoidSize() {
     return tVoidSize;
   }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/PerfDataEntry.java	Thu Nov 30 16:28:47 2017 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/PerfDataEntry.java	Fri Dec 01 10:04:31 2017 +0900
@@ -139,7 +139,7 @@
     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());
     }
@@ -147,7 +147,7 @@
     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());
     }
@@ -155,7 +155,7 @@
     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());
 
@@ -164,7 +164,7 @@
     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());
     }
@@ -172,7 +172,7 @@
     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());
     }
@@ -180,7 +180,7 @@
     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());
     }
@@ -188,7 +188,7 @@
     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());
     }
@@ -196,7 +196,7 @@
     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());
     }
@@ -205,7 +205,7 @@
         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();
@@ -220,7 +220,7 @@
         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();
@@ -235,7 +235,7 @@
         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();
@@ -250,7 +250,7 @@
         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();
@@ -265,7 +265,7 @@
         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();
@@ -280,7 +280,7 @@
         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();
@@ -295,7 +295,7 @@
         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();
@@ -310,7 +310,7 @@
         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();
@@ -327,38 +327,27 @@
         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('[');
@@ -368,26 +357,17 @@
                 }
                 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('[');
@@ -397,10 +377,7 @@
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tInt: {
+            } else if (dataType ==  BasicType.getTInt()) {
                 int[] res = intArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
@@ -410,10 +387,7 @@
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tLong: {
+            } else if (dataType == BasicType.getTLong()) {
                 long[] res = longArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
@@ -423,10 +397,7 @@
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tFloat: {
+            } else if (dataType == BasicType.getTFloat()) {
                 float[] res = floatArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
@@ -436,10 +407,7 @@
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            case BasicType.tDouble: {
+            } else if (dataType == BasicType.getTDouble()) {
                 double[] res = doubleArrayValue();
                 StringBuffer buf = new StringBuffer();
                 buf.append('[');
@@ -449,12 +417,8 @@
                 }
                 buf.append(']');
                 str = buf.toString();
-                break;
-            }
-
-            default:
+            } else {
                 str = "<unknown vector value>";
-                break;
             }
         }