@Override
public String stringifyValue()
{
- StringBuffer sb = new StringBuffer();
- sb.append(annotationEntry.toString());
- return sb.toString();
+ return annotationEntry.toString();
}
@Override
private static final long serialVersionUID = 1L;
- private int type_index;
- private ConstantPool constant_pool;
+ private final int type_index;
+ private final ConstantPool constant_pool;
private List<ElementValuePair> element_value_pairs;
*
* @param file
* @param constant_pool
+ * @return the entry
* @throws IOException
*/
public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool) throws IOException {
* @return the element value pairs in this annotation entry
*/
public ElementValuePair[] getElementValuePairs() {
- // TOFO return List
+ // TODO return List
return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]);
}
-
- public void dump(DataOutputStream dos) throws IOException
- {
- dos.writeShort(type_index); // u2 index of type name in cpool
- dos.writeShort(element_value_pairs.size()); // u2 element_value pair count
- for (int i = 0 ; i<element_value_pairs.size();i++) {
- ElementValuePair envp = element_value_pairs.get(i);
+ public void dump(DataOutputStream dos) throws IOException {
+ dos.writeShort(type_index); // u2 index of type name in cpool
+ dos.writeShort(element_value_pairs.size()); // u2 element_value pair
+ // count
+ for (int i = 0; i < element_value_pairs.size(); i++) {
+ final ElementValuePair envp = element_value_pairs.get(i);
envp.dump(dos);
}
}
-
}
return;
}
dos.writeShort(annotation_table.length);
- for (int i = 0; i < annotation_table.length; i++)
+ for (int i = 0; i < annotation_table.length; i++) {
annotation_table[i].dump(dos);
+ }
}
}
@Override
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("{");
for (int i = 0; i < evalues.length; i++)
{
@Override
public String stringifyValue()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < evalues.length; i++)
{
{
return evalues;
}
-
-
}
it to construct an attribute. In the case of errors, a null can be
returned which will cause the parsing of the class file to fail.
*/
- public Attribute createAttribute( int name_index, int length, java.io.DataInputStream file,
+ Attribute createAttribute( int name_index, int length, java.io.DataInputStream file,
ConstantPool constant_pool );
}
public final void setCode( byte[] code ) {
this.code = code;
code_length = (code == null) ? 0 : code.length;
+ length = calculateLength(); // Adjust length
}
public final void setExceptionTable( CodeException[] exception_table ) {
this.exception_table = exception_table;
exception_table_length = (exception_table == null) ? 0 : exception_table.length;
+ length = calculateLength(); // Adjust length
}
* @return String representation of code chunk.
*/
public final String toString( boolean verbose ) {
- StringBuffer buf;
- buf = new StringBuffer(100);
+ 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));
ConstantFieldref(DataInputStream file) throws IOException {
super(Constants.CONSTANT_Fieldref, file);
}
-
-
}
public final String toString() {
return super.toString() + "(bytes = " + bytes + ")";
}
-
-
}
public final String toString() {
return super.toString() + "(bytes = " + bytes + ")";
}
-
-
}
ConstantInterfaceMethodref(DataInputStream file) throws IOException {
super(Constants.CONSTANT_InterfaceMethodref, file);
}
-
-
}
public final String toString() {
return super.toString() + "(bytes = " + bytes + ")";
}
-
-
}
ConstantMethodref(DataInputStream file) throws IOException {
super(Constants.CONSTANT_Methodref, file);
}
-
-
}
*/
public interface ConstantObject {
-
}
private static final String escape( String str ) {
int len = str.length();
- StringBuffer buf = new StringBuffer(len + 5);
+ StringBuilder buf = new StringBuilder(len + 5);
char[] ch = str.toCharArray();
for (int i = 0; i < len; i++) {
switch (ch[i]) {
*/
@Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 1; i < constant_pool_count; i++) {
buf.append(i).append(")").append(constant_pool[i]).append("\n");
}
public final String toString() {
return super.toString() + "(string_index = " + string_index + ")";
}
-
-
}
"Unexpected element value kind in annotation: " + type);
}
}
-
-
}
Constants.CONSTANT_Utf8);
return cu8.getBytes();
}
-
}
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String str;
for (int i = 0; i < number_of_exceptions; i++) {
str = constant_pool.getConstantString(exception_index_table[i],
access = access.equals("") ? "" : (access + " ");
signature = Utility.signatureToString(getSignature());
name = getName();
- StringBuffer buf = new StringBuffer(64);
+ StringBuilder buf = new StringBuilder(64);
buf.append(access).append(signature).append(" ").append(name);
ConstantValue cv = getConstantValue();
if (cv != null) {
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < number_of_classes; i++) {
buf.append(inner_classes[i].toString(constant_pool)).append("\n");
}
public String toString() {
String access = Utility.accessToString(access_flags, true);
access = access.equals("") ? "" : (access + " ");
- StringBuffer buf = new StringBuffer(128);
+ 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');
private static final String indent( Object obj ) {
StringTokenizer tok = new StringTokenizer(obj.toString(), "\n");
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
while (tok.hasMoreTokens()) {
buf.append("\t").append(tok.nextToken()).append("\n");
}
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer();
- StringBuffer line = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
+ StringBuilder line = new StringBuilder();
String newLine = System.getProperty("line.separator", "\n");
for (int i = 0; i < line_number_table_length; i++) {
line.append(line_number_table[i].toString());
c.constant_pool = _constant_pool;
return c;
}
-
-
}
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < local_variable_table_length; i++) {
buf.append(local_variable_table[i].toString());
if (i < local_variable_table_length - 1) {
c.constant_pool = _constant_pool;
return c;
}
-
-
}
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer("");
+ StringBuilder buf = new StringBuilder();
for(int i=0; i < local_variable_type_table_length; i++) {
buf.append(local_variable_type_table[i].toString());
public final String toString() {
ConstantUtf8 c;
String name, signature, access; // Short cuts to constant pool
- StringBuffer buf;
+ StringBuilder buf;
access = Utility.accessToString(access_flags);
// Get name and signature from constant pool
c = (ConstantUtf8) constant_pool.getConstant(signature_index, Constants.CONSTANT_Utf8);
name = c.getBytes();
signature = Utility.methodSignatureToString(signature, name, access, true,
getLocalVariableTable());
- buf = new StringBuffer(signature);
+ buf = new StringBuilder(signature);
for (int i = 0; i < attributes_count; i++) {
Attribute a = attributes[i];
if (!((a instanceof Code) || (a instanceof ExceptionTable))) {
? 0
: parameter_annotation_table.length;
}
-
}
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer("StackMap(");
+ StringBuilder buf = new StringBuilder("StackMap(");
for (int i = 0; i < map_length; i++) {
buf.append(map[i].toString());
if (i < map_length - 1) {
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer(64);
+ StringBuilder buf = new StringBuilder(64);
buf.append("(offset=").append(byte_code_offset);
if (number_of_locals > 0) {
buf.append(", locals={");
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer("StackMapTable(");
+ StringBuilder buf = new StringBuilder("StackMapTable(");
for (int i = 0; i < map_length; i++) {
buf.append(map[i].toString());
if (i < map_length - 1) {
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer(64);
+ StringBuilder buf = new StringBuilder(64);
buf.append("(");
if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
buf.append("SAME");
}
return null;
}
-
-
}
*/
@Override
public final String toString() {
- StringBuffer buf = new StringBuffer("Synthetic");
+ StringBuilder buf = new StringBuilder("Synthetic");
if (length > 0) {
buf.append(" ").append(Utility.toHexString(bytes));
}
private static void wrap( ThreadLocal<Integer> tl, int value ) {
- tl.set(new Integer(value));
+ tl.set(Integer.valueOf(value));
}
private static ThreadLocal<Integer> consumed_chars =
new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
- return new Integer(0);
+ return Integer.valueOf(0);
}
};/* How many chars have been consumed
* during parsing in signatureToString().
* @return String representation of flags
*/
public static final String accessToString( int access_flags, boolean for_class ) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int p = 0;
for (int i = 0; p < Constants.MAX_ACC_FLAG; i++) { // Loop through known flags
p = pow2(i);
*/
public static final String codeToString( byte[] code, ConstantPool constant_pool, int index,
int length, boolean verbose ) {
- StringBuffer buf = new StringBuffer(code.length * 20); // Should be sufficient
+ StringBuilder buf = new StringBuilder(code.length * 20); // Should be sufficient
ByteSequence stream = new ByteSequence(code);
try {
for (int i = 0; i < index; i++) {
int index, vindex, constant;
int[] match, jump_table;
int no_pad_bytes = 0, offset;
- StringBuffer buf = new StringBuffer(Constants.OPCODE_NAMES[opcode]);
+ StringBuilder buf = new StringBuilder(Constants.OPCODE_NAMES[opcode]);
/* Special case: Skip (0-3) padding bytes, i.e., the
* following bytes are 4-byte-aligned
*/
*/
public static final String methodSignatureToString( String signature, String name,
String access, boolean chopit, LocalVariableTable vars ) throws ClassFormatException {
- StringBuffer buf = new StringBuffer("(");
+ StringBuilder buf = new StringBuilder("(");
String type;
int index;
int var_index = (access.indexOf("static") >= 0) ? 0 : 1;
return "boolean";
case '[': { // Array declaration
int n;
- StringBuffer brackets;
+ StringBuilder brackets;
String type;
int consumed_chars; // Shadows global var
- brackets = new StringBuffer(); // Accumulate []'s
+ brackets = new StringBuilder(); // Accumulate []'s
// Count opening brackets and look for optional size argument
for (n = 0; signature.charAt(n) == '['; n++) {
brackets.append("[]");
* @return bytes as hexadecimal string, e.g. 00 FA 12 ...
*/
public static final String toHexString( byte[] bytes ) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
short b = byteToShort(bytes[i]);
String hex = Integer.toString(b, 0x10);
*/
public static final String convertString( String label ) {
char[] ch = label.toCharArray();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < ch.length; i++) {
switch (ch[i]) {
case '\n':
}
return buf.toString();
}
-
-
}
* @param THAT
* @return true if and only if THIS equals THAT
*/
- public boolean equals( Object THIS, Object THAT );
+ boolean equals( Object THIS, Object THAT );
/**
* @param THIS
* @return hashcode for THIS.hashCode()
*/
- public int hashCode( Object THIS );
+ int hashCode( Object THIS );
}