/** Create a named field with the specified type. */
  ObjectStreamField(String n, Class<?> clazz) {
    name = n;
    this.clazz = clazz;

    // Compute the typecode for easy switching
    if (clazz.isPrimitive()) {
      if (clazz == Integer.TYPE) {
        type = 'I';
      } else if (clazz == Byte.TYPE) {
        type = 'B';
      } else if (clazz == Long.TYPE) {
        type = 'J';
      } else if (clazz == Float.TYPE) {
        type = 'F';
      } else if (clazz == Double.TYPE) {
        type = 'D';
      } else if (clazz == Short.TYPE) {
        type = 'S';
      } else if (clazz == Character.TYPE) {
        type = 'C';
      } else if (clazz == Boolean.TYPE) {
        type = 'Z';
      }
    } else if (clazz.isArray()) {
      type = '[';
      typeString = ObjectStreamClass.getSignature(clazz);
    } else {
      type = 'L';
      typeString = ObjectStreamClass.getSignature(clazz);
    }

    if (typeString != null) signature = typeString;
    else signature = String.valueOf(type);
  }