/** * Shorten long class names, <em>java/lang/String</em> becomes * <em>String</em>. * * @param str The long class name * @return Compacted class name */ public static final String compactClassName( String str ) { return compactClassName(str, true); }
/** * Convert bit field of flags into string such as `static final'. * * @param access_flags Access flags * @return String representation of flags */ public static final String accessToString( int access_flags ) { return accessToString(access_flags, false); }
/** Convert bytes into hexadecimal string * * @param bytes an array of bytes to convert to hexadecimal * * @return bytes as hexadecimal string, e.g. 00 FA 12 ... */ public static final String toHexString( byte[] bytes ) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { short b = byteToShort(bytes[i]); String hex = Integer.toString(b, 0x10); if (b < 0x10) { buf.append('0'); } buf.append(hex); if (i < bytes.length - 1) { buf.append(' '); } } return buf.toString(); }
wrap(consumed_chars, 1); // This is the default, read just one char like `B' try { switch (signature.charAt(0)) { wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed return compactClassName(signature.substring(1, index), chopit); type = signatureToString(signature.substring(n), chopit); int _temp = unwrap(Utility.consumed_chars) + consumed_chars; wrap(Utility.consumed_chars, _temp); return type + brackets.toString();
String access = Utility.accessToString(access_flags, true); access = access.equals("") ? "" : (access + " "); StringBuilder buf = new StringBuilder(128); buf.append(access).append(Utility.classOrInterface(access_flags)).append(" ").append( class_name).append(" extends ").append( Utility.compactClassName(superclass_name, false)).append('\n'); int size = interfaces.length; if (size > 0) {
/** * @return Resolved string representation */ public final String toString( ConstantPool constant_pool ) { String inner_class_name, outer_class_name, inner_name, access; inner_class_name = constant_pool.getConstantString(inner_class_index, Constants.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name); if (outer_class_index != 0) { outer_class_name = constant_pool.getConstantString(outer_class_index, Constants.CONSTANT_Class); outer_class_name = Utility.compactClassName(outer_class_name); } else { outer_class_name = "<not a member>"; } if (inner_name_index != 0) { inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes(); } else { inner_name = "<anonymous>"; } access = Utility.accessToString(inner_access_flags, true); access = access.equals("") ? "" : (access + " "); return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \"" + inner_name + "\")"; }
/** * Return string representation close to declaration format, * `public static final short MAX = 100', e.g.. * * @return String representation of field, including the signature. */ @Override public final String toString() { String name, signature, access; // Short cuts to constant pool // Get names from constant pool access = Utility.accessToString(access_flags); access = access.equals("") ? "" : (access + " "); signature = Utility.signatureToString(getSignature()); name = getName(); StringBuffer buf = new StringBuffer(64); buf.append(access).append(signature).append(" ").append(name); ConstantValue cv = getConstantValue(); if (cv != null) { buf.append(" = ").append(cv); } for (int i = 0; i < attributes_count; i++) { Attribute a = attributes[i]; if (!(a instanceof ConstantValue)) { buf.append(" [").append(a.toString()).append("]"); } } return buf.toString(); }
access = Utility.accessToString(access_flags); c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable()); buf = new StringBuilder(signature);
try { for (int i = 0; i < index; i++) { codeToString(stream, constant_pool, verbose); String indices = fillup(stream.getIndex() + ":", 6, true, ' '); buf.append(indices).append(codeToString(stream, constant_pool, verbose)) .append('\n');
/** * @return String representation */ @Override public final String toString() { return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")"; } }
/** * @return String representation of code chunk. */ public final String toString( boolean verbose ) { StringBuilder buf = new StringBuilder(100); buf.append("Code(max_stack = ").append(max_stack).append(", max_locals = ").append( max_locals).append(", code_length = ").append(code_length).append(")\n").append( Utility.codeToString(code, constant_pool, 0, -1, verbose)); if (exception_table_length > 0) { buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n"); for (int i = 0; i < exception_table_length; i++) { buf.append(exception_table[i].toString(constant_pool, verbose)).append("\n"); } } if (attributes_count > 0) { buf.append("\nAttribute(s) = \n"); for (int i = 0; i < attributes_count; i++) { buf.append(attributes[i].toString()).append("\n"); } } return buf.toString(); }
int p = 0; for (int i = 0; p < Constants.MAX_ACC_FLAG; i++) { // Loop through known flags p = pow2(i); if ((access_flags & p) != 0) {
i = ((ConstantString) c).getStringIndex(); c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8); buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\""; break; default:
wrap(consumed_chars, 1); // This is the default, read just one char like `B' try { switch (signature.charAt(0)) { wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed return compactClassName(signature.substring(1, index), chopit); type = signatureToString(signature.substring(n), chopit); int _temp = unwrap(Utility.consumed_chars) + consumed_chars; wrap(Utility.consumed_chars, _temp); return type + brackets.toString();
String access = Utility.accessToString(access_flags, true); access = access.equals("") ? "" : (access + " "); StringBuffer buf = new StringBuffer(128); buf.append(access).append(Utility.classOrInterface(access_flags)).append(" ").append( class_name).append(" extends ").append( Utility.compactClassName(superclass_name, false)).append('\n'); int size = interfaces.length; if (size > 0) {
/** * @return Resolved string representation */ public final String toString( ConstantPool constant_pool ) { String inner_class_name, outer_class_name, inner_name, access; inner_class_name = constant_pool.getConstantString(inner_class_index, Constants.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name); if (outer_class_index != 0) { outer_class_name = constant_pool.getConstantString(outer_class_index, Constants.CONSTANT_Class); outer_class_name = Utility.compactClassName(outer_class_name); } else { outer_class_name = "<not a member>"; } if (inner_name_index != 0) { inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes(); } else { inner_name = "<anonymous>"; } access = Utility.accessToString(inner_access_flags, true); access = access.equals("") ? "" : (access + " "); return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \"" + inner_name + "\")"; }
/** * Return string representation close to declaration format, * `public static final short MAX = 100', e.g.. * * @return String representation of field, including the signature. */ @Override public final String toString() { String name, signature, access; // Short cuts to constant pool // Get names from constant pool access = Utility.accessToString(access_flags); access = access.equals("") ? "" : (access + " "); signature = Utility.signatureToString(getSignature()); name = getName(); StringBuilder buf = new StringBuilder(64); buf.append(access).append(signature).append(" ").append(name); ConstantValue cv = getConstantValue(); if (cv != null) { buf.append(" = ").append(cv); } for (int i = 0; i < attributes_count; i++) { Attribute a = attributes[i]; if (!(a instanceof ConstantValue)) { buf.append(" [").append(a.toString()).append("]"); } } return buf.toString(); }
access = Utility.accessToString(access_flags); c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable()); buf = new StringBuilder(signature);
try { for (int i = 0; i < index; i++) { codeToString(stream, constant_pool, verbose); String indices = fillup(stream.getIndex() + ":", 6, true, ' '); buf.append(indices).append(codeToString(stream, constant_pool, verbose)) .append('\n');
/** * @return String representation */ @Override public final String toString() { return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")"; } }