felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mccu...@apache.org
Subject svn commit: r1350613 [13/14] - in /felix/trunk/bundleplugin/src/main/java/aQute: bnd/annotation/ bnd/annotation/component/ bnd/annotation/metatype/ bnd/build/ bnd/compatibility/ bnd/component/ bnd/differ/ bnd/help/ bnd/make/ bnd/make/calltree/ bnd/make...
Date Fri, 15 Jun 2012 13:28:02 GMT
Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java Fri Jun 15 13:27:53 2012
@@ -6,693 +6,645 @@ import java.io.*;
 import java.lang.reflect.*;
 
 public class ClassDumper {
-    /**
-     * <pre>
-     * ACC_PUBLIC 0x0001 Declared public; may be accessed from outside its
-     * package. 
-     * ACC_FINAL 0x0010 Declared final; no subclasses allowed.
-     * ACC_SUPER 0x0020 Treat superclass methods specially when invoked by the
-     * invokespecial instruction. 
-     * ACC_INTERFACE 0x0200 Is an interface, not a
-     * class. 
-     * ACC_ABSTRACT 0x0400 Declared abstract; may not be instantiated.
-     * </pre>
-     * 
-     * @param mod
-     */
-    final static int ACC_PUBLIC  = 0x0001; // Declared public; may be accessed
-                                            // from outside its package.
-    final static int ACC_FINAL     = 0x0010; // Declared final; no subclasses
-    // allowed.
-    final static int ACC_SUPER     = 0x0020; // Treat superclass methods
-    // specially when invoked by the
-    // invokespecial instruction.
-    final static int ACC_INTERFACE = 0x0200; // Is an interface, not a classs
-    final static int ACC_ABSTRACT  = 0x0400; // Declared abstract; may not be
-                                                // instantiated.
-    
-    final static class Assoc {
-        Assoc(byte tag, int a, int b) {
-            this.tag = tag;
-            this.a = a;
-            this.b = b;
-        }
-
-        byte tag;
-        int  a;
-        int  b;
-
-    }
-
-    final String        path;
-    final static String NUM_COLUMN = "%-30s %d\n";
-    final static String HEX_COLUMN = "%-30s %x\n";
-    final static String STR_COLUMN = "%-30s %s\n";
-
-    PrintStream         ps         = System.err;
-    Object[]            pool;
-    InputStream         in;
-
-    public ClassDumper(String path) throws Exception {
-        this(path, new FileInputStream(new File(path)));
-    }
-
-    public ClassDumper(String path, InputStream in) throws IOException {
-        this.path = path;
-        this.in = in;
-    }
-
-    public void dump(PrintStream ps) throws Exception {
-        if (ps != null)
-            this.ps = ps;
-        DataInputStream din = new DataInputStream(in);
-        parseClassFile(din);
-        din.close();
-    }
-
-    void parseClassFile(DataInputStream in) throws IOException {
-        int magic = in.readInt();
-        if (magic != 0xCAFEBABE)
-            throw new IOException("Not a valid class file (no CAFEBABE header)");
-
-        ps.printf(HEX_COLUMN, "magic", magic);
-        int minor = in.readUnsignedShort(); // minor version
-        int major = in.readUnsignedShort(); // major version
-        ps.printf(STR_COLUMN, "version", "" + major + "." + minor);
-        int pool_size = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "pool size", pool_size);
-        pool = new Object[pool_size];
-
-        process: for (int poolIndex = 1; poolIndex < pool_size; poolIndex++) {
-            byte tag = in.readByte();
-
-            switch (tag) {
-            case 0:
-                ps.printf("%30d tag (0)\n", poolIndex);
-                break process;
-
-            case 1:
-                String name = in.readUTF();
-                pool[poolIndex] = name;
-                ps.printf("%30d tag(1) utf8 '%s'\n", poolIndex, name);
-                break;
-
-            case 2:
-                throw new IOException("Invalid tag " + tag);
-
-            case 3:
-                int i = in.readInt();
-                pool[poolIndex] = Integer.valueOf(i);
-                ps.printf("%30d tag(3) int %s\n", poolIndex, i);
-                break;
-
-            case 4:
-                float f = in.readFloat();
-                pool[poolIndex] = new Float(f);
-                ps.printf("%30d tag(4) float %s\n", poolIndex, f);
-                break;
-
-            // For some insane optimization reason are
-            // the long and the double two entries in the
-            // constant pool. See 4.4.5
-            case 5:
-                long l = in.readLong();
-                pool[poolIndex] = Long.valueOf(l);
-                ps.printf("%30d tag(5) long %s\n", poolIndex, l);
-                poolIndex++;
-                break;
-
-            case 6:
-                double d = in.readDouble();
-                pool[poolIndex] = new Double(d);
-                ps.printf("%30d tag(6) double %s\n", poolIndex, d);
-                poolIndex++;
-                break;
-
-            case 7:
-                int class_index = in.readUnsignedShort();
-                pool[poolIndex] = Integer.valueOf(class_index);
-                ps.printf("%30d tag(7) constant classs %d\n", poolIndex,
-                        class_index);
-                break;
-
-            case 8:
-                int string_index = in.readUnsignedShort();
-                pool[poolIndex] = Integer.valueOf(string_index);
-                ps.printf("%30d tag(8) constant string %d\n", poolIndex,
-                        string_index);
-                break;
-
-            case 9: // Field ref
-                class_index = in.readUnsignedShort();
-                int name_and_type_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc((byte) 9, class_index,
-                        name_and_type_index);
-                ps.printf("%30d tag(9) field ref %d/%d\n", poolIndex,
-                        class_index, name_and_type_index);
-                break;
-
-            case 10: // Method ref
-                class_index = in.readUnsignedShort();
-                name_and_type_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc((byte) 10, class_index,
-                        name_and_type_index);
-                ps.printf("%30d tag(10) method ref %d/%d\n", poolIndex,
-                        class_index, name_and_type_index);
-                break;
-
-            case 11: // Interface and Method ref
-                class_index = in.readUnsignedShort();
-                name_and_type_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc((byte) 11, class_index,
-                        name_and_type_index);
-                ps.printf("%30d tag(11) interface and method ref %d/%d\n",
-                        poolIndex, class_index, name_and_type_index);
-                break;
-
-            // Name and Type
-            case 12:
-                int name_index = in.readUnsignedShort();
-                int descriptor_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc(tag, name_index, descriptor_index);
-                ps.printf("%30d tag(12) name and type %d/%d\n", poolIndex,
-                        name_index, descriptor_index);
-                break;
-
-            default:
-                throw new IllegalArgumentException("Unknown tag: " + tag);
-            }
-        }
-
-        int access = in.readUnsignedShort(); // access
-        printAccess(access);
-        int this_class = in.readUnsignedShort();
-        int super_class = in.readUnsignedShort();
-        ps.printf("%-30s %x %s(#%d)\n", "this_class", access, pool[this_class],
-                this_class);
-        ps.printf("%-30s %s(#%d)\n", "super_class", pool[super_class],
-                super_class);
-
-        int interfaces_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "interface count", interfaces_count);
-        for (int i = 0; i < interfaces_count; i++) {
-            int interface_index = in.readUnsignedShort();
-            ps.printf("%-30s interface %s(#%d)", "interface count",
-                    pool[interface_index], interfaces_count);
-        }
-
-        int field_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "field count", field_count);
-        for (int i = 0; i < field_count; i++) {
-            access = in.readUnsignedShort(); // access
-            printAccess(access);
-            int name_index = in.readUnsignedShort();
-            int descriptor_index = in.readUnsignedShort();
-            ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "field def", access,
-                    pool[name_index], name_index, pool[descriptor_index],
-                    descriptor_index);
-            doAttributes(in, "  ");
-        }
-
-        int method_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "method count", method_count);
-        for (int i = 0; i < method_count; i++) {
-            int access_flags = in.readUnsignedShort();
-            printAccess(access_flags);
-            int name_index = in.readUnsignedShort();
-            int descriptor_index = in.readUnsignedShort();
-            ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "method def", access_flags,
-                    pool[name_index], name_index, pool[descriptor_index],
-                    descriptor_index);
-            doAttributes(in, "  ");
-        }
-
-        doAttributes(in, "");
-        if (in.read() >= 0)
-            ps.printf("Extra bytes follow ...");
-    }
-
-    /**
-     * Called for each attribute in the class, field, or method.
-     * 
-     * @param in
-     *            The stream
-     * @throws IOException
-     */
-    private void doAttributes(DataInputStream in, String indent)
-            throws IOException {
-        int attribute_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "attribute count", attribute_count);
-        for (int j = 0; j < attribute_count; j++) {
-            doAttribute(in, indent + j + ": ");
-        }
-    }
-
-    /**
-     * Process a single attribute, if not recognized, skip it.
-     * 
-     * @param in
-     *            the data stream
-     * @throws IOException
-     */
-    private void doAttribute(DataInputStream in, String indent)
-            throws IOException {
-        int attribute_name_index = in.readUnsignedShort();
-        long attribute_length = in.readInt();
-        attribute_length &= 0xFFFF;
-        String attributeName = (String) pool[attribute_name_index];
-        ps.printf("%-30s %s(#%d)\n", indent + "attribute", attributeName,
-                attribute_name_index);
-        if ("RuntimeVisibleAnnotations".equals(attributeName))
-            doAnnotations(in, indent);
-        else if ("SourceFile".equals(attributeName))
-            doSourceFile(in, indent);
-        else if ("Code".equals(attributeName))
-            doCode(in, indent);
-        else if ("LineNumberTable".equals(attributeName))
-            doLineNumberTable(in, indent);
-        else if ("LocalVariableTable".equals(attributeName))
-            doLocalVariableTable(in, indent);
-        else if ("InnerClasses".equals(attributeName))
-            doInnerClasses(in, indent);
-        else if ("Exceptions".equals(attributeName))
-            doExceptions(in, indent);
-        else if ("EnclosingMethod".equals(attributeName))
-            doEnclosingMethod(in, indent);
-        else if ("Signature".equals(attributeName))
-            doSignature(in, indent);
-        else if ("Synthetic".equals(attributeName))
-            ; // Is empty!
-        else if ("Deprecated".equals(attributeName))
-            ; // Is Empty
-        else {
-            ps.printf("%-30s %d\n", indent + "Unknown attribute, skipping",
-                    attribute_length);
-            if (attribute_length > 0x7FFFFFFF) {
-                throw new IllegalArgumentException("Attribute > 2Gb");
-            }
-            byte buffer[] = new byte[(int) attribute_length];
-            in.readFully(buffer);
-            printHex(buffer);
-        }
-    }
-
-    /**
-     * <pre>
-     * Signature_attribute {
-     * 	u2 attribute_name_index;
-     * 	u4 attribute_length;
-     * 	u2 signature_index;
-     * 	}
-     * </pre>
-     * 
-     * @param in
-     * @param indent
-     */
-    void doSignature(DataInputStream in, String indent) throws IOException {
-        int signature_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d)\n", indent + "signature",
-                pool[signature_index], signature_index);
-    }
-
-    /**
-     * <pre>
-     * EnclosingMethod_attribute {
-     * 	u2 attribute_name_index;
-     * 	u4 attribute_length;
-     * 	u2 class_index
-     * 	u2 method_index;
-     * 	}
-     * 	
-     * </pre>
-     */
-    void doEnclosingMethod(DataInputStream in, String indent)
-            throws IOException {
-        int class_index = in.readUnsignedShort();
-        int method_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d/c) %s\n", //
-        		indent + "enclosing method", //
-                pool[((Integer) pool[class_index]).intValue()], //
-                class_index, //
-                (method_index == 0 ? "<>" : pool[method_index]));
-    }
-
-    /**
-     * <pre>
-     *  Exceptions_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 number_of_exceptions;
-     * 		u2 exception_index_table[number_of_exceptions];
-     * 	}
-     * </pre>
-     * 
-     * @param in
-     * @param indent
-     */
-    private void doExceptions(DataInputStream in, String indent)
-            throws IOException {
-        int number_of_exceptions = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "number of exceptions",
-                number_of_exceptions);
-        StringBuilder sb = new StringBuilder();
-        String del = "";
-        for (int i = 0; i < number_of_exceptions; i++) {
-            int exception_index_table = in.readUnsignedShort();
-            sb.append(del);
-            sb.append(pool[((Integer) pool[exception_index_table])]);
-            sb.append("(#");
-            sb.append(exception_index_table);
-            sb.append("/c)");
-            del = ", ";
-        }
-        ps.printf("%-30s %d: %s\n", indent + "exceptions",
-                number_of_exceptions, sb);
-    }
-
-    /**
-     * <pre>
-     * Code_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 max_stack;
-     * 		u2 max_locals;
-     * 		u4 code_length;
-     * 		u1 code[code_length];
-     * 		u2 exception_table_length;
-     * 		{    	u2 start_pc;
-     * 		      	u2 end_pc;
-     * 		      	u2  handler_pc;
-     * 		      	u2  catch_type;
-     * 		}	exception_table[exception_table_length];
-     * 		u2 attributes_count;
-     * 		attribute_info attributes[attributes_count];
-     * 	}
-     * </pre>
-     * 
-     * @param in
-     * @param pool
-     * @throws IOException
-     */
-    private void doCode(DataInputStream in, String indent) throws IOException {
-        int max_stack = in.readUnsignedShort();
-        int max_locals = in.readUnsignedShort();
-        int code_length = in.readInt();
-        ps.printf(NUM_COLUMN, indent + "max_stack", max_stack);
-        ps.printf(NUM_COLUMN, indent + "max_locals", max_locals);
-        ps.printf(NUM_COLUMN, indent + "code_length", code_length);
-        byte code[] = new byte[code_length];
-        in.readFully(code);
-        printHex(code);
-        int exception_table_length = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "exception_table_length",
-                exception_table_length);
-
-        for (int i = 0; i < exception_table_length; i++) {
-            int start_pc = in.readUnsignedShort();
-            int end_pc = in.readUnsignedShort();
-            int handler_pc = in.readUnsignedShort();
-            int catch_type = in.readUnsignedShort();
-            ps.printf("%-30s %d/%d/%d/%d\n", indent + "exception_table",
-                    start_pc, end_pc, handler_pc, catch_type);
-        }
-        doAttributes(in, indent + "  ");
-    }
-
-    /**
-     * We must find Class.forName references ...
-     * 
-     * @param code
-     */
-    protected void printHex(byte[] code) {
-        int index = 0;
-        while (index < code.length) {
-            StringBuilder sb = new StringBuilder();
-            for (int i = 0; i < 16 && index < code.length; i++) {
-                String s = Integer.toHexString((0xFF & code[index++]))
-                        .toUpperCase();
-                if (s.length() == 1)
-                    sb.append("0");
-                sb.append(s);
-                sb.append(" ");
-            }
-            ps.printf(STR_COLUMN, "", sb.toString());
-        }
-    }
-
-    private void doSourceFile(DataInputStream in, String indent)
-            throws IOException {
-        int sourcefile_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d)\n", indent + "Source file",
-                pool[sourcefile_index], sourcefile_index);
-    }
-
-    private void doAnnotations(DataInputStream in, String indent)
-            throws IOException {
-        int num_annotations = in.readUnsignedShort(); // # of annotations
-        ps
-                .printf(NUM_COLUMN, indent + "Number of annotations",
-                        num_annotations);
-        for (int a = 0; a < num_annotations; a++) {
-            doAnnotation(in, indent);
-        }
-    }
-
-    private void doAnnotation(DataInputStream in, String indent)
-            throws IOException {
-        int type_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d)", indent + "type", pool[type_index],
-                type_index);
-        int num_element_value_pairs = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "num_element_value_pairs",
-                num_element_value_pairs);
-        for (int v = 0; v < num_element_value_pairs; v++) {
-            int element_name_index = in.readUnsignedShort();
-            ps.printf(NUM_COLUMN, indent + "element_name_index",
-                    element_name_index);
-            doElementValue(in, indent);
-        }
-    }
-
-    private void doElementValue(DataInputStream in, String indent)
-            throws IOException {
-        int tag = in.readUnsignedByte();
-        switch (tag) {
-        case 'B':
-        case 'C':
-        case 'D':
-        case 'F':
-        case 'I':
-        case 'J':
-        case 'S':
-        case 'Z':
-        case 's':
-            int const_value_index = in.readUnsignedShort();
-            ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag,
-                    pool[const_value_index], const_value_index);
-            break;
-
-        case 'e':
-            int type_name_index = in.readUnsignedShort();
-            int const_name_index = in.readUnsignedShort();
-            ps.printf("%-30s %c %s(#%d) %s(#%d)\n", indent + "type+const", tag,
-                    pool[type_name_index], type_name_index,
-                    pool[const_name_index], const_name_index);
-            break;
-
-        case 'c':
-            int class_info_index = in.readUnsignedShort();
-            ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag,
-                    pool[class_info_index], class_info_index);
-            break;
-
-        case '@':
-            ps.printf("%-30s %c\n", indent + "sub annotation", tag);
-            doAnnotation(in, indent);
-            break;
-
-        case '[':
-            int num_values = in.readUnsignedShort();
-            ps.printf("%-30s %c num_values=%d\n", indent + "sub element value",
-                    tag, num_values);
-            for (int i = 0; i < num_values; i++) {
-                doElementValue(in, indent);
-            }
-            break;
-
-        default:
-            throw new IllegalArgumentException(
-                    "Invalid value for Annotation ElementValue tag " + tag);
-        }
-    }
-
-    /**
-     * <pre>
-     *  LineNumberTable_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 line_number_table_length;
-     * 		{  u2 start_pc;	     
-     * 		   u2 line_number;	     
-     * 		} line_number_table[line_number_table_length];
-     * 	}
-     * 	
-     * </pre>
-     */
-    void doLineNumberTable(DataInputStream in, String indent)
-            throws IOException {
-        int line_number_table_length = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "line number table length",
-                line_number_table_length);
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < line_number_table_length; i++) {
-            int start_pc = in.readUnsignedShort();
-            int line_number = in.readUnsignedShort();
-            sb.append(start_pc);
-            sb.append("/");
-            sb.append(line_number);
-            sb.append(" ");
-        }
-        ps.printf("%-30s %d: %s\n", indent + "line number table",
-                line_number_table_length, sb);
-    }
-
-    /**
-     * 
-     * <pre>
-     * 	LocalVariableTable_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 local_variable_table_length;
-     * 		{  u2 start_pc;
-     * 		    u2 length;
-     * 		    u2 name_index;
-     * 		    u2 descriptor_index;
-     * 		    u2 index;
-     * 		} local_variable_table[local_variable_table_length];
-     * 	}	
-     * </pre>
-     */
-
-    void doLocalVariableTable(DataInputStream in, String indent)
-            throws IOException {
-        int local_variable_table_length = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "local variable table length",
-                local_variable_table_length);
-        for (int i = 0; i < local_variable_table_length; i++) {
-            int start_pc = in.readUnsignedShort();
-            int length = in.readUnsignedShort();
-            int name_index = in.readUnsignedShort();
-            int descriptor_index = in.readUnsignedShort();
-            int index = in.readUnsignedShort();
-            ps.printf("%-30s %d: %d/%d %s(#%d) %s(#%d)\n", indent, index,
-                    start_pc, length, pool[name_index], name_index,
-                    pool[descriptor_index], descriptor_index);
-        }
-    }
-
-    /**
-     * <pre>
-     *    InnerClasses_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 number_of_classes;
-     * 		{  u2 inner_class_info_index;	     
-     * 		   u2 outer_class_info_index;	     
-     * 		   u2 inner_name_index;	     
-     * 		   u2 inner_class_access_flags;	     
-     * 		} classes[number_of_classes];
-     * 	}
-     * </pre>
-     * 
-     */
-    void doInnerClasses(DataInputStream in, String indent) throws IOException {
-        int number_of_classes = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "number of classes", number_of_classes);
-        for (int i = 0; i < number_of_classes; i++) {
-            int inner_class_info_index = in.readUnsignedShort();
-            int outer_class_info_index = in.readUnsignedShort();
-            int inner_name_index = in.readUnsignedShort();
-            int inner_class_access_flags = in.readUnsignedShort();
-            printAccess(inner_class_access_flags);
-
-            String iname = "<>";
-            String oname = iname;
-
-            if (inner_class_info_index != 0)
-                iname = (String) pool[((Integer) pool[inner_class_info_index])
-                        .intValue()];
-            if (outer_class_info_index != 0)
-                oname = (String) pool[((Integer) pool[outer_class_info_index])
-                        .intValue()];
-
-            ps.printf("%-30s %d: %x %s(#%d/c) %s(#%d/c) %s(#%d) \n", indent, i,
-                    inner_class_access_flags, iname, inner_class_info_index,
-                    oname, outer_class_info_index, pool[inner_name_index],
-                    inner_name_index);
-        }
-    }
-
-
-    void printClassAccess(int mod) {
-        ps.printf("%-30s", "Class Access");
-        if ((ACC_PUBLIC&mod)!= 0)
-            ps.print(" public");
-        if ((ACC_FINAL&mod)!= 0)
-            ps.print(" final");
-        if ((ACC_SUPER&mod)!= 0)
-            ps.print(" super");
-        if ((ACC_INTERFACE&mod)!= 0)
-            ps.print(" interface");
-        if ((ACC_ABSTRACT&mod)!= 0)
-            ps.print(" abstract");
-
-        ps.println();
-    }
-
-    void printAccess(int mod) {
-        ps.printf("%-30s", "Access");
-        if (Modifier.isStatic(mod))
-            ps.print(" static");
-        if (Modifier.isAbstract(mod))
-            ps.print(" abstract");
-        if (Modifier.isPublic(mod))
-            ps.print(" public");
-        if (Modifier.isFinal(mod))
-            ps.print(" final");
-        if (Modifier.isInterface(mod))
-            ps.print(" interface");
-        if (Modifier.isNative(mod))
-            ps.print(" native");
-        if (Modifier.isPrivate(mod))
-            ps.print(" private");
-        if (Modifier.isProtected(mod))
-            ps.print(" protected");
-        if (Modifier.isStrict(mod))
-            ps.print(" strict");
-        if (Modifier.isSynchronized(mod))
-            ps.print(" synchronized");
-        if (Modifier.isTransient(mod))
-            ps.print(" transient");
-        if (Modifier.isVolatile(mod))
-            ps.print(" volatile");
-
-        ps.println();
-    }
-
-    public static void main(String args[]) throws Exception {
-        if (args.length == 0) {
-            System.err.println("clsd <class file>+");
-        }
-        for (int i = 0; i < args.length; i++) {
-            File f = new File(args[i]);
-            if (!f.isFile())
-                System.err.println("File does not exist or is directory " + f);
-            else {
-                ClassDumper cd = new ClassDumper(args[i]);
-                cd.dump(null);
-            }
-        }
-    }
+	/**
+	 * <pre>
+	 * ACC_PUBLIC 0x0001 Declared public; may be accessed from outside its
+	 * package. 
+	 * ACC_FINAL 0x0010 Declared final; no subclasses allowed.
+	 * ACC_SUPER 0x0020 Treat superclass methods specially when invoked by the
+	 * invokespecial instruction. 
+	 * ACC_INTERFACE 0x0200 Is an interface, not a
+	 * class. 
+	 * ACC_ABSTRACT 0x0400 Declared abstract; may not be instantiated.
+	 * </pre>
+	 * 
+	 * @param mod
+	 */
+	final static int	ACC_PUBLIC		= 0x0001;	// Declared public; may be
+													// accessed
+													// from outside its package.
+	final static int	ACC_FINAL		= 0x0010;	// Declared final; no
+													// subclasses
+	// allowed.
+	final static int	ACC_SUPER		= 0x0020;	// Treat superclass methods
+	// specially when invoked by the
+	// invokespecial instruction.
+	final static int	ACC_INTERFACE	= 0x0200;	// Is an interface, not a
+													// classs
+	final static int	ACC_ABSTRACT	= 0x0400;	// Declared abstract; may
+													// not be
+													// instantiated.
+
+	final static class Assoc {
+		Assoc(byte tag, int a, int b) {
+			this.tag = tag;
+			this.a = a;
+			this.b = b;
+		}
+
+		byte	tag;
+		int		a;
+		int		b;
+
+	}
+
+	final String		path;
+	final static String	NUM_COLUMN	= "%-30s %d\n";
+	final static String	HEX_COLUMN	= "%-30s %x\n";
+	final static String	STR_COLUMN	= "%-30s %s\n";
+
+	PrintStream			ps			= System.err;
+	Object[]			pool;
+	InputStream			in;
+
+	public ClassDumper(String path) throws Exception {
+		this(path, new FileInputStream(new File(path)));
+	}
+
+	public ClassDumper(String path, InputStream in) throws IOException {
+		this.path = path;
+		this.in = in;
+	}
+
+	public void dump(PrintStream ps) throws Exception {
+		if (ps != null)
+			this.ps = ps;
+		DataInputStream din = new DataInputStream(in);
+		parseClassFile(din);
+		din.close();
+	}
+
+	void parseClassFile(DataInputStream in) throws IOException {
+		int magic = in.readInt();
+		if (magic != 0xCAFEBABE)
+			throw new IOException("Not a valid class file (no CAFEBABE header)");
+
+		ps.printf(HEX_COLUMN, "magic", magic);
+		int minor = in.readUnsignedShort(); // minor version
+		int major = in.readUnsignedShort(); // major version
+		ps.printf(STR_COLUMN, "version", "" + major + "." + minor);
+		int pool_size = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "pool size", pool_size);
+		pool = new Object[pool_size];
+
+		process: for (int poolIndex = 1; poolIndex < pool_size; poolIndex++) {
+			byte tag = in.readByte();
+
+			switch (tag) {
+				case 0 :
+					ps.printf("%30d tag (0)\n", poolIndex);
+					break process;
+
+				case 1 :
+					String name = in.readUTF();
+					pool[poolIndex] = name;
+					ps.printf("%30d tag(1) utf8 '%s'\n", poolIndex, name);
+					break;
+
+				case 2 :
+					throw new IOException("Invalid tag " + tag);
+
+				case 3 :
+					int i = in.readInt();
+					pool[poolIndex] = Integer.valueOf(i);
+					ps.printf("%30d tag(3) int %s\n", poolIndex, i);
+					break;
+
+				case 4 :
+					float f = in.readFloat();
+					pool[poolIndex] = new Float(f);
+					ps.printf("%30d tag(4) float %s\n", poolIndex, f);
+					break;
+
+				// For some insane optimization reason are
+				// the long and the double two entries in the
+				// constant pool. See 4.4.5
+				case 5 :
+					long l = in.readLong();
+					pool[poolIndex] = Long.valueOf(l);
+					ps.printf("%30d tag(5) long %s\n", poolIndex, l);
+					poolIndex++;
+					break;
+
+				case 6 :
+					double d = in.readDouble();
+					pool[poolIndex] = new Double(d);
+					ps.printf("%30d tag(6) double %s\n", poolIndex, d);
+					poolIndex++;
+					break;
+
+				case 7 :
+					int class_index = in.readUnsignedShort();
+					pool[poolIndex] = Integer.valueOf(class_index);
+					ps.printf("%30d tag(7) constant classs %d\n", poolIndex, class_index);
+					break;
+
+				case 8 :
+					int string_index = in.readUnsignedShort();
+					pool[poolIndex] = Integer.valueOf(string_index);
+					ps.printf("%30d tag(8) constant string %d\n", poolIndex, string_index);
+					break;
+
+				case 9 : // Field ref
+					class_index = in.readUnsignedShort();
+					int name_and_type_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc((byte) 9, class_index, name_and_type_index);
+					ps.printf("%30d tag(9) field ref %d/%d\n", poolIndex, class_index, name_and_type_index);
+					break;
+
+				case 10 : // Method ref
+					class_index = in.readUnsignedShort();
+					name_and_type_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc((byte) 10, class_index, name_and_type_index);
+					ps.printf("%30d tag(10) method ref %d/%d\n", poolIndex, class_index, name_and_type_index);
+					break;
+
+				case 11 : // Interface and Method ref
+					class_index = in.readUnsignedShort();
+					name_and_type_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc((byte) 11, class_index, name_and_type_index);
+					ps.printf("%30d tag(11) interface and method ref %d/%d\n", poolIndex, class_index,
+							name_and_type_index);
+					break;
+
+				// Name and Type
+				case 12 :
+					int name_index = in.readUnsignedShort();
+					int descriptor_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc(tag, name_index, descriptor_index);
+					ps.printf("%30d tag(12) name and type %d/%d\n", poolIndex, name_index, descriptor_index);
+					break;
+
+				default :
+					throw new IllegalArgumentException("Unknown tag: " + tag);
+			}
+		}
+
+		int access = in.readUnsignedShort(); // access
+		printAccess(access);
+		int this_class = in.readUnsignedShort();
+		int super_class = in.readUnsignedShort();
+		ps.printf("%-30s %x %s(#%d)\n", "this_class", access, pool[this_class], this_class);
+		ps.printf("%-30s %s(#%d)\n", "super_class", pool[super_class], super_class);
+
+		int interfaces_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "interface count", interfaces_count);
+		for (int i = 0; i < interfaces_count; i++) {
+			int interface_index = in.readUnsignedShort();
+			ps.printf("%-30s interface %s(#%d)", "interface count", pool[interface_index], interfaces_count);
+		}
+
+		int field_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "field count", field_count);
+		for (int i = 0; i < field_count; i++) {
+			access = in.readUnsignedShort(); // access
+			printAccess(access);
+			int name_index = in.readUnsignedShort();
+			int descriptor_index = in.readUnsignedShort();
+			ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "field def", access, pool[name_index], name_index,
+					pool[descriptor_index], descriptor_index);
+			doAttributes(in, "  ");
+		}
+
+		int method_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "method count", method_count);
+		for (int i = 0; i < method_count; i++) {
+			int access_flags = in.readUnsignedShort();
+			printAccess(access_flags);
+			int name_index = in.readUnsignedShort();
+			int descriptor_index = in.readUnsignedShort();
+			ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "method def", access_flags, pool[name_index], name_index,
+					pool[descriptor_index], descriptor_index);
+			doAttributes(in, "  ");
+		}
+
+		doAttributes(in, "");
+		if (in.read() >= 0)
+			ps.printf("Extra bytes follow ...");
+	}
+
+	/**
+	 * Called for each attribute in the class, field, or method.
+	 * 
+	 * @param in
+	 *            The stream
+	 * @throws IOException
+	 */
+	private void doAttributes(DataInputStream in, String indent) throws IOException {
+		int attribute_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "attribute count", attribute_count);
+		for (int j = 0; j < attribute_count; j++) {
+			doAttribute(in, indent + j + ": ");
+		}
+	}
+
+	/**
+	 * Process a single attribute, if not recognized, skip it.
+	 * 
+	 * @param in
+	 *            the data stream
+	 * @throws IOException
+	 */
+	private void doAttribute(DataInputStream in, String indent) throws IOException {
+		int attribute_name_index = in.readUnsignedShort();
+		long attribute_length = in.readInt();
+		attribute_length &= 0xFFFF;
+		String attributeName = (String) pool[attribute_name_index];
+		ps.printf("%-30s %s(#%d)\n", indent + "attribute", attributeName, attribute_name_index);
+		if ("RuntimeVisibleAnnotations".equals(attributeName))
+			doAnnotations(in, indent);
+		else if ("SourceFile".equals(attributeName))
+			doSourceFile(in, indent);
+		else if ("Code".equals(attributeName))
+			doCode(in, indent);
+		else if ("LineNumberTable".equals(attributeName))
+			doLineNumberTable(in, indent);
+		else if ("LocalVariableTable".equals(attributeName))
+			doLocalVariableTable(in, indent);
+		else if ("InnerClasses".equals(attributeName))
+			doInnerClasses(in, indent);
+		else if ("Exceptions".equals(attributeName))
+			doExceptions(in, indent);
+		else if ("EnclosingMethod".equals(attributeName))
+			doEnclosingMethod(in, indent);
+		else if ("Signature".equals(attributeName))
+			doSignature(in, indent);
+		else if ("Synthetic".equals(attributeName))
+			; // Is empty!
+		else if ("Deprecated".equals(attributeName))
+			; // Is Empty
+		else {
+			ps.printf("%-30s %d\n", indent + "Unknown attribute, skipping", attribute_length);
+			if (attribute_length > 0x7FFFFFFF) {
+				throw new IllegalArgumentException("Attribute > 2Gb");
+			}
+			byte buffer[] = new byte[(int) attribute_length];
+			in.readFully(buffer);
+			printHex(buffer);
+		}
+	}
+
+	/**
+	 * <pre>
+	 * Signature_attribute {
+	 * 	u2 attribute_name_index;
+	 * 	u4 attribute_length;
+	 * 	u2 signature_index;
+	 * 	}
+	 * </pre>
+	 * 
+	 * @param in
+	 * @param indent
+	 */
+	void doSignature(DataInputStream in, String indent) throws IOException {
+		int signature_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d)\n", indent + "signature", pool[signature_index], signature_index);
+	}
+
+	/**
+	 * <pre>
+	 * EnclosingMethod_attribute {
+	 * 	u2 attribute_name_index;
+	 * 	u4 attribute_length;
+	 * 	u2 class_index
+	 * 	u2 method_index;
+	 * 	}
+	 * 
+	 * </pre>
+	 */
+	void doEnclosingMethod(DataInputStream in, String indent) throws IOException {
+		int class_index = in.readUnsignedShort();
+		int method_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d/c) %s\n", //
+				indent + "enclosing method", //
+				pool[((Integer) pool[class_index]).intValue()], //
+				class_index, //
+				(method_index == 0 ? "<>" : pool[method_index]));
+	}
+
+	/**
+	 * <pre>
+	 *  Exceptions_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 number_of_exceptions;
+	 * 		u2 exception_index_table[number_of_exceptions];
+	 * 	}
+	 * </pre>
+	 * 
+	 * @param in
+	 * @param indent
+	 */
+	private void doExceptions(DataInputStream in, String indent) throws IOException {
+		int number_of_exceptions = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "number of exceptions", number_of_exceptions);
+		StringBuilder sb = new StringBuilder();
+		String del = "";
+		for (int i = 0; i < number_of_exceptions; i++) {
+			int exception_index_table = in.readUnsignedShort();
+			sb.append(del);
+			sb.append(pool[((Integer) pool[exception_index_table])]);
+			sb.append("(#");
+			sb.append(exception_index_table);
+			sb.append("/c)");
+			del = ", ";
+		}
+		ps.printf("%-30s %d: %s\n", indent + "exceptions", number_of_exceptions, sb);
+	}
+
+	/**
+	 * <pre>
+	 * Code_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 max_stack;
+	 * 		u2 max_locals;
+	 * 		u4 code_length;
+	 * 		u1 code[code_length];
+	 * 		u2 exception_table_length;
+	 * 		{    	u2 start_pc;
+	 * 		      	u2 end_pc;
+	 * 		      	u2  handler_pc;
+	 * 		      	u2  catch_type;
+	 * 		}	exception_table[exception_table_length];
+	 * 		u2 attributes_count;
+	 * 		attribute_info attributes[attributes_count];
+	 * 	}
+	 * </pre>
+	 * 
+	 * @param in
+	 * @param pool
+	 * @throws IOException
+	 */
+	private void doCode(DataInputStream in, String indent) throws IOException {
+		int max_stack = in.readUnsignedShort();
+		int max_locals = in.readUnsignedShort();
+		int code_length = in.readInt();
+		ps.printf(NUM_COLUMN, indent + "max_stack", max_stack);
+		ps.printf(NUM_COLUMN, indent + "max_locals", max_locals);
+		ps.printf(NUM_COLUMN, indent + "code_length", code_length);
+		byte code[] = new byte[code_length];
+		in.readFully(code);
+		printHex(code);
+		int exception_table_length = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "exception_table_length", exception_table_length);
+
+		for (int i = 0; i < exception_table_length; i++) {
+			int start_pc = in.readUnsignedShort();
+			int end_pc = in.readUnsignedShort();
+			int handler_pc = in.readUnsignedShort();
+			int catch_type = in.readUnsignedShort();
+			ps.printf("%-30s %d/%d/%d/%d\n", indent + "exception_table", start_pc, end_pc, handler_pc, catch_type);
+		}
+		doAttributes(in, indent + "  ");
+	}
+
+	/**
+	 * We must find Class.forName references ...
+	 * 
+	 * @param code
+	 */
+	protected void printHex(byte[] code) {
+		int index = 0;
+		while (index < code.length) {
+			StringBuilder sb = new StringBuilder();
+			for (int i = 0; i < 16 && index < code.length; i++) {
+				String s = Integer.toHexString((0xFF & code[index++])).toUpperCase();
+				if (s.length() == 1)
+					sb.append("0");
+				sb.append(s);
+				sb.append(" ");
+			}
+			ps.printf(STR_COLUMN, "", sb.toString());
+		}
+	}
+
+	private void doSourceFile(DataInputStream in, String indent) throws IOException {
+		int sourcefile_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d)\n", indent + "Source file", pool[sourcefile_index], sourcefile_index);
+	}
+
+	private void doAnnotations(DataInputStream in, String indent) throws IOException {
+		int num_annotations = in.readUnsignedShort(); // # of annotations
+		ps.printf(NUM_COLUMN, indent + "Number of annotations", num_annotations);
+		for (int a = 0; a < num_annotations; a++) {
+			doAnnotation(in, indent);
+		}
+	}
+
+	private void doAnnotation(DataInputStream in, String indent) throws IOException {
+		int type_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d)", indent + "type", pool[type_index], type_index);
+		int num_element_value_pairs = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "num_element_value_pairs", num_element_value_pairs);
+		for (int v = 0; v < num_element_value_pairs; v++) {
+			int element_name_index = in.readUnsignedShort();
+			ps.printf(NUM_COLUMN, indent + "element_name_index", element_name_index);
+			doElementValue(in, indent);
+		}
+	}
+
+	private void doElementValue(DataInputStream in, String indent) throws IOException {
+		int tag = in.readUnsignedByte();
+		switch (tag) {
+			case 'B' :
+			case 'C' :
+			case 'D' :
+			case 'F' :
+			case 'I' :
+			case 'J' :
+			case 'S' :
+			case 'Z' :
+			case 's' :
+				int const_value_index = in.readUnsignedShort();
+				ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag, pool[const_value_index],
+						const_value_index);
+				break;
+
+			case 'e' :
+				int type_name_index = in.readUnsignedShort();
+				int const_name_index = in.readUnsignedShort();
+				ps.printf("%-30s %c %s(#%d) %s(#%d)\n", indent + "type+const", tag, pool[type_name_index],
+						type_name_index, pool[const_name_index], const_name_index);
+				break;
+
+			case 'c' :
+				int class_info_index = in.readUnsignedShort();
+				ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag, pool[class_info_index], class_info_index);
+				break;
+
+			case '@' :
+				ps.printf("%-30s %c\n", indent + "sub annotation", tag);
+				doAnnotation(in, indent);
+				break;
+
+			case '[' :
+				int num_values = in.readUnsignedShort();
+				ps.printf("%-30s %c num_values=%d\n", indent + "sub element value", tag, num_values);
+				for (int i = 0; i < num_values; i++) {
+					doElementValue(in, indent);
+				}
+				break;
+
+			default :
+				throw new IllegalArgumentException("Invalid value for Annotation ElementValue tag " + tag);
+		}
+	}
+
+	/**
+	 * <pre>
+	 *  LineNumberTable_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 line_number_table_length;
+	 * 		{  u2 start_pc;	     
+	 * 		   u2 line_number;	     
+	 * 		} line_number_table[line_number_table_length];
+	 * 	}
+	 * 
+	 * </pre>
+	 */
+	void doLineNumberTable(DataInputStream in, String indent) throws IOException {
+		int line_number_table_length = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "line number table length", line_number_table_length);
+		StringBuilder sb = new StringBuilder();
+		for (int i = 0; i < line_number_table_length; i++) {
+			int start_pc = in.readUnsignedShort();
+			int line_number = in.readUnsignedShort();
+			sb.append(start_pc);
+			sb.append("/");
+			sb.append(line_number);
+			sb.append(" ");
+		}
+		ps.printf("%-30s %d: %s\n", indent + "line number table", line_number_table_length, sb);
+	}
+
+	/**
+	 * <pre>
+	 * 	LocalVariableTable_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 local_variable_table_length;
+	 * 		{  u2 start_pc;
+	 * 		    u2 length;
+	 * 		    u2 name_index;
+	 * 		    u2 descriptor_index;
+	 * 		    u2 index;
+	 * 		} local_variable_table[local_variable_table_length];
+	 * 	}
+	 * </pre>
+	 */
+
+	void doLocalVariableTable(DataInputStream in, String indent) throws IOException {
+		int local_variable_table_length = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "local variable table length", local_variable_table_length);
+		for (int i = 0; i < local_variable_table_length; i++) {
+			int start_pc = in.readUnsignedShort();
+			int length = in.readUnsignedShort();
+			int name_index = in.readUnsignedShort();
+			int descriptor_index = in.readUnsignedShort();
+			int index = in.readUnsignedShort();
+			ps.printf("%-30s %d: %d/%d %s(#%d) %s(#%d)\n", indent, index, start_pc, length, pool[name_index],
+					name_index, pool[descriptor_index], descriptor_index);
+		}
+	}
+
+	/**
+	 * <pre>
+	 *    InnerClasses_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 number_of_classes;
+	 * 		{  u2 inner_class_info_index;	     
+	 * 		   u2 outer_class_info_index;	     
+	 * 		   u2 inner_name_index;	     
+	 * 		   u2 inner_class_access_flags;	     
+	 * 		} classes[number_of_classes];
+	 * 	}
+	 * </pre>
+	 */
+	void doInnerClasses(DataInputStream in, String indent) throws IOException {
+		int number_of_classes = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "number of classes", number_of_classes);
+		for (int i = 0; i < number_of_classes; i++) {
+			int inner_class_info_index = in.readUnsignedShort();
+			int outer_class_info_index = in.readUnsignedShort();
+			int inner_name_index = in.readUnsignedShort();
+			int inner_class_access_flags = in.readUnsignedShort();
+			printAccess(inner_class_access_flags);
+
+			String iname = "<>";
+			String oname = iname;
+
+			if (inner_class_info_index != 0)
+				iname = (String) pool[((Integer) pool[inner_class_info_index]).intValue()];
+			if (outer_class_info_index != 0)
+				oname = (String) pool[((Integer) pool[outer_class_info_index]).intValue()];
+
+			ps.printf("%-30s %d: %x %s(#%d/c) %s(#%d/c) %s(#%d) \n", indent, i, inner_class_access_flags, iname,
+					inner_class_info_index, oname, outer_class_info_index, pool[inner_name_index], inner_name_index);
+		}
+	}
+
+	void printClassAccess(int mod) {
+		ps.printf("%-30s", "Class Access");
+		if ((ACC_PUBLIC & mod) != 0)
+			ps.print(" public");
+		if ((ACC_FINAL & mod) != 0)
+			ps.print(" final");
+		if ((ACC_SUPER & mod) != 0)
+			ps.print(" super");
+		if ((ACC_INTERFACE & mod) != 0)
+			ps.print(" interface");
+		if ((ACC_ABSTRACT & mod) != 0)
+			ps.print(" abstract");
+
+		ps.println();
+	}
+
+	void printAccess(int mod) {
+		ps.printf("%-30s", "Access");
+		if (Modifier.isStatic(mod))
+			ps.print(" static");
+		if (Modifier.isAbstract(mod))
+			ps.print(" abstract");
+		if (Modifier.isPublic(mod))
+			ps.print(" public");
+		if (Modifier.isFinal(mod))
+			ps.print(" final");
+		if (Modifier.isInterface(mod))
+			ps.print(" interface");
+		if (Modifier.isNative(mod))
+			ps.print(" native");
+		if (Modifier.isPrivate(mod))
+			ps.print(" private");
+		if (Modifier.isProtected(mod))
+			ps.print(" protected");
+		if (Modifier.isStrict(mod))
+			ps.print(" strict");
+		if (Modifier.isSynchronized(mod))
+			ps.print(" synchronized");
+		if (Modifier.isTransient(mod))
+			ps.print(" transient");
+		if (Modifier.isVolatile(mod))
+			ps.print(" volatile");
+
+		ps.println();
+	}
+
+	public static void main(String args[]) throws Exception {
+		if (args.length == 0) {
+			System.err.println("clsd <class file>+");
+		}
+		for (int i = 0; i < args.length; i++) {
+			File f = new File(args[i]);
+			if (!f.isFile())
+				System.err.println("File does not exist or is directory " + f);
+			else {
+				ClassDumper cd = new ClassDumper(args[i]);
+				cd.dump(null);
+			}
+		}
+	}
 
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java Fri Jun 15 13:27:53 2012
@@ -4,24 +4,25 @@ import java.lang.reflect.*;
 import java.net.*;
 
 public class URLClassLoaderWrapper {
-	final URLClassLoader loader;
-	final Method addURL;
-	
+	final URLClassLoader	loader;
+	final Method			addURL;
+
 	public URLClassLoaderWrapper(ClassLoader loader) throws Exception {
 		this.loader = (URLClassLoader) loader;
 		addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
 		addURL.setAccessible(true);
 	}
-	
-	public void addURL(URL url) throws Exception  {
+
+	public void addURL(URL url) throws Exception {
 		try {
-		addURL.invoke(loader, url);
-		} catch( InvocationTargetException ite) {
+			addURL.invoke(loader, url);
+		}
+		catch (InvocationTargetException ite) {
 			throw (Exception) ite.getTargetException();
 		}
 	}
-	
-	public Class<?> loadClass(String name) throws Exception {
+
+	public Class< ? > loadClass(String name) throws Exception {
 		return loader.loadClass(name);
 	}
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java Fri Jun 15 13:27:53 2012
@@ -5,15 +5,14 @@ import java.util.*;
 import aQute.libg.log.*;
 import aQute.libg.qtokens.*;
 
-public class Clauses extends LinkedHashMap<String,Map<String,String>>{
+public class Clauses extends LinkedHashMap<String,Map<String,String>> {
 	private static final long	serialVersionUID	= 1L;
-	
+
 	/**
 	 * Standard OSGi header parser. This parser can handle the format clauses
 	 * ::= clause ( ',' clause ) + clause ::= name ( ';' name ) (';' key '='
-	 * value )
-	 * 
-	 * This is mapped to a Map { name => Map { attr|directive => value } }
+	 * value ) This is mapped to a Map { name => Map { attr|directive => value }
+	 * }
 	 * 
 	 * @param value
 	 * @return
@@ -36,9 +35,8 @@ public class Clauses extends LinkedHashM
 				String adname = qt.nextToken();
 				if ((del = qt.getSeparator()) != '=') {
 					if (hadAttribute)
-						throw new IllegalArgumentException(
-								"Header contains name field after attribute or directive: "
-										+ adname + " from " + value);
+						throw new IllegalArgumentException("Header contains name field after attribute or directive: "
+								+ adname + " from " + value);
 					aliases.add(adname);
 				} else {
 					String advalue = qt.nextToken();
@@ -51,10 +49,8 @@ public class Clauses extends LinkedHashM
 				String packageName = i.next();
 				if (result.containsKey(packageName)) {
 					if (logger != null)
-						logger
-								.warning("Duplicate package name in header: "
-										+ packageName
-										+ ". Multiple package names in one clause not supported in Bnd.");
+						logger.warning("Duplicate package name in header: " + packageName
+								+ ". Multiple package names in one clause not supported in Bnd.");
 				} else
 					result.put(packageName, clause);
 			}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java Fri Jun 15 13:27:53 2012
@@ -65,18 +65,18 @@ public class Selector {
 		StringBuilder sb = new StringBuilder();
 		for (int c = 0; c < string.length(); c++) {
 			switch (string.charAt(c)) {
-			case '.':
-				sb.append("\\.");
-				break;
-			case '*':
-				sb.append(".*");
-				break;
-			case '?':
-				sb.append(".?");
-				break;
-			default:
-				sb.append(string.charAt(c));
-				break;
+				case '.' :
+					sb.append("\\.");
+					break;
+				case '*' :
+					sb.append(".*");
+					break;
+				case '?' :
+					sb.append(".?");
+					break;
+				default :
+					sb.append(string.charAt(c));
+					break;
 			}
 		}
 		string = sb.toString();
@@ -101,17 +101,16 @@ public class Selector {
 
 	public static List<Selector> getInstructions(Clauses clauses) {
 		List<Selector> result = new ArrayList<Selector>();
-		for (Map.Entry<String, Map<String, String>> entry : clauses.entrySet()) {
+		for (Map.Entry<String,Map<String,String>> entry : clauses.entrySet()) {
 			Selector instruction = getPattern(entry.getKey());
 			result.add(instruction);
 		}
 		return result;
 	}
-	
-	public static <T> List<T> select(Collection<T> domain,
-			List<Selector> instructions) {
+
+	public static <T> List<T> select(Collection<T> domain, List<Selector> instructions) {
 		List<T> result = new ArrayList<T>();
-		Iterator<T> iterator = domain.iterator(); 
+		Iterator<T> iterator = domain.iterator();
 		value: while (iterator.hasNext()) {
 			T value = iterator.next();
 			for (Selector instruction : instructions) {
@@ -124,6 +123,5 @@ public class Selector {
 		}
 		return result;
 	}
-	
 
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/command/Command.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/command/Command.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/command/Command.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/command/Command.java Fri Jun 15 13:27:53 2012
@@ -12,7 +12,7 @@ public class Command {
 	boolean				trace;
 	Reporter			reporter;
 	List<String>		arguments	= new ArrayList<String>();
-	Map<String, String>	variables	= new LinkedHashMap<String, String>();
+	Map<String,String>	variables	= new LinkedHashMap<String,String>();
 	long				timeout		= 0;
 	File				cwd			= new File("").getAbsoluteFile();
 	static Timer		timer		= new Timer(Command.class.getName(), true);
@@ -24,8 +24,7 @@ public class Command {
 		this.fullCommand = fullCommand;
 	}
 
-	public Command() {
-	}
+	public Command() {}
 
 	public int execute(Appendable stdout, Appendable stderr) throws Exception {
 		return execute((InputStream) null, stdout, stderr);
@@ -44,7 +43,7 @@ public class Command {
 		String args[] = arguments.toArray(new String[arguments.size()]);
 		String vars[] = new String[variables.size()];
 		int i = 0;
-		for (Entry<String, String> s : variables.entrySet()) {
+		for (Entry<String,String> s : variables.entrySet()) {
 			vars[i++] = s.getKey() + "=" + s.getValue();
 		}
 
@@ -53,7 +52,6 @@ public class Command {
 		else
 			process = Runtime.getRuntime().exec(fullCommand, vars.length == 0 ? null : vars, cwd);
 
-		
 		// Make sure the command will not linger when we go
 		Runnable r = new Runnable() {
 			public void run() {
@@ -83,12 +81,12 @@ public class Command {
 				cout.start();
 				Collector cerr = new Collector(err, stderr);
 				cerr.start();
-	
+
 				try {
 					int c = in.read();
 					while (c >= 0) {
 						stdin.write(c);
-						if ( c == '\n')
+						if (c == '\n')
 							stdin.flush();
 						c = in.read();
 					}
@@ -98,13 +96,14 @@ public class Command {
 				}
 				catch (Exception e) {
 					// Who cares?
-				} finally {
+				}
+				finally {
 					stdin.close();
 				}
-				
+
 				if (reporter != null)
 					reporter.trace("exited process");
-				
+
 				cerr.join();
 				cout.join();
 				if (reporter != null)
@@ -120,15 +119,15 @@ public class Command {
 				timer.cancel();
 			Runtime.getRuntime().removeShutdownHook(hook);
 		}
-		
+
 		byte exitValue = (byte) process.waitFor();
 		if (reporter != null)
-			reporter.trace("cmd %s executed with result=%d, result: %s/%s, timedout=%s", arguments, exitValue,
-					stdout, stderr, timedout);
+			reporter.trace("cmd %s executed with result=%d, result: %s/%s, timedout=%s", arguments, exitValue, stdout,
+					stderr, timedout);
 
 		if (timedout)
 			return Integer.MIN_VALUE;
-		
+
 		return exitValue;
 	}
 
@@ -182,7 +181,7 @@ public class Command {
 					c = in.read();
 				}
 			}
-			catch( IOException e) {
+			catch (IOException e) {
 				// We assume the socket is closed
 			}
 			catch (Exception e) {
@@ -191,8 +190,7 @@ public class Command {
 					sb.append(e.toString());
 					sb.append("\n**************************************\n");
 				}
-				catch (IOException e1) {
-				}
+				catch (IOException e1) {}
 				if (reporter != null) {
 					reporter.trace("cmd exec: %s", e);
 				}
@@ -217,7 +215,7 @@ public class Command {
 
 	public void inherit() {
 		ProcessBuilder pb = new ProcessBuilder();
-		for (Entry<String, String> e : pb.environment().entrySet()) {
+		for (Entry<String,String> e : pb.environment().entrySet()) {
 			var(e.getKey(), e.getValue());
 		}
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java Fri Jun 15 13:27:53 2012
@@ -7,61 +7,57 @@ import java.security.spec.*;
 import java.util.regex.*;
 
 public class Crypto {
-	static final Pattern	RSA_PRIVATE	= Pattern
-												.compile("\\s*RSA\\.Private\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
-	static final Pattern	RSA_PUBLIC	= Pattern
-												.compile("\\s*RSA\\.Public\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
+	static final Pattern	RSA_PRIVATE	= Pattern.compile("\\s*RSA\\.Private\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
+	static final Pattern	RSA_PUBLIC	= Pattern.compile("\\s*RSA\\.Public\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
 
 	/**
-	 * 
 	 * @param <T>
 	 * @param spec
 	 * @return
 	 * @throws Exception
 	 */
-	@SuppressWarnings("unchecked") public static <T> T fromString(String spec, Class<T> c) throws Exception {
-		if ( PrivateKey.class.isAssignableFrom(c)) {
-			Matcher m = RSA_PRIVATE.matcher(spec); 
-			if ( m.matches()) {
-				return (T) RSA.createPrivate(  
-						new BigInteger(m.group(1)), new BigInteger(m.group(2)));
+	@SuppressWarnings("unchecked")
+	public static <T> T fromString(String spec, Class<T> c) throws Exception {
+		if (PrivateKey.class.isAssignableFrom(c)) {
+			Matcher m = RSA_PRIVATE.matcher(spec);
+			if (m.matches()) {
+				return (T) RSA.createPrivate(new BigInteger(m.group(1)), new BigInteger(m.group(2)));
 			}
-			throw new IllegalArgumentException("No such private key " + spec );
+			throw new IllegalArgumentException("No such private key " + spec);
 		}
-		
-		if ( PublicKey.class.isAssignableFrom(c)) {
-			Matcher m = RSA_PUBLIC.matcher(spec); 
-			if ( m.matches()) {
-				return (T) RSA.create( new RSAPublicKeySpec( 
-						new BigInteger(m.group(1)), new BigInteger(m.group(2))));
+
+		if (PublicKey.class.isAssignableFrom(c)) {
+			Matcher m = RSA_PUBLIC.matcher(spec);
+			if (m.matches()) {
+				return (T) RSA.create(new RSAPublicKeySpec(new BigInteger(m.group(1)), new BigInteger(m.group(2))));
 			}
-			throw new IllegalArgumentException("No such public key " + spec );			
+			throw new IllegalArgumentException("No such public key " + spec);
 		}
 		return null;
 	}
 
-	public static String toString( Object key ) {
-		if ( key instanceof RSAPrivateKey ) {
+	public static String toString(Object key) {
+		if (key instanceof RSAPrivateKey) {
 			RSAPrivateKey pk = (RSAPrivateKey) key;
 			return "RSA.Private(" + pk.getModulus() + ":" + pk.getPrivateExponent() + ")";
 		}
-		if ( key instanceof RSAPublicKey ) {
+		if (key instanceof RSAPublicKey) {
 			RSAPublicKey pk = (RSAPublicKey) key;
 			return "RSA.Private(" + pk.getModulus() + ":" + pk.getPublicExponent() + ")";
 		}
 		return null;
 	}
 
-
-//	public static <T extends Digest> Signer<T> signer(PrivateKey key, Digester<T> digester) throws NoSuchAlgorithmException {
-//		Signature s = Signature.getInstance(key.getAlgorithm() + "with" + digester.getAlgorithm());
-//		return new Signer<T>(s,digester);
-//	}
+	// public static <T extends Digest> Signer<T> signer(PrivateKey key,
+	// Digester<T> digester) throws NoSuchAlgorithmException {
+	// Signature s = Signature.getInstance(key.getAlgorithm() + "with" +
+	// digester.getAlgorithm());
+	// return new Signer<T>(s,digester);
+	// }
 
 	public static Verifier verifier(PublicKey key, Digest digest) throws NoSuchAlgorithmException {
 		Signature s = Signature.getInstance(key.getAlgorithm() + "with" + digest.getAlgorithm());
-		return new Verifier(s,digest);
+		return new Verifier(s, digest);
 	}
 
-	
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java Fri Jun 15 13:27:53 2012
@@ -10,30 +10,28 @@ public abstract class Digest {
 	protected Digest(byte[] checksum, int width) {
 		this.digest = checksum;
 		if (digest.length != width)
-			throw new IllegalArgumentException("Invalid width for digest: " + digest.length
-					+ " expected " + width);
+			throw new IllegalArgumentException("Invalid width for digest: " + digest.length + " expected " + width);
 	}
 
-
 	public byte[] digest() {
 		return digest;
 	}
 
-	@Override public String toString() {
+	@Override
+	public String toString() {
 		return String.format("%s(d=%s)", getAlgorithm(), Hex.toHexString(digest));
 	}
 
 	public abstract String getAlgorithm();
-	
-	
+
 	public boolean equals(Object other) {
-		if ( !(other instanceof Digest))
+		if (!(other instanceof Digest))
 			return false;
 
 		Digest d = (Digest) other;
 		return Arrays.equals(d.digest, digest);
 	}
-	
+
 	public int hashCode() {
 		return Arrays.hashCode(digest);
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java Fri Jun 15 13:27:53 2012
@@ -7,41 +7,45 @@ import aQute.lib.io.*;
 
 public abstract class Digester<T extends Digest> extends OutputStream {
 	protected MessageDigest	md;
-	OutputStream out[];
-	
-	public Digester(MessageDigest instance, OutputStream ... out) {
+	OutputStream			out[];
+
+	public Digester(MessageDigest instance, OutputStream... out) {
 		md = instance;
 		this.out = out;
 	}
-	
+
 	@Override
-	public void write( byte[] buffer, int offset, int length) throws IOException{
-		md.update(buffer,offset,length);
-		for ( OutputStream o : out ) {
+	public void write(byte[] buffer, int offset, int length) throws IOException {
+		md.update(buffer, offset, length);
+		for (OutputStream o : out) {
 			o.write(buffer, offset, length);
 		}
 	}
+
 	@Override
-	public void write( int b) throws IOException{
+	public void write(int b) throws IOException {
 		md.update((byte) b);
-		for ( OutputStream o : out ) {
+		for (OutputStream o : out) {
 			o.write(b);
 		}
 	}
-	
+
 	public MessageDigest getMessageDigest() throws Exception {
 		return md;
 	}
-	
+
 	public T from(InputStream in) throws Exception {
-		IO.copy(in,this);
+		IO.copy(in, this);
 		return digest();
 	}
-		
-	public void setOutputs(OutputStream ...out) {
+
+	public void setOutputs(OutputStream... out) {
 		this.out = out;
 	}
+
 	public abstract T digest() throws Exception;
-	public abstract T digest( byte [] bytes) throws Exception;
+
+	public abstract T digest(byte[] bytes) throws Exception;
+
 	public abstract String getAlgorithm();
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java Fri Jun 15 13:27:53 2012
@@ -1,8 +1,6 @@
 package aQute.libg.cryptography;
 
-
 public abstract class Key implements java.security.Key {
 	private static final long	serialVersionUID	= 1L;
 
-
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java Fri Jun 15 13:27:53 2012
@@ -3,32 +3,36 @@ package aQute.libg.cryptography;
 import java.io.*;
 import java.security.*;
 
-
-
 public class MD5 extends Digest {
-	public final static String ALGORITHM = "MD5";
-	
-	public static Digester<MD5> getDigester(OutputStream ... out) throws Exception {
+	public final static String	ALGORITHM	= "MD5";
+
+	public static Digester<MD5> getDigester(OutputStream... out) throws Exception {
 		return new Digester<MD5>(MessageDigest.getInstance(ALGORITHM), out) {
-			
-			@Override public MD5 digest() throws Exception {
+
+			@Override
+			public MD5 digest() throws Exception {
 				return new MD5(md.digest());
 			}
 
-			@Override public MD5 digest(byte[] bytes) {
+			@Override
+			public MD5 digest(byte[] bytes) {
 				return new MD5(bytes);
 			}
-			@Override public String getAlgorithm() {
+
+			@Override
+			public String getAlgorithm() {
 				return ALGORITHM;
 			}
 		};
 	}
-	
-	
+
 	public MD5(byte[] digest) {
-		super(digest,16);
+		super(digest, 16);
 	}
 
-	@Override public String getAlgorithm() { return ALGORITHM; }
+	@Override
+	public String getAlgorithm() {
+		return ALGORITHM;
+	}
 
 }
\ No newline at end of file

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java Fri Jun 15 13:27:53 2012
@@ -15,7 +15,8 @@ public class RSA {
 	static private KeyFactory getKeyFactory() {
 		try {
 			return KeyFactory.getInstance(ALGORITHM);
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			// built in
 		}
 		return null;
@@ -24,20 +25,23 @@ public class RSA {
 	public static RSAPrivateKey create(RSAPrivateKeySpec keyspec) throws InvalidKeySpecException {
 		return (RSAPrivateKey) factory.generatePrivate(keyspec);
 	}
+
 	public static RSAPublicKey create(RSAPublicKeySpec keyspec) throws InvalidKeySpecException {
 		return (RSAPublicKey) factory.generatePrivate(keyspec);
 	}
-	
+
 	public static RSAPublicKey createPublic(BigInteger m, BigInteger e) throws InvalidKeySpecException {
-		return create( new RSAPublicKeySpec(m,e));
+		return create(new RSAPublicKeySpec(m, e));
 	}
+
 	public static RSAPrivateKey createPrivate(BigInteger m, BigInteger e) throws InvalidKeySpecException {
-		return create( new RSAPrivateKeySpec(m,e));
+		return create(new RSAPrivateKeySpec(m, e));
 	}
-	
-	public static Pair<RSAPrivateKey, RSAPublicKey> generate() throws NoSuchAlgorithmException {
+
+	public static Pair<RSAPrivateKey,RSAPublicKey> generate() throws NoSuchAlgorithmException {
 		KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGORITHM);
 		KeyPair keypair = kpg.generateKeyPair();
-		return new Pair<RSAPrivateKey,RSAPublicKey>( (RSAPrivateKey) keypair.getPrivate(), (RSAPublicKey) keypair.getPublic());
+		return new Pair<RSAPrivateKey,RSAPublicKey>((RSAPrivateKey) keypair.getPrivate(),
+				(RSAPublicKey) keypair.getPublic());
 	}
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java Fri Jun 15 13:27:53 2012
@@ -3,33 +3,36 @@ package aQute.libg.cryptography;
 import java.io.*;
 import java.security.*;
 
-
-
 public class SHA1 extends Digest {
-	public final static String ALGORITHM = "SHA1";
-	
-	
-	public static Digester<SHA1> getDigester(OutputStream ... out  ) throws NoSuchAlgorithmException {
+	public final static String	ALGORITHM	= "SHA1";
+
+	public static Digester<SHA1> getDigester(OutputStream... out) throws NoSuchAlgorithmException {
 		MessageDigest md = MessageDigest.getInstance(ALGORITHM);
 		return new Digester<SHA1>(md, out) {
-			@Override public SHA1 digest() throws Exception {
+			@Override
+			public SHA1 digest() throws Exception {
 				return new SHA1(md.digest());
 			}
 
-			@Override public SHA1 digest(byte[] bytes) {
+			@Override
+			public SHA1 digest(byte[] bytes) {
 				return new SHA1(bytes);
 			}
-			@Override public String getAlgorithm() {
+
+			@Override
+			public String getAlgorithm() {
 				return ALGORITHM;
 			}
 		};
 	}
-	
+
 	public SHA1(byte[] b) {
 		super(b, 20);
 	}
 
-
-	@Override public String getAlgorithm() { return ALGORITHM; }
+	@Override
+	public String getAlgorithm() {
+		return ALGORITHM;
+	}
 
 }
\ No newline at end of file

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java Fri Jun 15 13:27:53 2012
@@ -3,33 +3,36 @@ package aQute.libg.cryptography;
 import java.io.*;
 import java.security.*;
 
-
-
 public class SHA256 extends Digest {
-	public final static String ALGORITHM = "SHA256";
-	
-	
-	public static Digester<SHA256> getDigester(OutputStream ... out  ) throws NoSuchAlgorithmException {
+	public final static String	ALGORITHM	= "SHA256";
+
+	public static Digester<SHA256> getDigester(OutputStream... out) throws NoSuchAlgorithmException {
 		MessageDigest md = MessageDigest.getInstance(ALGORITHM);
 		return new Digester<SHA256>(md, out) {
-			@Override public SHA256 digest() throws Exception {
+			@Override
+			public SHA256 digest() throws Exception {
 				return new SHA256(md.digest());
 			}
 
-			@Override public SHA256 digest(byte[] bytes) {
+			@Override
+			public SHA256 digest(byte[] bytes) {
 				return new SHA256(bytes);
 			}
-			@Override public String getAlgorithm() {
+
+			@Override
+			public String getAlgorithm() {
 				return ALGORITHM;
 			}
 		};
 	}
-	
+
 	public SHA256(byte[] b) {
 		super(b, 32);
 	}
 
-
-	@Override public String getAlgorithm() { return ALGORITHM; }
+	@Override
+	public String getAlgorithm() {
+		return ALGORITHM;
+	}
 
 }
\ No newline at end of file

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java Fri Jun 15 13:27:53 2012
@@ -5,36 +5,39 @@ import java.security.*;
 
 public class Signer<D extends Digest> extends OutputStream {
 	Signature	signature;
-	Digester<D> digester;
-	
+	Digester<D>	digester;
+
 	Signer(Signature s, Digester<D> digester) {
 		this.signature = s;
-		this.digester  = digester;
+		this.digester = digester;
 	}
 
-	@Override public void write(byte[] buffer, int offset, int length) throws IOException {
+	@Override
+	public void write(byte[] buffer, int offset, int length) throws IOException {
 		try {
 			signature.update(buffer, offset, length);
 			digester.write(buffer, offset, length);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
 
-	@Override public void write(int b) throws IOException {
+	@Override
+	public void write(int b) throws IOException {
 		try {
 			signature.update((byte) b);
 			digester.write(b);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
-	
 
 	public Signature signature() throws Exception {
 		return signature;
 	}
-	
+
 	public D digest() throws Exception {
 		return digester.digest();
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java Fri Jun 15 13:27:53 2012
@@ -3,30 +3,31 @@ package aQute.libg.cryptography;
 import java.io.*;
 import java.security.*;
 
-
 public class Verifier extends OutputStream {
-	final Signature signature;
-	final Digest d;
-	
+	final Signature	signature;
+	final Digest	d;
+
 	Verifier(Signature s, Digest d) {
 		this.signature = s;
 		this.d = d;
 	}
-	
+
 	@Override
-	public void write( byte[] buffer, int offset, int length) throws IOException {
+	public void write(byte[] buffer, int offset, int length) throws IOException {
 		try {
 			signature.update(buffer, offset, length);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
 
 	@Override
-	public void write( int b) throws IOException {
+	public void write(int b) throws IOException {
 		try {
 			signature.update((byte) b);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
@@ -34,5 +35,5 @@ public class Verifier extends OutputStre
 	public boolean verify() throws Exception {
 		return signature.verify(d.digest());
 	}
-	
+
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java Fri Jun 15 13:27:53 2012
@@ -4,40 +4,39 @@ import java.io.*;
 import java.util.*;
 
 public class FileIterator implements Iterator<File> {
-    File         dir;
-    int          n = 0;
-    FileIterator next;
+	File			dir;
+	int				n	= 0;
+	FileIterator	next;
 
-    public FileIterator(File nxt) {
-        assert nxt.isDirectory();
-        this.dir = nxt;
-    }
+	public FileIterator(File nxt) {
+		assert nxt.isDirectory();
+		this.dir = nxt;
+	}
 
-    public boolean hasNext() {
-        if (next != null)
-            return next.hasNext();
+	public boolean hasNext() {
+		if (next != null)
+			return next.hasNext();
 		return n < dir.list().length;
-    }
+	}
 
-    public File next() {
-        if (next != null) {
-            File answer = next.next();
-            if (!next.hasNext())
-                next = null;
-            return answer;
-        }
+	public File next() {
+		if (next != null) {
+			File answer = next.next();
+			if (!next.hasNext())
+				next = null;
+			return answer;
+		}
 		File nxt = dir.listFiles()[n++];
 		if (nxt.isDirectory()) {
-		    next = new FileIterator(nxt);
-		    return nxt;
+			next = new FileIterator(nxt);
+			return nxt;
 		} else if (nxt.isFile()) {
-		    return nxt;
+			return nxt;
 		} else
-		    throw new IllegalStateException("File disappeared");
-    }
+			throw new IllegalStateException("File disappeared");
+	}
 
-    public void remove() {
-        throw new UnsupportedOperationException(
-                "Cannot remove from a file iterator");
-    }
+	public void remove() {
+		throw new UnsupportedOperationException("Cannot remove from a file iterator");
+	}
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java Fri Jun 15 13:27:53 2012
@@ -3,9 +3,9 @@ package aQute.libg.filelock;
 import java.io.*;
 
 public class DirectoryLock {
-	final File						lock;
-	final long						timeout;
-	final public static String LOCKNAME = ".lock";
+	final File					lock;
+	final long					timeout;
+	final public static String	LOCKNAME	= ".lock";
 
 	public DirectoryLock(File directory, long timeout) {
 		this.lock = new File(directory, LOCKNAME);
@@ -13,7 +13,6 @@ public class DirectoryLock {
 		this.timeout = timeout;
 	}
 
-	
 	public void release() {
 		lock.delete();
 	}
@@ -22,10 +21,10 @@ public class DirectoryLock {
 		if (lock.mkdir())
 			return;
 
-		long deadline = System.currentTimeMillis()+ timeout;
-		while ( System.currentTimeMillis() < deadline) {
+		long deadline = System.currentTimeMillis() + timeout;
+		while (System.currentTimeMillis() < deadline) {
 			if (lock.mkdir())
-				return;	
+				return;
 			Thread.sleep(50);
 		}
 	}

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java Fri Jun 15 13:27:53 2012
@@ -39,9 +39,9 @@ public class FileRepo {
 				Matcher m = REPO_FILE.matcher(name);
 				if (!m.matches())
 					return false;
-				if ( versionRange == null)
+				if (versionRange == null)
 					return true;
-				
+
 				Version v = new Version(m.group(2));
 				return versionRange.includes(v);
 			}
@@ -97,10 +97,11 @@ public class FileRepo {
 	}
 
 	public File put(String bsn, Version version) {
-		File dir = new File(root,bsn);
+		File dir = new File(root, bsn);
 		dir.mkdirs();
-		File file = new File(dir, bsn + "-" + version.getMajor() + "." + version.getMinor() + "." + version.getMicro() + ".jar");
+		File file = new File(dir, bsn + "-" + version.getMajor() + "." + version.getMinor() + "." + version.getMicro()
+				+ ".jar");
 		return file;
 	}
-	
+
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/forker/Forker.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/forker/Forker.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/forker/Forker.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/forker/Forker.java Fri Jun 15 13:27:53 2012
@@ -12,12 +12,11 @@ import java.util.concurrent.atomic.*;
  * have ran their associated runnable.
  * 
  * @author aqute
- * 
  * @param <T>
  */
 public class Forker<T> {
 	final Executor		executor;
-	final Map<T, Job>	waiting		= new HashMap<T, Job>();
+	final Map<T,Job>	waiting		= new HashMap<T,Job>();
 	final Set<Job>		executing	= new HashSet<Job>();
 	final AtomicBoolean	canceled	= new AtomicBoolean();
 	private int			count;
@@ -48,10 +47,12 @@ public class Forker<T> {
 					t = Thread.currentThread();
 				}
 				runnable.run();
-			} catch (Exception e) {
+			}
+			catch (Exception e) {
 				exception = e;
 				e.printStackTrace();
-			} finally {
+			}
+			finally {
 				synchronized (this) {
 					t = null;
 				}
@@ -84,7 +85,6 @@ public class Forker<T> {
 
 	/**
 	 * Constructor
-	 * 
 	 */
 	public Forker() {
 		this.executor = Executors.newFixedThreadPool(4);
@@ -101,8 +101,7 @@ public class Forker<T> {
 	 * @param runnable
 	 *            the runnable to run
 	 */
-	public synchronized void doWhen(Collection<? extends T> dependencies, T target,
-			Runnable runnable) {
+	public synchronized void doWhen(Collection< ? extends T> dependencies, T target, Runnable runnable) {
 		if (waiting.containsKey(target))
 			throw new IllegalArgumentException("You can only add a target once to the forker");
 
@@ -130,8 +129,7 @@ public class Forker<T> {
 		dependencies.removeAll(waiting.keySet());
 		if (dependencies.size() > 0)
 			throw new IllegalArgumentException(
-					"There are dependencies in the jobs that are not present in the targets: "
-							+ dependencies);
+					"There are dependencies in the jobs that are not present in the targets: " + dependencies);
 
 	}
 
@@ -181,8 +179,9 @@ public class Forker<T> {
 
 			for (Job job : waiting.values()) {
 				// boolean x =
-					job.dependencies.remove(done.target);
-				//System.err.println( "Removing " + done.target + " from " + job.target + " ?" + x  + " " + job.dependencies.size());
+				job.dependencies.remove(done.target);
+				// System.err.println( "Removing " + done.target + " from " +
+				// job.target + " ?" + x + " " + job.dependencies.size());
 			}
 		}
 		schedule();

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/generics/Create.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/generics/Create.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/generics/Create.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/generics/Create.java Fri Jun 15 13:27:53 2012
@@ -3,52 +3,51 @@ package aQute.libg.generics;
 import java.util.*;
 
 public class Create {
-    
-    public static <K,V>  Map<K, V> map() {
-        return new LinkedHashMap<K,V>();
-    }
-
-    public static <K,V>  Map<K, V> map(Class<K> key, Class<V> value) {
-        return Collections.checkedMap(new LinkedHashMap<K,V>(), key,value);
-    }
-
-    public static <T>  List<T> list() {
-        return new ArrayList<T>();
-    }
-
-    public static <T>  List<T> list(Class<T> c) {
-        return Collections.checkedList(new ArrayList<T>(),c) ;
-    }
-
-    public static <T>  Set<T> set() {
-        return new HashSet<T>();
-    }
-
-    public static <T>  Set<T> set(Class<T> c) {
-        return Collections.checkedSet(new HashSet<T>(),c);
-    }
-
-    public static <T>  List<T> list(T[] source) {
-        return new ArrayList<T>(Arrays.asList(source));
-    }
-
-    public static <T>  Set<T> set(T[]source) {
-        return new HashSet<T>(Arrays.asList(source));
-    }
-
-    public static <K,V>  Map<K, V> copy(Map<K,V> source) {
-        return new LinkedHashMap<K,V>(source);
-    }
-
-    public static <T>  List<T> copy(List<T> source) {
-        return new ArrayList<T>(source);
-    }
-
-    public static <T>  Set<T> copy(Collection<T> source) {
-        if ( source == null )
-            return set();
-        return new HashSet<T>(source);
-    }
 
-    
+	public static <K, V> Map<K,V> map() {
+		return new LinkedHashMap<K,V>();
+	}
+
+	public static <K, V> Map<K,V> map(Class<K> key, Class<V> value) {
+		return Collections.checkedMap(new LinkedHashMap<K,V>(), key, value);
+	}
+
+	public static <T> List<T> list() {
+		return new ArrayList<T>();
+	}
+
+	public static <T> List<T> list(Class<T> c) {
+		return Collections.checkedList(new ArrayList<T>(), c);
+	}
+
+	public static <T> Set<T> set() {
+		return new HashSet<T>();
+	}
+
+	public static <T> Set<T> set(Class<T> c) {
+		return Collections.checkedSet(new HashSet<T>(), c);
+	}
+
+	public static <T> List<T> list(T[] source) {
+		return new ArrayList<T>(Arrays.asList(source));
+	}
+
+	public static <T> Set<T> set(T[] source) {
+		return new HashSet<T>(Arrays.asList(source));
+	}
+
+	public static <K, V> Map<K,V> copy(Map<K,V> source) {
+		return new LinkedHashMap<K,V>(source);
+	}
+
+	public static <T> List<T> copy(List<T> source) {
+		return new ArrayList<T>(source);
+	}
+
+	public static <T> Set<T> copy(Collection<T> source) {
+		if (source == null)
+			return set();
+		return new HashSet<T>(source);
+	}
+
 }

Modified: felix/trunk/bundleplugin/src/main/java/aQute/libg/glob/Glob.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/aQute/libg/glob/Glob.java?rev=1350613&r1=1350612&r2=1350613&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/aQute/libg/glob/Glob.java (original)
+++ felix/trunk/bundleplugin/src/main/java/aQute/libg/glob/Glob.java Fri Jun 15 13:27:53 2012
@@ -1,22 +1,21 @@
 package aQute.libg.glob;
 
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.regex.*;
 
 public class Glob {
 
-	private final String glob;
-	private final Pattern pattern;
-	
+	private final String	glob;
+	private final Pattern	pattern;
+
 	public Glob(String globString) {
 		this.glob = globString;
 		this.pattern = Pattern.compile(convertGlobToRegEx(globString));
 	}
-	
+
 	public Matcher matcher(CharSequence input) {
 		return pattern.matcher(input);
 	}
-	
+
 	@Override
 	public String toString() {
 		return glob;
@@ -39,70 +38,70 @@ public class Glob {
 		int inCurlies = 0;
 		for (char currentChar : line.toCharArray()) {
 			switch (currentChar) {
-			case '*':
-				if (escaping)
-					sb.append("\\*");
-				else
-					sb.append(".*");
-				escaping = false;
-				break;
-			case '?':
-				if (escaping)
-					sb.append("\\?");
-				else
-					sb.append('.');
-				escaping = false;
-				break;
-			case '.':
-			case '(':
-			case ')':
-			case '+':
-			case '|':
-			case '^':
-			case '$':
-			case '@':
-			case '%':
-				sb.append('\\');
-				sb.append(currentChar);
-				escaping = false;
-				break;
-			case '\\':
-				if (escaping) {
-					sb.append("\\\\");
-					escaping = false;
-				} else
-					escaping = true;
-				break;
-			case '{':
-				if (escaping) {
-					sb.append("\\{");
-				} else {
-					sb.append('(');
-					inCurlies++;
-				}
-				escaping = false;
-				break;
-			case '}':
-				if (inCurlies > 0 && !escaping) {
-					sb.append(')');
-					inCurlies--;
-				} else if (escaping)
-					sb.append("\\}");
-				else
-					sb.append("}");
-				escaping = false;
-				break;
-			case ',':
-				if (inCurlies > 0 && !escaping) {
-					sb.append('|');
-				} else if (escaping)
-					sb.append("\\,");
-				else
-					sb.append(",");
-				break;
-			default:
-				escaping = false;
-				sb.append(currentChar);
+				case '*' :
+					if (escaping)
+						sb.append("\\*");
+					else
+						sb.append(".*");
+					escaping = false;
+					break;
+				case '?' :
+					if (escaping)
+						sb.append("\\?");
+					else
+						sb.append('.');
+					escaping = false;
+					break;
+				case '.' :
+				case '(' :
+				case ')' :
+				case '+' :
+				case '|' :
+				case '^' :
+				case '$' :
+				case '@' :
+				case '%' :
+					sb.append('\\');
+					sb.append(currentChar);
+					escaping = false;
+					break;
+				case '\\' :
+					if (escaping) {
+						sb.append("\\\\");
+						escaping = false;
+					} else
+						escaping = true;
+					break;
+				case '{' :
+					if (escaping) {
+						sb.append("\\{");
+					} else {
+						sb.append('(');
+						inCurlies++;
+					}
+					escaping = false;
+					break;
+				case '}' :
+					if (inCurlies > 0 && !escaping) {
+						sb.append(')');
+						inCurlies--;
+					} else if (escaping)
+						sb.append("\\}");
+					else
+						sb.append("}");
+					escaping = false;
+					break;
+				case ',' :
+					if (inCurlies > 0 && !escaping) {
+						sb.append('|');
+					} else if (escaping)
+						sb.append("\\,");
+					else
+						sb.append(",");
+					break;
+				default :
+					escaping = false;
+					sb.append(currentChar);
 			}
 		}
 		return sb.toString();



Mime
View raw message