示例#1
0
  private static String formatAccessFlags(AccessFlags[] accessFlags) {
    int size = 0;
    for (AccessFlags accessFlag : accessFlags) {
      size += accessFlag.toString().length() + 1;
    }

    StringBuilder sb = new StringBuilder(size);
    for (AccessFlags accessFlag : accessFlags) {
      sb.append(accessFlag.toString());
      sb.append(" ");
    }
    if (accessFlags.length > 0) {
      sb.delete(sb.length() - 1, sb.length());
    }
    return sb.toString();
  }
示例#2
0
  static {
    allFlags = AccessFlags.values();

    accessFlagsByName = new HashMap<String, AccessFlags>();
    for (AccessFlags accessFlag : allFlags) {
      accessFlagsByName.put(accessFlag.accessFlagName, accessFlag);
    }
  }
示例#3
0
    /**
     * Writes the <code>EncodedField</code> to the given <code>AnnotatedOutput</code> object
     *
     * @param out the <code>AnnotatedOutput</code> object to write to
     * @param previousEncodedField The previous <code>EncodedField</code> in the list containing
     *     this <code>EncodedField</code>.
     */
    private void writeTo(AnnotatedOutput out, EncodedField previousEncodedField) {
      int previousIndex = previousEncodedField == null ? 0 : previousEncodedField.field.getIndex();

      if (out.annotates()) {
        out.annotate("field: " + field.getFieldString());
        out.writeUnsignedLeb128(field.getIndex() - previousIndex);
        out.annotate("access_flags: " + AccessFlags.formatAccessFlagsForField(accessFlags));
        out.writeUnsignedLeb128(accessFlags);
      } else {
        out.writeUnsignedLeb128(field.getIndex() - previousIndex);
        out.writeUnsignedLeb128(accessFlags);
      }
    }
示例#4
0
    /**
     * Writes the <code>EncodedMethod</code> to the given <code>AnnotatedOutput</code> object
     *
     * @param out the <code>AnnotatedOutput</code> object to write to
     * @param previousEncodedMethod The previous <code>EncodedMethod</code> in the list containing
     *     this <code>EncodedMethod</code>.
     */
    private void writeTo(AnnotatedOutput out, EncodedMethod previousEncodedMethod) {
      int previousIndex =
          previousEncodedMethod == null ? 0 : previousEncodedMethod.method.getIndex();

      if (out.annotates()) {
        out.annotate("method: " + method.getMethodString());
        out.writeUnsignedLeb128(method.getIndex() - previousIndex);
        out.annotate("access_flags: " + AccessFlags.formatAccessFlagsForMethod(accessFlags));
        out.writeUnsignedLeb128(accessFlags);
        if (codeItem != null) {
          out.annotate("code_off: 0x" + Integer.toHexString(codeItem.getOffset()));
          out.writeUnsignedLeb128(codeItem.getOffset());
        } else {
          out.annotate("code_off: 0x0");
          out.writeUnsignedLeb128(0);
        }
      } else {
        out.writeUnsignedLeb128(method.getIndex() - previousIndex);
        out.writeUnsignedLeb128(accessFlags);
        out.writeUnsignedLeb128(codeItem == null ? 0 : codeItem.getOffset());
      }
    }