diff options
Diffstat (limited to 'src/main/javassist/bytecode/ClassFilePrinter.java')
-rw-r--r-- | src/main/javassist/bytecode/ClassFilePrinter.java | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/main/javassist/bytecode/ClassFilePrinter.java b/src/main/javassist/bytecode/ClassFilePrinter.java index 388ab517..a9c7d9ba 100644 --- a/src/main/javassist/bytecode/ClassFilePrinter.java +++ b/src/main/javassist/bytecode/ClassFilePrinter.java @@ -17,9 +17,10 @@ package javassist.bytecode; import java.io.PrintWriter; -import javassist.Modifier; import java.util.List; +import javassist.Modifier; + /** * A utility class for priting the contents of a class file. * It prints a constant pool table, fields, and methods in a @@ -37,9 +38,6 @@ public class ClassFilePrinter { * Prints the contents of a class file. */ public static void print(ClassFile cf, PrintWriter out) { - List list; - int n; - /* 0x0020 (SYNCHRONIZED) means ACC_SUPER if the modifiers * are of a class. */ @@ -62,10 +60,8 @@ public class ClassFilePrinter { } out.println(); - list = cf.getFields(); - n = list.size(); - for (int i = 0; i < n; ++i) { - FieldInfo finfo = (FieldInfo)list.get(i); + List<FieldInfo> fields = cf.getFields(); + for (FieldInfo finfo:fields) { int acc = finfo.getAccessFlags(); out.println(Modifier.toString(AccessFlag.toModifier(acc)) + " " + finfo.getName() + "\t" @@ -74,10 +70,8 @@ public class ClassFilePrinter { } out.println(); - list = cf.getMethods(); - n = list.size(); - for (int i = 0; i < n; ++i) { - MethodInfo minfo = (MethodInfo)list.get(i); + List<MethodInfo> methods = cf.getMethods(); + for (MethodInfo minfo:methods) { int acc = minfo.getAccessFlags(); out.println(Modifier.toString(AccessFlag.toModifier(acc)) + " " + minfo.getName() + "\t" @@ -90,13 +84,11 @@ public class ClassFilePrinter { printAttributes(cf.getAttributes(), out, 'c'); } - static void printAttributes(List list, PrintWriter out, char kind) { + static void printAttributes(List<AttributeInfo> list, PrintWriter out, char kind) { if (list == null) return; - int n = list.size(); - for (int i = 0; i < n; ++i) { - AttributeInfo ai = (AttributeInfo)list.get(i); + for (AttributeInfo ai:list) { if (ai instanceof CodeAttribute) { CodeAttribute ca = (CodeAttribute)ai; out.println("attribute: " + ai.getName() + ": " |