public static void print(ClassFile cf,PrintWriter out){
  List list;
  int n;
  int mod=AccessFlag.toModifier(cf.getAccessFlags() & ~AccessFlag.SYNCHRONIZED);
  out.println("major: " + cf.major + ", minor: "+ cf.minor+ " modifiers: "+ Integer.toHexString(cf.getAccessFlags()));
  out.println(Modifier.toString(mod) + " class " + cf.getName()+ " extends "+ cf.getSuperclass());
  String[] infs=cf.getInterfaces();
  if (infs != null && infs.length > 0) {
    out.print("    implements ");
    out.print(infs[0]);
    for (int i=1; i < infs.length; ++i)     out.print(", " + infs[i]);
    out.println();
  }
  out.println();
  list=cf.getFields();
  n=list.size();
  for (int i=0; i < n; ++i) {
    FieldInfo finfo=(FieldInfo)list.get(i);
    int acc=finfo.getAccessFlags();
    out.println(Modifier.toString(AccessFlag.toModifier(acc)) + " " + finfo.getName()+ "\t"+ finfo.getDescriptor());
    printAttributes(finfo.getAttributes(),out,'f');
  }
  out.println();
  list=cf.getMethods();
  n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    int acc=minfo.getAccessFlags();
    out.println(Modifier.toString(AccessFlag.toModifier(acc)) + " " + minfo.getName()+ "\t"+ minfo.getDescriptor());
    printAttributes(minfo.getAttributes(),out,'m');
    out.println();
  }
  out.println();
  printAttributes(cf.getAttributes(),out,'c');
}

public static void print ( ClassFile cf , PrintWriter out ) { List list ; int n ; int mod = AccessFlag . toModifier ( cf . getAccessFlags ( ) & ~ AccessFlag . SYNCHRONIZED ) ; out . println ( "major: " + cf . major + ", minor: " + cf . minor + " modifiers: " + Integer . toHexString ( cf . getAccessFlags ( ) ) ) ; out . println ( Modifier . toString ( mod ) + " class " + cf . getName ( ) + " extends " + cf . getSuperclass ( ) ) ; String [ ] infs = cf . getInterfaces ( ) ; if ( infs != null && infs . length > 0 ) { out . print ( "    implements " ) ; out . print ( infs [ 0 ] ) ; for ( int i = 1 ; i < infs . length ; ++ i ) out . print ( ", " + infs [ i ] ) ; out . println ( ) ; } out . println ( ) ; list = cf . getFields ( ) ; n = list . size ( ) ; for ( int i = 0 ; i < n ; ++ i ) { FieldInfo finfo = ( FieldInfo ) list . get ( i ) ; int acc = finfo . getAccessFlags ( ) ; out . println ( Modifier . toString ( AccessFlag . toModifier ( acc ) ) + " " + finfo . getName ( ) + "\t" + finfo . getDescriptor ( ) ) ; printAttributes ( finfo . getAttributes ( ) , out , 'f' ) ; } out . println ( ) ; list = cf . getMethods ( ) ; n = list . size ( ) ; for ( int i = 0 ; i < n ; ++ i ) { MethodInfo minfo = ( MethodInfo ) list . get ( i ) ; int acc = minfo . getAccessFlags ( ) ; out . println ( Modifier . toString ( AccessFlag . toModifier ( acc ) ) + " " + minfo . getName ( ) + "\t" + minfo . getDescriptor ( ) ) ; printAttributes ( minfo . getAttributes ( ) , out , 'm' ) ; out . println ( ) ; } out . println ( ) ; printAttributes ( cf . getAttributes ( ) , out , 'c' ) ; }
prints the contents of a class file .
