Beispiel #1
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    String nl = String.format("%n");
    String nlIndent = String.format("%n%38s", "");
    if (hasNormalData()) {
      int pos = 0;
      HotSpotMethodDataAccessor data;
      while ((data = getNormalData(pos)) != null) {
        if (pos != 0) {
          sb.append(nl);
        }
        int bci = data.getBCI(this, pos);
        sb.append(String.format("%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName()));
        sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent));
        pos = pos + data.getSize(this, pos);
      }
    }

    if (hasExtraData()) {
      int pos = getExtraDataBeginOffset();
      HotSpotMethodDataAccessor data;
      while ((data = getExtraData(pos)) != null) {
        if (pos == getExtraDataBeginOffset()) {
          sb.append(nl).append("--- Extra data:");
        }
        int bci = data.getBCI(this, pos);
        sb.append(
            String.format("%n%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName()));
        sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent));
        pos = pos + data.getSize(this, pos);
      }
    }
    return sb.toString();
  }
Beispiel #2
0
 /**
  * Returns a string representation of the given collection of objects.
  *
  * @param objects The {@link Iterable} that will be used to iterate over the objects.
  * @return A string of the format "[a, b, ...]".
  */
 public static String toString(Iterable<?> objects) {
   StringBuilder str = new StringBuilder();
   str.append("[");
   for (Object o : objects) {
     str.append(o).append(", ");
   }
   if (str.length() > 1) {
     str.setLength(str.length() - 2);
   }
   str.append("]");
   return str.toString();
 }