View | Details | Raw Unified | Return to bug 56953
Collapse All | Expand All

(-)a/Constants.java (-7 / +5 lines)
Lines 20-25 package org.apache.tomcat.util.bcel; Link Here
20
/**
20
/**
21
 * Constants for the project, mostly defined in the JVM specification.
21
 * Constants for the project, mostly defined in the JVM specification.
22
 *
22
 *
23
 * @version $Id$
23
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
24
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
24
 */
25
 */
25
public interface Constants {
26
public interface Constants {
Lines 511-527 public interface Constants { Link Here
511
  public static final byte ATTR_SIGNATURE                               = 10;
512
  public static final byte ATTR_SIGNATURE                               = 10;
512
  public static final byte ATTR_STACK_MAP                               = 11;
513
  public static final byte ATTR_STACK_MAP                               = 11;
513
  public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS             = 12;
514
  public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS             = 12;
514
  public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS           = 13;
515
  public static final byte ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS           = 13;
515
  public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS   = 14;
516
  public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS   = 14;
516
  public static final byte ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = 15;
517
  public static final byte ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS = 15;
517
  public static final byte ATTR_ANNOTATION_DEFAULT                      = 16;
518
  public static final byte ATTR_ANNOTATION_DEFAULT                      = 16;
518
  public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE               = 17;
519
  public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE               = 17;
519
  public static final byte ATTR_ENCLOSING_METHOD                        = 18;
520
  public static final byte ATTR_ENCLOSING_METHOD                        = 18;
520
  public static final byte ATTR_STACK_MAP_TABLE                         = 19;
521
  public static final byte ATTR_STACK_MAP_TABLE                         = 19;
521
  public static final byte ATTR_BOOTSTRAP_METHODS                       = 20;
522
  public static final byte ATTR_METHOD_PARAMETERS                       = 21;
523
522
524
  public static final short KNOWN_ATTRIBUTES = 22;
523
  public static final short KNOWN_ATTRIBUTES = 20;
525
524
526
  // TOFO: FIXXXXX
525
  // TOFO: FIXXXXX
527
  public static final String[] ATTRIBUTE_NAMES = {
526
  public static final String[] ATTRIBUTE_NAMES = {
Lines 531-538 public interface Constants { Link Here
531
    "PMGClass", "Signature", "StackMap", 
530
    "PMGClass", "Signature", "StackMap", 
532
    "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
531
    "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
533
    "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
532
    "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
534
    "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", "StackMapTable",
533
    "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod", "StackMapTable"
535
    "BootstrapMethods", "MethodParameters"
536
  };
534
  };
537
535
538
  /** Constants used in the StackMap attribute.
536
  /** Constants used in the StackMap attribute.
(-)a/classfile/AccessFlags.java (+1 lines)
Lines 21-26 package org.apache.tomcat.util.bcel.classfile; Link Here
21
 * Super class for all objects that have modifiers like private, final, ...
21
 * Super class for all objects that have modifiers like private, final, ...
22
 * I.e. classes, fields, and methods.
22
 * I.e. classes, fields, and methods.
23
 *
23
 *
24
 * @version $Id$
24
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
25
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
25
 */
26
 */
26
public abstract class AccessFlags implements java.io.Serializable {
27
public abstract class AccessFlags implements java.io.Serializable {
(-)a/classfile/AnnotationDefault.java (-3 / +5 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-32 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/**
25
/**
26
 * represents the default value of a annotation for a method info
26
 * represents the default value of a annotation for a method info
27
 * 
27
 * 
28
 * @version $Id: AnnotationDefault 1 2005-02-13 03:15:08Z dbrosius $
28
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
29
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
29
 * @since 6.0
30
 * @since 5.3
30
 */
31
 */
31
public class AnnotationDefault extends Attribute
32
public class AnnotationDefault extends Attribute
32
{
33
{
Lines 44-50 public class AnnotationDefault extends Attribute Link Here
44
     *            Array of constants
45
     *            Array of constants
45
     */
46
     */
46
    public AnnotationDefault(int name_index, int length,
47
    public AnnotationDefault(int name_index, int length,
47
            DataInputStream file, ConstantPool constant_pool)
48
            DataInput file, ConstantPool constant_pool)
48
            throws IOException
49
            throws IOException
49
    {
50
    {
50
        this(name_index, length, (ElementValue) null,
51
        this(name_index, length, (ElementValue) null,
Lines 52-57 public class AnnotationDefault extends Attribute Link Here
52
        default_value = ElementValue.readElementValue(file, constant_pool);
53
        default_value = ElementValue.readElementValue(file, constant_pool);
53
    }
54
    }
54
55
56
55
    /**
57
    /**
56
     * @param name_index
58
     * @param name_index
57
     *            Index pointing to the name <em>Code</em>
59
     *            Index pointing to the name <em>Code</em>
(-)a/classfile/AnnotationElementValue.java (-4 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataOutputStream;
20
import java.io.DataOutput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
public class AnnotationElementValue extends ElementValue
23
public class AnnotationElementValue extends ElementValue
Lines 29-43 public class AnnotationElementValue extends ElementValue Link Here
29
            ConstantPool cpool)
29
            ConstantPool cpool)
30
    {
30
    {
31
        super(type, cpool);
31
        super(type, cpool);
32
        if (type != ANNOTATION) {
32
        if (type != ANNOTATION)
33
            throw new RuntimeException(
33
            throw new RuntimeException(
34
                    "Only element values of type annotation can be built with this ctor - type specified: " + type);
34
                    "Only element values of type annotation can be built with this ctor - type specified: " + type);
35
        }
36
        this.annotationEntry = annotationEntry;
35
        this.annotationEntry = annotationEntry;
37
    }
36
    }
38
37
39
    @Override
38
    @Override
40
    public void dump(DataOutputStream dos) throws IOException
39
    public void dump(DataOutput dos) throws IOException
41
    {
40
    {
42
        dos.writeByte(type); // u1 type of value (ANNOTATION == '@')
41
        dos.writeByte(type); // u1 type of value (ANNOTATION == '@')
43
        annotationEntry.dump(dos);
42
        annotationEntry.dump(dos);
(-)a/classfile/AnnotationEntry.java (-8 / +6 lines)
Lines 17-26 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.*;
21
import java.io.DataOutputStream;
22
import java.io.IOException;
23
import java.io.Serializable;
24
import java.util.ArrayList;
21
import java.util.ArrayList;
25
import java.util.List;
22
import java.util.List;
26
23
Lines 29-36 import org.apache.tomcat.util.bcel.Constants; Link Here
29
/**
26
/**
30
 * represents one annotation in the annotation table
27
 * represents one annotation in the annotation table
31
 * 
28
 * 
29
 * @version $Id: AnnotationEntry
32
 * @author  <A HREF="mailto:dbrosius@mebigfatguy.com">D. Brosius</A>
30
 * @author  <A HREF="mailto:dbrosius@mebigfatguy.com">D. Brosius</A>
33
 * @since 6.0
31
 * @since 5.3
34
 */
32
 */
35
public class AnnotationEntry implements Constants, Serializable {
33
public class AnnotationEntry implements Constants, Serializable {
36
34
Lines 42-55 public class AnnotationEntry implements Constants, Serializable { Link Here
42
    private List<ElementValuePair> element_value_pairs;
40
    private List<ElementValuePair> element_value_pairs;
43
    
41
    
44
    /**
42
    /**
45
     * Factory method to create an AnnotionEntry from a DataInputStream
43
     * Factory method to create an AnnotionEntry from a DataInput
46
     * 
44
     * 
47
     * @param file
45
     * @param file
48
     * @param constant_pool
46
     * @param constant_pool
49
     * @return the entry
47
     * @return the entry
50
     * @throws IOException
48
     * @throws IOException
51
     */
49
     */
52
    public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool) throws IOException {
50
    public static AnnotationEntry read(DataInput file, ConstantPool constant_pool) throws IOException {
53
        
51
        
54
        final AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool);
52
        final AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool);
55
        final int num_element_value_pairs = (file.readUnsignedShort());
53
        final int num_element_value_pairs = (file.readUnsignedShort());
Lines 82-88 public class AnnotationEntry implements Constants, Serializable { Link Here
82
        return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]);
80
        return element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]);
83
    }
81
    }
84
82
85
    public void dump(DataOutputStream dos) throws IOException {
83
    public void dump(DataOutput dos) throws IOException {
86
        dos.writeShort(type_index); // u2 index of type name in cpool
84
        dos.writeShort(type_index); // u2 index of type name in cpool
87
        dos.writeShort(element_value_pairs.size()); // u2 element_value pair
85
        dos.writeShort(element_value_pairs.size()); // u2 element_value pair
88
        // count
86
        // count
(-)a/classfile/Annotations.java (-5 / +6 lines)
Lines 17-31 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.DataOutputStream;
21
import java.io.DataOutput;
22
import java.io.IOException;
22
import java.io.IOException;
23
23
24
/**
24
/**
25
 * base class for annotations
25
 * base class for annotations
26
 * 
26
 * 
27
 * @version $Id: Annotations
27
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
28
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
28
 * @since 6.0
29
 * @since 5.3
29
 */
30
 */
30
public abstract class Annotations extends Attribute {
31
public abstract class Annotations extends Attribute {
31
32
Lines 40-46 public abstract class Annotations extends Attribute { Link Here
40
     * @param file Input stream
41
     * @param file Input stream
41
     * @param constant_pool Array of constants
42
     * @param constant_pool Array of constants
42
     */
43
     */
43
    public Annotations(byte annotation_type, int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
44
    public Annotations(byte annotation_type, int name_index, int length, DataInput file, ConstantPool constant_pool) throws IOException {
44
        this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
45
        this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
45
        final int annotation_table_length = (file.readUnsignedShort());
46
        final int annotation_table_length = (file.readUnsignedShort());
46
        annotation_table = new AnnotationEntry[annotation_table_length];
47
        annotation_table = new AnnotationEntry[annotation_table_length];
Lines 76-82 public abstract class Annotations extends Attribute { Link Here
76
        return annotation_table;
77
        return annotation_table;
77
    }
78
    }
78
79
79
    protected void writeAnnotations(DataOutputStream dos) throws IOException {
80
    protected void writeAnnotations(DataOutput dos) throws IOException {
80
        if (annotation_table == null) {
81
        if (annotation_table == null) {
81
            return;
82
            return;
82
        }
83
        }
(-)a/classfile/ArrayElementValue.java (-6 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataOutputStream;
20
import java.io.DataOutput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
public class ArrayElementValue extends ElementValue
23
public class ArrayElementValue extends ElementValue
Lines 43-57 public class ArrayElementValue extends ElementValue Link Here
43
    public ArrayElementValue(int type, ElementValue[] datums, ConstantPool cpool)
43
    public ArrayElementValue(int type, ElementValue[] datums, ConstantPool cpool)
44
    {
44
    {
45
        super(type, cpool);
45
        super(type, cpool);
46
        if (type != ARRAY) {
46
        if (type != ARRAY)
47
            throw new RuntimeException(
47
            throw new RuntimeException(
48
                    "Only element values of type array can be built with this ctor - type specified: " + type);
48
                    "Only element values of type array can be built with this ctor - type specified: " + type);
49
        }
50
        this.evalues = datums;
49
        this.evalues = datums;
51
    }
50
    }
52
51
53
    @Override
52
    @Override
54
    public void dump(DataOutputStream dos) throws IOException
53
    public void dump(DataOutput dos) throws IOException
55
    {
54
    {
56
        dos.writeByte(type); // u1 type of value (ARRAY == '[')
55
        dos.writeByte(type); // u1 type of value (ARRAY == '[')
57
        dos.writeShort(evalues.length);
56
        dos.writeShort(evalues.length);
Lines 69-77 public class ArrayElementValue extends ElementValue Link Here
69
        for (int i = 0; i < evalues.length; i++)
68
        for (int i = 0; i < evalues.length; i++)
70
        {
69
        {
71
            sb.append(evalues[i].stringifyValue());
70
            sb.append(evalues[i].stringifyValue());
72
            if ((i + 1) < evalues.length) {
71
            if ((i + 1) < evalues.length)
73
                sb.append(",");
72
                sb.append(",");
74
            }
75
        }
73
        }
76
        sb.append("]");
74
        sb.append("]");
77
        return sb.toString();
75
        return sb.toString();
(-)a/classfile/Attribute.java (-10 / +5 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
import java.io.Serializable;
22
import java.io.Serializable;
23
import java.util.HashMap;
23
import java.util.HashMap;
Lines 33-38 import org.apache.tomcat.util.bcel.Constants; Link Here
33
 * <em>Synthetic</em> attributes are supported. The <em>Unknown</em>
33
 * <em>Synthetic</em> attributes are supported. The <em>Unknown</em>
34
 * attribute stands for non-standard-attributes.
34
 * attribute stands for non-standard-attributes.
35
 * 
35
 * 
36
 * @version $Id$
36
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
37
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
37
 * @see ConstantValue
38
 * @see ConstantValue
38
 * @see SourceFile
39
 * @see SourceFile
Lines 80-86 public abstract class Attribute implements Cloneable, Serializable Link Here
80
     *      constants @return Attribute @throws IOException @throws
81
     *      constants @return Attribute @throws IOException @throws
81
     *      ClassFormatException
82
     *      ClassFormatException
82
     */
83
     */
83
    public static final Attribute readAttribute(DataInputStream file,
84
    public static final Attribute readAttribute(DataInput file,
84
            ConstantPool constant_pool) throws IOException,
85
            ConstantPool constant_pool) throws IOException,
85
            ClassFormatException
86
            ClassFormatException
86
    {
87
    {
Lines 145-157 public abstract class Attribute implements Cloneable, Serializable Link Here
145
        case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
146
        case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
146
            return new RuntimeVisibleAnnotations(name_index, length, file,
147
            return new RuntimeVisibleAnnotations(name_index, length, file,
147
                    constant_pool);
148
                    constant_pool);
148
        case Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS:
149
        case Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS:
149
            return new RuntimeInvisibleAnnotations(name_index, length, file,
150
            return new RuntimeInvisibleAnnotations(name_index, length, file,
150
                    constant_pool);
151
                    constant_pool);
151
        case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
152
        case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
152
            return new RuntimeVisibleParameterAnnotations(name_index, length,
153
            return new RuntimeVisibleParameterAnnotations(name_index, length,
153
                    file, constant_pool);
154
                    file, constant_pool);
154
        case Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS:
155
        case Constants.ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS:
155
            return new RuntimeInvisibleParameterAnnotations(name_index, length,
156
            return new RuntimeInvisibleParameterAnnotations(name_index, length,
156
                    file, constant_pool);
157
                    file, constant_pool);
157
        case Constants.ATTR_ANNOTATION_DEFAULT:
158
        case Constants.ATTR_ANNOTATION_DEFAULT:
Lines 164-175 public abstract class Attribute implements Cloneable, Serializable Link Here
164
            return new EnclosingMethod(name_index, length, file, constant_pool);
165
            return new EnclosingMethod(name_index, length, file, constant_pool);
165
        case Constants.ATTR_STACK_MAP_TABLE:
166
        case Constants.ATTR_STACK_MAP_TABLE:
166
            return new StackMapTable(name_index, length, file, constant_pool);
167
            return new StackMapTable(name_index, length, file, constant_pool);
167
        case Constants.ATTR_BOOTSTRAP_METHODS:
168
            Utility.swallowBootstrapMethods(file);
169
            return null;
170
        case Constants.ATTR_METHOD_PARAMETERS:
171
            Utility.swallowMethodParameters(file);
172
            return null;
173
        default: // Never reached
168
        default: // Never reached
174
            throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag);
169
            throw new IllegalStateException("Unrecognized attribute type tag parsed: " + tag);
175
        }
170
        }
(-)a/classfile/AttributeReader.java (-1 / +2 lines)
Lines 23-28 package org.apache.tomcat.util.bcel.classfile; Link Here
23
 * method. These factory objects should implement this interface.
23
 * method. These factory objects should implement this interface.
24
24
25
 * @see Attribute
25
 * @see Attribute
26
 * @version $Id$
26
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
27
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
27
 */
28
 */
28
public interface AttributeReader {
29
public interface AttributeReader {
Lines 51-56 public interface AttributeReader { Link Here
51
     it to construct an attribute.  In the case of errors, a null can be
52
     it to construct an attribute.  In the case of errors, a null can be
52
     returned which will cause the parsing of the class file to fail.
53
     returned which will cause the parsing of the class file to fail.
53
     */
54
     */
54
    Attribute createAttribute( int name_index, int length, java.io.DataInputStream file,
55
    Attribute createAttribute( int name_index, int length, java.io.DataInput file,
55
            ConstantPool constant_pool );
56
            ConstantPool constant_pool );
56
}
57
}
(-)a/classfile/ClassElementValue.java (-1 / +2 lines)
Lines 17-22 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataOutput;
20
import java.io.DataOutputStream;
21
import java.io.DataOutputStream;
21
import java.io.IOException;
22
import java.io.IOException;
22
23
Lines 45-51 public class ClassElementValue extends ElementValue Link Here
45
    }
46
    }
46
47
47
    @Override
48
    @Override
48
    public void dump(DataOutputStream dos) throws IOException
49
    public void dump(DataOutput dos) throws IOException
49
    {
50
    {
50
        dos.writeByte(type); // u1 kind of value
51
        dos.writeByte(type); // u1 kind of value
51
        dos.writeShort(idx);
52
        dos.writeShort(idx);
(-)a/classfile/ClassFormatException.java (+1 lines)
Lines 22-27 package org.apache.tomcat.util.bcel.classfile; Link Here
22
 * that the file is malformed or otherwise cannot be interpreted as a
22
 * that the file is malformed or otherwise cannot be interpreted as a
23
 * class file.
23
 * class file.
24
 *
24
 *
25
 * @version $Id$
25
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
26
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
26
 */
27
 */
27
public class ClassFormatException extends RuntimeException {
28
public class ClassFormatException extends RuntimeException {
(-)a/classfile/ClassParser.java (-35 / +71 lines)
Lines 17-31 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.BufferedInputStream;
20
import java.io.*;
21
import java.io.DataInputStream;
21
import java.util.Arrays;
22
import java.io.FileInputStream;
23
import java.io.IOException;
24
import java.io.InputStream;
25
import java.util.zip.ZipEntry;
22
import java.util.zip.ZipEntry;
26
import java.util.zip.ZipFile;
23
import java.util.zip.ZipFile;
27
24
28
import org.apache.tomcat.util.bcel.Constants;
25
import org.apache.tomcat.util.bcel.Constants;
26
import org.apache.tomcat.util.bcel.util.FastDataInputStream;
29
27
30
/**
28
/**
31
 * Wrapper class that parses a given Java .class file. The method <A
29
 * Wrapper class that parses a given Java .class file. The method <A
Lines 39-49 import org.apache.tomcat.util.bcel.Constants; Link Here
39
 * JVM specification 1.0</a>. See this paper for
37
 * JVM specification 1.0</a>. See this paper for
40
 * further details about the structure of a bytecode file.
38
 * further details about the structure of a bytecode file.
41
 *
39
 *
40
 * @version $Id$
42
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> 
41
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> 
43
 */
42
 */
44
public final class ClassParser {
43
public final class ClassParser {
44
	
45
	//switch for FastDataInputStream
46
	public static boolean isFDIS = false;
45
47
46
    private DataInputStream file;
48
    private DataInput file;
47
    private boolean fileOwned;
49
    private boolean fileOwned;
48
    private String file_name;
50
    private String file_name;
49
    private String zip_file;
51
    private String zip_file;
Lines 70-79 public final class ClassParser { Link Here
70
        fileOwned = false;
72
        fileOwned = false;
71
        String clazz = file.getClass().getName(); // Not a very clean solution ...
73
        String clazz = file.getClass().getName(); // Not a very clean solution ...
72
        is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
74
        is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
73
        if (file instanceof DataInputStream) {
75
        if(isFDIS){
74
            this.file = (DataInputStream) file;
76
	        if (file instanceof FastDataInputStream) {
75
        } else {
77
	            this.
76
            this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
78
	            file = (FastDataInputStream) file;
79
	        } else {
80
	            this.file = new FastDataInputStream(file, BUFSIZE);
81
	        }
82
        } else{
83
        	if (file instanceof DataInputStream) {
84
                this.file = (DataInputStream) file;
85
            } else {
86
                this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
87
            }
77
        }
88
        }
78
    }
89
    }
79
90
Lines 93-112 public final class ClassParser { Link Here
93
        ZipFile zip = null;
104
        ZipFile zip = null;
94
        try {
105
        try {
95
            if (fileOwned) {
106
            if (fileOwned) {
96
                if (is_zip) {
107
            	if(isFDIS){
97
                    zip = new ZipFile(zip_file);
108
	                if (is_zip) {
98
                    ZipEntry entry = zip.getEntry(file_name);
109
	                    zip = new ZipFile(zip_file);
99
                    
110
	                    ZipEntry entry = zip.getEntry(file_name);
100
                    if (entry == null) {
111
	                    
101
                        throw new IOException("File " + file_name + " not found");
112
	                    if (entry == null) {
113
	                        throw new IOException("File " + file_name + " not found");
114
	                    }
115
	                    
116
	                    file = new FastDataInputStream(zip.getInputStream(entry),
117
	                            BUFSIZE);
118
	                } else {
119
	                    file = new FastDataInputStream(new FileInputStream(
120
	                            file_name), BUFSIZE);
121
	                }
122
            	}
123
            	else {
124
            		if (is_zip) {
125
                        zip = new ZipFile(zip_file);
126
                        ZipEntry entry = zip.getEntry(file_name);
127
                        
128
                        if (entry == null) {
129
                            throw new IOException("File " + file_name + " not found");
130
                        }
131
                        
132
                        file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
133
                                BUFSIZE));
134
                    } else {
135
                        file = new DataInputStream(new BufferedInputStream(new FileInputStream(
136
                                file_name), BUFSIZE));
102
                    }
137
                    }
103
                    
138
            	}
104
                    file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
105
                            BUFSIZE));
106
                } else {
107
                    file = new DataInputStream(new BufferedInputStream(new FileInputStream(
108
                            file_name), BUFSIZE));
109
                }
110
            }
139
            }
111
            /****************** Read headers ********************************/
140
            /****************** Read headers ********************************/
112
            // Check magic tag of class file
141
            // Check magic tag of class file
Lines 145-152 public final class ClassParser { Link Here
145
            // Read everything of interest, so close the file
174
            // Read everything of interest, so close the file
146
            if (fileOwned) {
175
            if (fileOwned) {
147
                try {
176
                try {
148
                    if (file != null) {
177
                    if (file != null && file instanceof Closeable) {
149
                        file.close();
178
                        ((Closeable)file).close();
150
                    }
179
                    }
151
                    if (zip != null) {
180
                    if (zip != null) {
152
                        zip.close();
181
                        zip.close();
Lines 167-173 public final class ClassParser { Link Here
167
     * @throws  IOException
196
     * @throws  IOException
168
     * @throws  ClassFormatException
197
     * @throws  ClassFormatException
169
     */
198
     */
170
    private void readAttributes() throws IOException, ClassFormatException {
199
	private final void readAttributes() throws IOException, ClassFormatException {
171
        int attributes_count;
200
        int attributes_count;
172
        attributes_count = file.readUnsignedShort();
201
        attributes_count = file.readUnsignedShort();
173
        attributes = new Attribute[attributes_count];
202
        attributes = new Attribute[attributes_count];
Lines 182-188 public final class ClassParser { Link Here
182
     * @throws  IOException
211
     * @throws  IOException
183
     * @throws  ClassFormatException
212
     * @throws  ClassFormatException
184
     */
213
     */
185
    private void readClassInfo() throws IOException, ClassFormatException {
214
    private final void readClassInfo() throws IOException, ClassFormatException {
186
        access_flags = file.readUnsignedShort();
215
        access_flags = file.readUnsignedShort();
187
        /* Interfaces are implicitely abstract, the flag should be set
216
        /* Interfaces are implicitely abstract, the flag should be set
188
         * according to the JVM specification.
217
         * according to the JVM specification.
Lines 204-210 public final class ClassParser { Link Here
204
     * @throws  IOException
233
     * @throws  IOException
205
     * @throws  ClassFormatException
234
     * @throws  ClassFormatException
206
     */
235
     */
207
    private void readConstantPool() throws IOException, ClassFormatException {
236
    private final void readConstantPool() throws IOException, ClassFormatException {
208
        constant_pool = new ConstantPool(file);
237
        constant_pool = new ConstantPool(file);
209
    }
238
    }
210
239
Lines 214-220 public final class ClassParser { Link Here
214
     * @throws  IOException
243
     * @throws  IOException
215
     * @throws  ClassFormatException
244
     * @throws  ClassFormatException
216
     */
245
     */
217
    private void readFields() throws IOException, ClassFormatException {
246
    private final void readFields() throws IOException, ClassFormatException {
218
        int fields_count;
247
        int fields_count;
219
        fields_count = file.readUnsignedShort();
248
        fields_count = file.readUnsignedShort();
220
        fields = new Field[fields_count];
249
        fields = new Field[fields_count];
Lines 223-228 public final class ClassParser { Link Here
223
        }
252
        }
224
    }
253
    }
225
254
255
    private static final byte[] MAGIC_ID = new byte[] { (byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE};
256
226
257
227
    /******************** Private utility methods **********************/
258
    /******************** Private utility methods **********************/
228
    /**
259
    /**
Lines 231-241 public final class ClassParser { Link Here
231
     * @throws  IOException
262
     * @throws  IOException
232
     * @throws  ClassFormatException
263
     * @throws  ClassFormatException
233
     */
264
     */
234
    private void readID() throws IOException, ClassFormatException {
265
    private final void readID() throws IOException, ClassFormatException {
235
        int magic = 0xCAFEBABE;
266
        byte[] bytes = new byte[4];
236
        if (file.readInt() != magic) {
267
        file.readFully(bytes);
268
        if (!Arrays.equals(bytes, MAGIC_ID)) {
237
            throw new ClassFormatException(file_name + " is not a Java .class file");
269
            throw new ClassFormatException(file_name + " is not a Java .class file");
238
        }
270
        }
271
//        int magic = 0xCAFEBABE;
272
//        if (file.readInt() != magic) {
273
//            throw new ClassFormatException(file_name + " is not a Java .class file");
274
//        }
239
    }
275
    }
240
276
241
277
Lines 244-250 public final class ClassParser { Link Here
244
     * @throws  IOException
280
     * @throws  IOException
245
     * @throws  ClassFormatException
281
     * @throws  ClassFormatException
246
     */
282
     */
247
    private void readInterfaces() throws IOException, ClassFormatException {
283
    private final void readInterfaces() throws IOException, ClassFormatException {
248
        int interfaces_count;
284
        int interfaces_count;
249
        interfaces_count = file.readUnsignedShort();
285
        interfaces_count = file.readUnsignedShort();
250
        interfaces = new int[interfaces_count];
286
        interfaces = new int[interfaces_count];
Lines 259-265 public final class ClassParser { Link Here
259
     * @throws  IOException
295
     * @throws  IOException
260
     * @throws  ClassFormatException
296
     * @throws  ClassFormatException
261
     */
297
     */
262
    private void readMethods() throws IOException, ClassFormatException {
298
    private final void readMethods() throws IOException, ClassFormatException {
263
        int methods_count;
299
        int methods_count;
264
        methods_count = file.readUnsignedShort();
300
        methods_count = file.readUnsignedShort();
265
        methods = new Method[methods_count];
301
        methods = new Method[methods_count];
Lines 274-280 public final class ClassParser { Link Here
274
     * @throws  IOException
310
     * @throws  IOException
275
     * @throws  ClassFormatException
311
     * @throws  ClassFormatException
276
     */
312
     */
277
    private void readVersion() throws IOException, ClassFormatException {
313
    private final void readVersion() throws IOException, ClassFormatException {
278
        minor = file.readUnsignedShort();
314
        minor = file.readUnsignedShort();
279
        major = file.readUnsignedShort();
315
        major = file.readUnsignedShort();
280
    }
316
    }
(-)a/classfile/Code.java (-6 / +13 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 34-39 import org.apache.tomcat.util.bcel.Constants; Link Here
34
 * is used for debugging purposes and <em>LocalVariableTable</em> which 
34
 * is used for debugging purposes and <em>LocalVariableTable</em> which 
35
 * contains information about the local variables.
35
 * contains information about the local variables.
36
 *
36
 *
37
 * @version $Id$
37
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
38
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
38
 * @see     Attribute
39
 * @see     Attribute
39
 * @see     CodeException
40
 * @see     CodeException
Lines 59-72 public final class Code extends Attribute { Link Here
59
     * @param file Input stream
60
     * @param file Input stream
60
     * @param constant_pool Array of constants
61
     * @param constant_pool Array of constants
61
     */
62
     */
62
    Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
63
	Code(int name_index, int length, DataInput file, ConstantPool constant_pool)
63
            throws IOException {
64
            throws IOException {
64
        // Initialize with some default values which will be overwritten later
65
    	// Initialize with some default values which will be overwritten later
65
        this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null,
66
        this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null,
66
                (CodeException[]) null, (Attribute[]) null, constant_pool);
67
                (CodeException[]) null, (Attribute[]) null, constant_pool);
68
//        System.out.println("init");
67
        code_length = file.readInt();
69
        code_length = file.readInt();
70
//        System.out.println("readInt");
71
72
//        System.out.println("+++++++++++++++++"+code_length+"+++++++++++++++++");
73
68
        code = new byte[code_length]; // Read byte code
74
        code = new byte[code_length]; // Read byte code
69
        file.readFully(code);
75
        file.readFully(code);
76
70
        /* Read exception table that contains all regions where an exception
77
        /* Read exception table that contains all regions where an exception
71
         * handler is active, i.e., a try { ... } catch() block.
78
         * handler is active, i.e., a try { ... } catch() block.
72
         */
79
         */
Lines 103-109 public final class Code extends Attribute { Link Here
103
     */
110
     */
104
    public Code(int name_index, int length, int max_stack, int max_locals, byte[] code,
111
    public Code(int name_index, int length, int max_stack, int max_locals, byte[] code,
105
            CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) {
112
            CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) {
106
        super(Constants.ATTR_CODE, name_index, length, constant_pool);
113
    	super(Constants.ATTR_CODE, name_index, length, constant_pool);
107
        this.max_stack = max_stack;
114
        this.max_stack = max_stack;
108
        this.max_locals = max_locals;
115
        this.max_locals = max_locals;
109
        setCode(code);
116
        setCode(code);
Lines 129-135 public final class Code extends Attribute { Link Here
129
     * @return the internal length of this code attribute (minus the first 6 bytes) 
136
     * @return the internal length of this code attribute (minus the first 6 bytes) 
130
     * and excluding all its attributes
137
     * and excluding all its attributes
131
     */
138
     */
132
    private int getInternalLength() {
139
    private final int getInternalLength() {
133
        return 2 /*max_stack*/+ 2 /*max_locals*/+ 4 /*code length*/
140
        return 2 /*max_stack*/+ 2 /*max_locals*/+ 4 /*code length*/
134
                + code_length /*byte-code*/
141
                + code_length /*byte-code*/
135
                + 2 /*exception-table length*/
142
                + 2 /*exception-table length*/
Lines 142-148 public final class Code extends Attribute { Link Here
142
     * @return the full size of this code attribute, minus its first 6 bytes,
149
     * @return the full size of this code attribute, minus its first 6 bytes,
143
     * including the size of all its contained attributes
150
     * including the size of all its contained attributes
144
     */
151
     */
145
    private int calculateLength() {
152
    private final int calculateLength() {
146
        int len = 0;
153
        int len = 0;
147
        for (int i = 0; i < attributes_count; i++) {
154
        for (int i = 0; i < attributes_count; i++) {
148
            len += attributes[i].length + 6 /*attribute header size*/;
155
            len += attributes[i].length + 6 /*attribute header size*/;
(-)a/classfile/CodeException.java (+1 lines)
Lines 29-34 import org.apache.tomcat.util.bcel.Constants; Link Here
29
 * attribute and is used only there. It contains a range in which a
29
 * attribute and is used only there. It contains a range in which a
30
 * particular exception handler is active.
30
 * particular exception handler is active.
31
 *
31
 *
32
 * @version $Id$
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @see     Code
34
 * @see     Code
34
 */
35
 */
(-)a/classfile/Constant.java (-4 / +5 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
import java.io.Serializable;
22
import java.io.Serializable;
23
23
Lines 29-34 import org.apache.tomcat.util.bcel.util.BCELComparator; Link Here
29
 * in the constant pool of a class file. The classes keep closely to
29
 * in the constant pool of a class file. The classes keep closely to
30
 * the JVM specification.
30
 * the JVM specification.
31
 *
31
 *
32
 * @version $Id$
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 */
34
 */
34
public abstract class Constant implements Cloneable, Serializable {
35
public abstract class Constant implements Cloneable, Serializable {
Lines 85-93 public abstract class Constant implements Cloneable, Serializable { Link Here
85
86
86
87
87
    @Override
88
    @Override
88
    public Object clone() {
89
    public Constant clone() {
89
        try {
90
        try {
90
            return super.clone();
91
            return (Constant) super.clone();
91
        } catch (CloneNotSupportedException e) {
92
        } catch (CloneNotSupportedException e) {
92
            throw new Error("Clone Not Supported"); // never happens
93
            throw new Error("Clone Not Supported"); // never happens
93
        }
94
        }
Lines 100-106 public abstract class Constant implements Cloneable, Serializable { Link Here
100
     * @param file Input stream
101
     * @param file Input stream
101
     * @return Constant object
102
     * @return Constant object
102
     */
103
     */
103
    static Constant readConstant( DataInputStream file ) throws IOException,
104
    static final Constant readConstant( DataInput file ) throws IOException,
104
            ClassFormatException {
105
            ClassFormatException {
105
        byte b = file.readByte(); // Read tag byte
106
        byte b = file.readByte(); // Read tag byte
106
        switch (b) {
107
        switch (b) {
(-)a/classfile/ConstantCP.java (+1 lines)
Lines 23-28 import java.io.IOException; Link Here
23
/** 
23
/** 
24
 * Abstract super class for Fieldref and Methodref constants.
24
 * Abstract super class for Fieldref and Methodref constants.
25
 *
25
 *
26
 * @version $Id$
26
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
27
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
27
 * @see     ConstantFieldref
28
 * @see     ConstantFieldref
28
 * @see     ConstantMethodref
29
 * @see     ConstantMethodref
(-)a/classfile/ConstantClass.java (+1 lines)
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
28
 * and represents a reference to a (external) class.
28
 * and represents a reference to a (external) class.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Constant
32
 * @see     Constant
32
 */
33
 */
(-)a/classfile/ConstantDouble.java (+1 lines)
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
28
 * and represents a reference to a Double object.
28
 * and represents a reference to a Double object.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Constant
32
 * @see     Constant
32
 */
33
 */
(-)a/classfile/ConstantFieldref.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-30 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/** 
25
/** 
26
 * This class represents a constant pool reference to a field.
26
 * This class represents a constant pool reference to a field.
27
 *
27
 *
28
 * @version $Id$
28
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 */
30
 */
30
public final class ConstantFieldref extends ConstantCP {
31
public final class ConstantFieldref extends ConstantCP {
Lines 38-44 public final class ConstantFieldref extends ConstantCP { Link Here
38
     * @param file input stream
39
     * @param file input stream
39
     * @throws IOException
40
     * @throws IOException
40
     */
41
     */
41
    ConstantFieldref(DataInputStream file) throws IOException {
42
    ConstantFieldref(DataInput file) throws IOException {
42
        super(Constants.CONSTANT_Fieldref, file);
43
        super(Constants.CONSTANT_Fieldref, file);
43
    }
44
    }
44
}
45
}
(-)a/classfile/ConstantFloat.java (+1 lines)
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
28
 * and represents a reference to a float object.
28
 * and represents a reference to a float object.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Constant
32
 * @see     Constant
32
 */
33
 */
(-)a/classfile/ConstantInteger.java (+1 lines)
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
28
 * and represents a reference to an int object.
28
 * and represents a reference to an int object.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Constant
32
 * @see     Constant
32
 */
33
 */
(-)a/classfile/ConstantInterfaceMethodref.java (-2 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-30 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/** 
25
/** 
26
 * This class represents a constant pool reference to an interface method.
26
 * This class represents a constant pool reference to an interface method.
27
 *
27
 *
28
 * @version $Id$
28
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 */
30
 */
30
public final class ConstantInterfaceMethodref extends ConstantCP {
31
public final class ConstantInterfaceMethodref extends ConstantCP {
Lines 38-44 public final class ConstantInterfaceMethodref extends ConstantCP { Link Here
38
     * @param file input stream
39
     * @param file input stream
39
     * @throws IOException
40
     * @throws IOException
40
     */
41
     */
41
    ConstantInterfaceMethodref(DataInputStream file) throws IOException {
42
    ConstantInterfaceMethodref(DataInput file) throws IOException {
42
        super(Constants.CONSTANT_InterfaceMethodref, file);
43
        super(Constants.CONSTANT_InterfaceMethodref, file);
43
    }
44
    }
45
44
}
46
}
(-)a/classfile/ConstantLong.java (+1 lines)
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
28
 * and represents a reference to a long object.
28
 * and represents a reference to a long object.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Constant
32
 * @see     Constant
32
 */
33
 */
(-)a/classfile/ConstantMethodref.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-30 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/** 
25
/** 
26
 * This class represents a constant pool reference to a method.
26
 * This class represents a constant pool reference to a method.
27
 *
27
 *
28
 * @version $Id$
28
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 */
30
 */
30
public final class ConstantMethodref extends ConstantCP {
31
public final class ConstantMethodref extends ConstantCP {
Lines 38-44 public final class ConstantMethodref extends ConstantCP { Link Here
38
     * @param file input stream
39
     * @param file input stream
39
     * @throws IOException
40
     * @throws IOException
40
     */
41
     */
41
    ConstantMethodref(DataInputStream file) throws IOException {
42
    ConstantMethodref(DataInput file) throws IOException {
42
        super(Constants.CONSTANT_Methodref, file);
43
        super(Constants.CONSTANT_Methodref, file);
43
    }
44
    }
44
}
45
}
(-)a/classfile/ConstantNameAndType.java (+1 lines)
Lines 28-33 import org.apache.tomcat.util.bcel.Constants; Link Here
28
 * and represents a reference to the name and signature
28
 * and represents a reference to the name and signature
29
 * of a field or method.
29
 * of a field or method.
30
 *
30
 *
31
 * @version $Id$
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @see     Constant
33
 * @see     Constant
33
 */
34
 */
(-)a/classfile/ConstantPool.java (-3 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
import java.io.Serializable;
22
import java.io.Serializable;
23
23
Lines 31-36 import org.apache.tomcat.util.bcel.Constants; Link Here
31
 * programatically should see <a href="../generic/ConstantPoolGen.html">
31
 * programatically should see <a href="../generic/ConstantPoolGen.html">
32
 * ConstantPoolGen</a>.
32
 * ConstantPoolGen</a>.
33
33
34
 * @version $Id$
34
 * @see     Constant
35
 * @see     Constant
35
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
36
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
36
 */
37
 */
Lines 48-54 public class ConstantPool implements Cloneable, Serializable { Link Here
48
     * @throws IOException
49
     * @throws IOException
49
     * @throws ClassFormatException
50
     * @throws ClassFormatException
50
     */
51
     */
51
    ConstantPool(DataInputStream file) throws IOException, ClassFormatException {
52
    ConstantPool(DataInput file) throws IOException, ClassFormatException {
52
        byte tag;
53
        byte tag;
53
        constant_pool_count = file.readUnsignedShort();
54
        constant_pool_count = file.readUnsignedShort();
54
        constant_pool = new Constant[constant_pool_count];
55
        constant_pool = new Constant[constant_pool_count];
Lines 128-134 public class ConstantPool implements Cloneable, Serializable { Link Here
128
    }
129
    }
129
130
130
131
131
    private static String escape( String str ) {
132
    private static final String escape( String str ) {
132
        int len = str.length();
133
        int len = str.length();
133
        StringBuilder buf = new StringBuilder(len + 5);
134
        StringBuilder buf = new StringBuilder(len + 5);
134
        char[] ch = str.toCharArray();
135
        char[] ch = str.toCharArray();
(-)a/classfile/ConstantString.java (+1 lines)
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
27
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
28
 * and represents a reference to a String object.
28
 * and represents a reference to a String object.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Constant
32
 * @see     Constant
32
 */
33
 */
(-)a/classfile/ConstantUtf8.java (-2 / +2 lines)
Lines 17-23 Link Here
17
package org.apache.tomcat.util.bcel.classfile;
17
package org.apache.tomcat.util.bcel.classfile;
18
18
19
import java.io.DataInput;
19
import java.io.DataInput;
20
import java.io.DataInputStream;
21
import java.io.IOException;
20
import java.io.IOException;
22
import java.util.HashMap;
21
import java.util.HashMap;
23
import java.util.LinkedHashMap;
22
import java.util.LinkedHashMap;
Lines 30-35 import org.apache.tomcat.util.bcel.Constants; Link Here
30
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
29
 * <A HREF="org.apache.tomcat.util.bcel.classfile.Constant.html">Constant</A> class 
31
 * and represents a reference to a Utf8 encoded string.
30
 * and represents a reference to a Utf8 encoded string.
32
 *
31
 *
32
 * @version $Id$
33
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
34
 * @see     Constant
34
 * @see     Constant
35
 */
35
 */
Lines 69-75 public final class ConstantUtf8 extends Constant { Link Here
69
        return getCachedInstance(s);
69
        return getCachedInstance(s);
70
    }
70
    }
71
71
72
    static ConstantUtf8 getInstance(DataInputStream file) throws IOException {
72
    static ConstantUtf8 getInstance(DataInput file) throws IOException {
73
        return getInstance(file.readUTF());
73
        return getInstance(file.readUTF());
74
    }
74
    }
75
75
(-)a/classfile/ConstantValue.java (+1 lines)
Lines 26-31 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * value, i.e., a default value for initializing a class field.
26
 * value, i.e., a default value for initializing a class field.
27
 * This class is instantiated by the <em>Attribute.readAttribute()</em> method.
27
 * This class is instantiated by the <em>Attribute.readAttribute()</em> method.
28
 *
28
 *
29
 * @version $Id$
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @see     Attribute
31
 * @see     Attribute
31
 */
32
 */
(-)a/classfile/Deprecated.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * deprecated method.
27
 * deprecated method.
28
 * It is instantiated from the <em>Attribute.readAttribute()</em> method.
28
 * It is instantiated from the <em>Attribute.readAttribute()</em> method.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Attribute
32
 * @see     Attribute
32
 */
33
 */
Lines 56-62 public final class Deprecated extends Attribute { Link Here
56
     * @param constant_pool Array of constants
57
     * @param constant_pool Array of constants
57
     * @throws IOException
58
     * @throws IOException
58
     */
59
     */
59
    Deprecated(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
60
    Deprecated(int name_index, int length, DataInput file, ConstantPool constant_pool)
60
            throws IOException {
61
            throws IOException {
61
        this(name_index, length, (byte[]) null, constant_pool);
62
        this(name_index, length, (byte[]) null, constant_pool);
62
        if (length > 0) {
63
        if (length > 0) {
(-)a/classfile/ElementValue.java (-5 / +6 lines)
Lines 17-29 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.DataOutputStream;
21
import java.io.DataOutput;
22
import java.io.IOException;
22
import java.io.IOException;
23
23
24
/**
24
/**
25
 * @version $Id: ElementValue
25
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
26
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
26
 * @since 6.0
27
 * @since 5.3
27
 */
28
 */
28
public abstract class ElementValue
29
public abstract class ElementValue
29
{
30
{
Lines 46-52 public abstract class ElementValue Link Here
46
47
47
    public abstract String stringifyValue();
48
    public abstract String stringifyValue();
48
49
49
    public abstract void dump(DataOutputStream dos) throws IOException;
50
    public abstract void dump(DataOutput dos) throws IOException;
50
51
51
    public static final int STRING = 's';
52
    public static final int STRING = 's';
52
53
Lines 74-80 public abstract class ElementValue Link Here
74
75
75
    public static final int PRIMITIVE_BOOLEAN = 'Z';
76
    public static final int PRIMITIVE_BOOLEAN = 'Z';
76
77
77
    public static ElementValue readElementValue(DataInputStream dis,
78
    public static ElementValue readElementValue(DataInput dis,
78
            ConstantPool cpool) throws IOException
79
            ConstantPool cpool) throws IOException
79
    {
80
    {
80
        byte type = dis.readByte();
81
        byte type = dis.readByte();
(-)a/classfile/ElementValuePair.java (-3 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataOutputStream;
20
import java.io.DataOutput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-32 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/**
25
/**
26
 * an annotation's element value pair
26
 * an annotation's element value pair
27
 * 
27
 * 
28
 * @version $Id: ElementValuePair
28
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
29
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
29
 * @since 6.0
30
 * @since 5.3
30
 */
31
 */
31
public class ElementValuePair
32
public class ElementValuePair
32
{
33
{
Lines 56-62 public class ElementValuePair Link Here
56
        return elementValue;
57
        return elementValue;
57
    }
58
    }
58
    
59
    
59
    protected void dump(DataOutputStream dos) throws IOException {
60
    protected void dump(DataOutput dos) throws IOException {
60
        dos.writeShort(elementNameIndex); // u2 name of the element
61
        dos.writeShort(elementNameIndex); // u2 name of the element
61
        elementValue.dump(dos);
62
        elementValue.dump(dos);
62
    }
63
    }
(-)a/classfile/EnclosingMethod.java (-2 / +2 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.apache.tomcat.util.bcel.classfile;
17
package org.apache.tomcat.util.bcel.classfile;
18
18
19
import java.io.DataInputStream;
19
import java.io.DataInput;
20
import java.io.IOException;
20
import java.io.IOException;
21
21
22
import org.apache.tomcat.util.bcel.Constants;
22
import org.apache.tomcat.util.bcel.Constants;
Lines 30-36 public class EnclosingMethod extends Attribute { Link Here
30
    private static final long serialVersionUID = 6755214228300933233L;
30
    private static final long serialVersionUID = 6755214228300933233L;
31
31
32
    // Ctors - and code to read an attribute in.
32
    // Ctors - and code to read an attribute in.
33
    public EnclosingMethod(int nameIndex, int len, DataInputStream dis,
33
    public EnclosingMethod(int nameIndex, int len, DataInput dis,
34
            ConstantPool cpool) throws IOException {
34
            ConstantPool cpool) throws IOException {
35
        super(Constants.ATTR_ENCLOSING_METHOD, nameIndex, len, cpool);
35
        super(Constants.ATTR_ENCLOSING_METHOD, nameIndex, len, cpool);
36
        // Unused class index
36
        // Unused class index
(-)a/classfile/EnumElementValue.java (-2 / +2 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataOutputStream;
20
import java.io.DataOutput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 41-47 public class EnumElementValue extends ElementValue Link Here
41
    }
41
    }
42
42
43
    @Override
43
    @Override
44
    public void dump(DataOutputStream dos) throws IOException
44
    public void dump(DataOutput dos) throws IOException
45
    {
45
    {
46
        dos.writeByte(type); // u1 type of value (ENUM_CONSTANT == 'e')
46
        dos.writeByte(type); // u1 type of value (ENUM_CONSTANT == 'e')
47
        dos.writeShort(typeIdx); // u2
47
        dos.writeShort(typeIdx); // u2
(-)a/classfile/ExceptionTable.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 30-35 import org.apache.tomcat.util.bcel.Constants; Link Here
30
 * attribute using the name <em>Exceptions</em> (which is inconsistent
30
 * attribute using the name <em>Exceptions</em> (which is inconsistent
31
 * with the other classes).
31
 * with the other classes).
32
 *
32
 *
33
 * @version $Id$
33
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
34
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
34
 * @see     Code
35
 * @see     Code
35
 */
36
 */
Lines 61-67 public final class ExceptionTable extends Attribute { Link Here
61
     * @param constant_pool Array of constants
62
     * @param constant_pool Array of constants
62
     * @throws IOException
63
     * @throws IOException
63
     */
64
     */
64
    ExceptionTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
65
    ExceptionTable(int name_index, int length, DataInput file, ConstantPool constant_pool)
65
            throws IOException {
66
            throws IOException {
66
        this(name_index, length, (int[]) null, constant_pool);
67
        this(name_index, length, (int[]) null, constant_pool);
67
        number_of_exceptions = file.readUnsignedShort();
68
        number_of_exceptions = file.readUnsignedShort();
(-)a/classfile/Field.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 27-32 import org.apache.tomcat.util.bcel.util.BCELComparator; Link Here
27
 * This class represents the field info structure, i.e., the representation 
27
 * This class represents the field info structure, i.e., the representation 
28
 * for a variable in the class. See JVM specification for details.
28
 * for a variable in the class. See JVM specification for details.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 */
32
 */
32
public final class Field extends FieldOrMethod {
33
public final class Field extends FieldOrMethod {
Lines 55-61 public final class Field extends FieldOrMethod { Link Here
55
     * Construct object from file stream.
56
     * Construct object from file stream.
56
     * @param file Input stream
57
     * @param file Input stream
57
     */
58
     */
58
    Field(DataInputStream file, ConstantPool constant_pool) throws IOException,
59
    Field(DataInput file, ConstantPool constant_pool) throws IOException,
59
            ClassFormatException {
60
            ClassFormatException {
60
        super(file, constant_pool);
61
        super(file, constant_pool);
61
    }
62
    }
(-)a/classfile/FieldOrMethod.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-30 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/** 
25
/** 
26
 * Abstract super class for fields and methods.
26
 * Abstract super class for fields and methods.
27
 *
27
 *
28
 * @version $Id$
28
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 */
30
 */
30
public abstract class FieldOrMethod extends AccessFlags implements Cloneable {
31
public abstract class FieldOrMethod extends AccessFlags implements Cloneable {
Lines 47-53 public abstract class FieldOrMethod extends AccessFlags implements Cloneable { Link Here
47
     * @throws IOException
48
     * @throws IOException
48
     * @throws ClassFormatException
49
     * @throws ClassFormatException
49
     */
50
     */
50
    protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) throws IOException,
51
    protected FieldOrMethod(DataInput file, ConstantPool constant_pool) throws IOException,
51
            ClassFormatException {
52
            ClassFormatException {
52
        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null,
53
        this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null,
53
                constant_pool);
54
                constant_pool);
(-)a/classfile/InnerClass.java (+1 lines)
Lines 29-34 import org.apache.tomcat.util.bcel.Constants; Link Here
29
 * indices of the inner and outer classes, the name and the attributes
29
 * indices of the inner and outer classes, the name and the attributes
30
 * of the inner class.
30
 * of the inner class.
31
 *
31
 *
32
 * @version $Id$
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @see InnerClasses
34
 * @see InnerClasses
34
 */
35
 */
(-)a/classfile/InnerClasses.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 28-33 import org.apache.tomcat.util.bcel.Constants; Link Here
28
 * to the source file of this class.
28
 * to the source file of this class.
29
 * It is instantiated from the <em>Attribute.readAttribute()</em> method.
29
 * It is instantiated from the <em>Attribute.readAttribute()</em> method.
30
 *
30
 *
31
 * @version $Id$
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @see     Attribute
33
 * @see     Attribute
33
 */
34
 */
Lines 60-66 public final class InnerClasses extends Attribute { Link Here
60
     * @param constant_pool Array of constants
61
     * @param constant_pool Array of constants
61
     * @throws IOException
62
     * @throws IOException
62
     */
63
     */
63
    InnerClasses(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
64
    InnerClasses(int name_index, int length, DataInput file, ConstantPool constant_pool)
64
            throws IOException {
65
            throws IOException {
65
        this(name_index, length, (InnerClass[]) null, constant_pool);
66
        this(name_index, length, (InnerClass[]) null, constant_pool);
66
        number_of_classes = file.readUnsignedShort();
67
        number_of_classes = file.readUnsignedShort();
(-)a/classfile/JavaClass.java (-1 / +3 lines)
Lines 32-37 import org.apache.tomcat.util.bcel.util.BCELComparator; Link Here
32
 * class file.  Those interested in programatically generating classes
32
 * class file.  Those interested in programatically generating classes
33
 * should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
33
 * should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
34
34
35
 * @version $Id$
35
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
36
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
36
 */
37
 */
37
public class JavaClass extends AccessFlags
38
public class JavaClass extends AccessFlags
Lines 156-162 public class JavaClass extends AccessFlags Link Here
156
            // Find attributes that contain annotation data
157
            // Find attributes that contain annotation data
157
            Attribute[] attrs = getAttributes();
158
            Attribute[] attrs = getAttributes();
158
            List<AnnotationEntry> accumulatedAnnotations = new ArrayList<AnnotationEntry>();
159
            List<AnnotationEntry> accumulatedAnnotations = new ArrayList<AnnotationEntry>();
159
            for (Attribute attribute : attrs) {
160
            for (int i = 0; i < attrs.length; i++) {
161
                Attribute attribute = attrs[i];
160
                if (attribute instanceof Annotations) {
162
                if (attribute instanceof Annotations) {
161
                    Annotations runtimeAnnotations = (Annotations)attribute;
163
                    Annotations runtimeAnnotations = (Annotations)attribute;
162
                    for(int j = 0; j < runtimeAnnotations.getAnnotationEntries().length; j++)
164
                    for(int j = 0; j < runtimeAnnotations.getAnnotationEntries().length; j++)
(-)a/classfile/LineNumber.java (+1 lines)
Lines 27-32 import java.io.Serializable; Link Here
27
 * the source that corresponds to a relative address in the byte code. This
27
 * the source that corresponds to a relative address in the byte code. This
28
 * is used for debugging purposes.
28
 * is used for debugging purposes.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     LineNumberTable
32
 * @see     LineNumberTable
32
 */
33
 */
(-)a/classfile/LineNumberTable.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 27-32 import org.apache.tomcat.util.bcel.Constants; Link Here
27
 * purposes. This attribute is used by the <em>Code</em> attribute. It
27
 * purposes. This attribute is used by the <em>Code</em> attribute. It
28
 * contains pairs of PCs and line numbers.
28
 * contains pairs of PCs and line numbers.
29
 *
29
 *
30
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     Code
32
 * @see     Code
32
 * @see LineNumber
33
 * @see LineNumber
Lines 59-65 public final class LineNumberTable extends Attribute { Link Here
59
     * @param constant_pool Array of constants
60
     * @param constant_pool Array of constants
60
     * @throws IOException
61
     * @throws IOException
61
     */
62
     */
62
    LineNumberTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
63
    LineNumberTable(int name_index, int length, DataInput file, ConstantPool constant_pool)
63
            throws IOException {
64
            throws IOException {
64
        this(name_index, length, (LineNumber[]) null, constant_pool);
65
        this(name_index, length, (LineNumber[]) null, constant_pool);
65
        line_number_table_length = (file.readUnsignedShort());
66
        line_number_table_length = (file.readUnsignedShort());
(-)a/classfile/LocalVariable.java (+1 lines)
Lines 28-33 import org.apache.tomcat.util.bcel.Constants; Link Here
28
 * This class represents a local variable within a method. It contains its
28
 * This class represents a local variable within a method. It contains its
29
 * scope, name, signature and index on the method's frame.
29
 * scope, name, signature and index on the method's frame.
30
 *
30
 *
31
 * @version $Id$
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @see     LocalVariableTable
33
 * @see     LocalVariableTable
33
 */
34
 */
(-)a/classfile/LocalVariableTable.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 26-31 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * This class represents colection of local variables in a
26
 * This class represents colection of local variables in a
27
 * method. This attribute is contained in the <em>Code</em> attribute.
27
 * method. This attribute is contained in the <em>Code</em> attribute.
28
 *
28
 *
29
 * @version $Id$
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @see     Code
31
 * @see     Code
31
 * @see LocalVariable
32
 * @see LocalVariable
Lines 58-64 public class LocalVariableTable extends Attribute { Link Here
58
     * @param constant_pool Array of constants
59
     * @param constant_pool Array of constants
59
     * @throws IOException
60
     * @throws IOException
60
     */
61
     */
61
    LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
62
    LocalVariableTable(int name_index, int length, DataInput file, ConstantPool constant_pool)
62
            throws IOException {
63
            throws IOException {
63
        this(name_index, length, (LocalVariable[]) null, constant_pool);
64
        this(name_index, length, (LocalVariable[]) null, constant_pool);
64
        local_variable_table_length = (file.readUnsignedShort());
65
        local_variable_table_length = (file.readUnsignedShort());
(-)a/classfile/LocalVariableTypeTable.java (-2 / +2 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.apache.tomcat.util.bcel.classfile;
17
package org.apache.tomcat.util.bcel.classfile;
18
18
19
import java.io.DataInputStream;
19
import java.io.DataInput;
20
import java.io.IOException;
20
import java.io.IOException;
21
21
22
import org.apache.tomcat.util.bcel.Constants;
22
import org.apache.tomcat.util.bcel.Constants;
Lines 61-67 private int local_variable_type_table_length; // Table of local Link Here
61
    setLocalVariableTable(local_variable_table);
61
    setLocalVariableTable(local_variable_table);
62
  }    
62
  }    
63
63
64
  LocalVariableTypeTable(int nameIdx, int len, DataInputStream dis,ConstantPool cpool) throws IOException {
64
  LocalVariableTypeTable(int nameIdx, int len, DataInput dis,ConstantPool cpool) throws IOException {
65
    this(nameIdx, len, (LocalVariable[])null, cpool);
65
    this(nameIdx, len, (LocalVariable[])null, cpool);
66
66
67
    local_variable_type_table_length = (dis.readUnsignedShort());
67
    local_variable_type_table_length = (dis.readUnsignedShort());
(-)a/classfile/Method.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 28-33 import org.apache.tomcat.util.bcel.util.BCELComparator; Link Here
28
 * for a method in the class. See JVM specification for details.
28
 * for a method in the class. See JVM specification for details.
29
 * A method has access flags, a name, a signature and a number of attributes.
29
 * A method has access flags, a name, a signature and a number of attributes.
30
 *
30
 *
31
 * @version $Id$
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 */
33
 */
33
public final class Method extends FieldOrMethod {
34
public final class Method extends FieldOrMethod {
Lines 66-72 public final class Method extends FieldOrMethod { Link Here
66
     * @throws IOException
67
     * @throws IOException
67
     * @throws ClassFormatException
68
     * @throws ClassFormatException
68
     */
69
     */
69
    Method(DataInputStream file, ConstantPool constant_pool) throws IOException,
70
    Method(DataInput file, ConstantPool constant_pool) throws IOException,
70
            ClassFormatException {
71
            ClassFormatException {
71
        super(file, constant_pool);
72
        super(file, constant_pool);
72
    }
73
    }
(-)a/classfile/PMGClass.java (+1 lines)
Lines 26-31 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * This class is derived from <em>Attribute</em> and represents a reference
26
 * This class is derived from <em>Attribute</em> and represents a reference
27
 * to a PMG attribute.
27
 * to a PMG attribute.
28
 *
28
 *
29
 * @version $Id$
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @see     Attribute
31
 * @see     Attribute
31
 */
32
 */
(-)a/classfile/ParameterAnnotationEntry.java (-3 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 25-32 import org.apache.tomcat.util.bcel.Constants; Link Here
25
/**
25
/**
26
 * represents one parameter annotation in the parameter annotation table
26
 * represents one parameter annotation in the parameter annotation table
27
 * 
27
 * 
28
 * @version $Id: ParameterAnnotationEntry
28
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
29
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
29
 * @since 6.0
30
 * @since 5.3
30
 */
31
 */
31
public class ParameterAnnotationEntry implements Constants {
32
public class ParameterAnnotationEntry implements Constants {
32
33
Lines 39-45 public class ParameterAnnotationEntry implements Constants { Link Here
39
     * @param file Input stream
40
     * @param file Input stream
40
     * @throws IOException
41
     * @throws IOException
41
     */
42
     */
42
    ParameterAnnotationEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
43
    ParameterAnnotationEntry(DataInput file, ConstantPool constant_pool) throws IOException {
43
        annotation_table_length = (file.readUnsignedShort());
44
        annotation_table_length = (file.readUnsignedShort());
44
        annotation_table = new AnnotationEntry[annotation_table_length];
45
        annotation_table = new AnnotationEntry[annotation_table_length];
45
        for (int i = 0; i < annotation_table_length; i++) {
46
        for (int i = 0; i < annotation_table_length; i++) {
(-)a/classfile/ParameterAnnotations.java (-3 / +4 lines)
Lines 17-30 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
/**
23
/**
24
 * base class for parameter annotations
24
 * base class for parameter annotations
25
 * 
25
 * 
26
 * @version $Id: ParameterAnnotations
26
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
27
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
27
 * @since 6.0
28
 * @since 5.3
28
 */
29
 */
29
public abstract class ParameterAnnotations extends Attribute {
30
public abstract class ParameterAnnotations extends Attribute {
30
31
Lines 41-47 public abstract class ParameterAnnotations extends Attribute { Link Here
41
     * @param constant_pool Array of constants
42
     * @param constant_pool Array of constants
42
     */
43
     */
43
    ParameterAnnotations(byte parameter_annotation_type, int name_index, int length,
44
    ParameterAnnotations(byte parameter_annotation_type, int name_index, int length,
44
            DataInputStream file, ConstantPool constant_pool) throws IOException {
45
            DataInput file, ConstantPool constant_pool) throws IOException {
45
        this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null,
46
        this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null,
46
                constant_pool);
47
                constant_pool);
47
        num_parameters = (file.readUnsignedByte());
48
        num_parameters = (file.readUnsignedByte());
(-)a/classfile/RuntimeInvisibleAnnotations.java (-4 / +5 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 26-33 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * represents an annotation that is represented in the class file but is not
26
 * represents an annotation that is represented in the class file but is not
27
 * provided to the JVM.
27
 * provided to the JVM.
28
 * 
28
 * 
29
 * @version $Id: RuntimeInvisibleAnnotations
29
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @since 6.0
31
 * @since 5.3
31
 */
32
 */
32
public class RuntimeInvisibleAnnotations extends Annotations
33
public class RuntimeInvisibleAnnotations extends Annotations
33
{
34
{
Lines 44-53 public class RuntimeInvisibleAnnotations extends Annotations Link Here
44
     *            Array of constants
45
     *            Array of constants
45
     */
46
     */
46
    RuntimeInvisibleAnnotations(int name_index, int length,
47
    RuntimeInvisibleAnnotations(int name_index, int length,
47
                                DataInputStream file, ConstantPool constant_pool)
48
                                DataInput file, ConstantPool constant_pool)
48
                                throws IOException
49
                                throws IOException
49
    {
50
    {
50
        super(Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, name_index, length,
51
        super(Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS, name_index, length,
51
                file, constant_pool);
52
                file, constant_pool);
52
    }
53
    }
53
54
(-)a/classfile/RuntimeInvisibleParameterAnnotations.java (-4 / +5 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 26-33 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * represents a parameter annotation that is represented in the class file
26
 * represents a parameter annotation that is represented in the class file
27
 * but is not provided to the JVM.
27
 * but is not provided to the JVM.
28
 * 
28
 * 
29
 * @version $Id: RuntimeInvisibleParameterAnnotations
29
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @since 6.0
31
 * @since 5.3
31
 */
32
 */
32
public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations {
33
public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations {
33
34
Lines 40-48 public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations { Link Here
40
     * @param file Input stream
41
     * @param file Input stream
41
     * @param constant_pool Array of constants
42
     * @param constant_pool Array of constants
42
     */
43
     */
43
    RuntimeInvisibleParameterAnnotations(int name_index, int length, DataInputStream file,
44
    RuntimeInvisibleParameterAnnotations(int name_index, int length, DataInput file,
44
            ConstantPool constant_pool) throws IOException {
45
            ConstantPool constant_pool) throws IOException {
45
        super(Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file,
46
        super(Constants.ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file,
46
                constant_pool);
47
                constant_pool);
47
    }
48
    }
48
49
(-)a/classfile/RuntimeVisibleAnnotations.java (-3 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 26-33 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * represents an annotation that is represented in the class file and is
26
 * represents an annotation that is represented in the class file and is
27
 * provided to the JVM.
27
 * provided to the JVM.
28
 * 
28
 * 
29
 * @version $Id: RuntimeVisibleAnnotations
29
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @since 6.0
31
 * @since 5.3
31
 */
32
 */
32
public class RuntimeVisibleAnnotations extends Annotations
33
public class RuntimeVisibleAnnotations extends Annotations
33
{
34
{
Lines 44-50 public class RuntimeVisibleAnnotations extends Annotations Link Here
44
     *            Array of constants
45
     *            Array of constants
45
     */
46
     */
46
    public RuntimeVisibleAnnotations(int name_index, int length,
47
    public RuntimeVisibleAnnotations(int name_index, int length,
47
            DataInputStream file, ConstantPool constant_pool)
48
            DataInput file, ConstantPool constant_pool)
48
            throws IOException
49
            throws IOException
49
    {
50
    {
50
        super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length,
51
        super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length,
(-)a/classfile/RuntimeVisibleParameterAnnotations.java (-3 / +4 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 26-33 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * represents a parameter annotation that is represented in the class file
26
 * represents a parameter annotation that is represented in the class file
27
 * and is provided to the JVM.
27
 * and is provided to the JVM.
28
 * 
28
 * 
29
 * @version $Id: RuntimeVisibleParameterAnnotations
29
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @author  <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
30
 * @since 6.0
31
 * @since 5.3
31
 */
32
 */
32
public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations {
33
public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations {
33
34
Lines 40-46 public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations { Link Here
40
     * @param file Input stream
41
     * @param file Input stream
41
     * @param constant_pool Array of constants
42
     * @param constant_pool Array of constants
42
     */
43
     */
43
    RuntimeVisibleParameterAnnotations(int name_index, int length, DataInputStream file,
44
    RuntimeVisibleParameterAnnotations(int name_index, int length, DataInput file,
44
            ConstantPool constant_pool) throws IOException {
45
            ConstantPool constant_pool) throws IOException {
45
        super(Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file,
46
        super(Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, name_index, length, file,
46
                constant_pool);
47
                constant_pool);
(-)a/classfile/Signature.java (+1 lines)
Lines 26-31 import org.apache.tomcat.util.bcel.Constants; Link Here
26
 * This class is derived from <em>Attribute</em> and represents a reference
26
 * This class is derived from <em>Attribute</em> and represents a reference
27
 * to a GJ attribute.
27
 * to a GJ attribute.
28
 *
28
 *
29
 * @version $Id$
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @see     Attribute
31
 * @see     Attribute
31
 */
32
 */
(-)a/classfile/SimpleElementValue.java (-2 / +2 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataOutputStream;
20
import java.io.DataOutput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 100-106 public class SimpleElementValue extends ElementValue Link Here
100
    }
100
    }
101
101
102
    @Override
102
    @Override
103
    public void dump(DataOutputStream dos) throws IOException
103
    public void dump(DataOutput dos) throws IOException
104
    {
104
    {
105
        dos.writeByte(type); // u1 kind of value
105
        dos.writeByte(type); // u1 kind of value
106
        switch (type)
106
        switch (type)
(-)a/classfile/SourceFile.java (+1 lines)
Lines 28-33 import org.apache.tomcat.util.bcel.Constants; Link Here
28
 * should appear per classfile.  The intention of this class is that it is
28
 * should appear per classfile.  The intention of this class is that it is
29
 * instantiated from the <em>Attribute.readAttribute()</em> method.
29
 * instantiated from the <em>Attribute.readAttribute()</em> method.
30
 *
30
 *
31
 * @version $Id$
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @see     Attribute
33
 * @see     Attribute
33
 */
34
 */
(-)a/classfile/StackMap.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 31-36 import org.apache.tomcat.util.bcel.Constants; Link Here
31
 * within the Code attribute of a method. See CLDC specification
31
 * within the Code attribute of a method. See CLDC specification
32
 * &sect;5.3.1.2
32
 * &sect;5.3.1.2
33
 *
33
 *
34
 * @version $Id$
34
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
35
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
35
 * @see     Code
36
 * @see     Code
36
 * @see     StackMapEntry
37
 * @see     StackMapEntry
Lines 63-69 public final class StackMap extends Attribute { Link Here
63
     * @param constant_pool Array of constants
64
     * @param constant_pool Array of constants
64
     * @throws IOException
65
     * @throws IOException
65
     */
66
     */
66
    StackMap(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
67
    StackMap(int name_index, int length, DataInput file, ConstantPool constant_pool)
67
            throws IOException {
68
            throws IOException {
68
        this(name_index, length, (StackMapEntry[]) null, constant_pool);
69
        this(name_index, length, (StackMapEntry[]) null, constant_pool);
69
        map_length = file.readUnsignedShort();
70
        map_length = file.readUnsignedShort();
(-)a/classfile/StackMapEntry.java (-5 / +3 lines)
Lines 17-32 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.*;
21
import java.io.DataOutputStream;
22
import java.io.IOException;
23
import java.io.Serializable;
24
21
25
/**
22
/**
26
 * This class represents a stack map entry recording the types of
23
 * This class represents a stack map entry recording the types of
27
 * local variables and the the of stack items at a given byte code offset.
24
 * local variables and the the of stack items at a given byte code offset.
28
 * See CLDC specification &sect;5.3.1.2
25
 * See CLDC specification &sect;5.3.1.2
29
 *
26
 *
27
 * @version $Id$
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
28
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31
 * @see     StackMap
29
 * @see     StackMap
32
 * @see     StackMapType
30
 * @see     StackMapType
Lines 47-53 public final class StackMapEntry implements Cloneable, Serializable { Link Here
47
     * @param file Input stream
45
     * @param file Input stream
48
     * @throws IOException
46
     * @throws IOException
49
     */
47
     */
50
    StackMapEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
48
    StackMapEntry(DataInput file, ConstantPool constant_pool) throws IOException {
51
        this(file.readShort(), file.readShort(), null, -1, null);
49
        this(file.readShort(), file.readShort(), null, -1, null);
52
        types_of_locals = new StackMapType[number_of_locals];
50
        types_of_locals = new StackMapType[number_of_locals];
53
        for (int i = 0; i < number_of_locals; i++) {
51
        for (int i = 0; i < number_of_locals; i++) {
(-)a/classfile/StackMapTable.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 31-36 import org.apache.tomcat.util.bcel.Constants; Link Here
31
 * within the Code attribute of a method. See CLDC specification
31
 * within the Code attribute of a method. See CLDC specification
32
 * &sect;5.3.1.2
32
 * &sect;5.3.1.2
33
 *
33
 *
34
 * @version $Id$
34
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
35
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
35
 * @see     Code
36
 * @see     Code
36
 * @see     StackMapEntry
37
 * @see     StackMapEntry
Lines 63-69 public final class StackMapTable extends Attribute { Link Here
63
     * @param constant_pool Array of constants
64
     * @param constant_pool Array of constants
64
     * @throws IOException
65
     * @throws IOException
65
     */
66
     */
66
    StackMapTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
67
    StackMapTable(int name_index, int length, DataInput file, ConstantPool constant_pool)
67
            throws IOException {
68
            throws IOException {
68
        this(name_index, length, (StackMapTableEntry[]) null, constant_pool);
69
        this(name_index, length, (StackMapTableEntry[]) null, constant_pool);
69
        map_length = file.readUnsignedShort();
70
        map_length = file.readUnsignedShort();
(-)a/classfile/StackMapTableEntry.java (-6 / +4 lines)
Lines 17-26 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.*;
21
import java.io.DataOutputStream;
22
import java.io.IOException;
23
import java.io.Serializable;
24
21
25
import org.apache.tomcat.util.bcel.Constants;
22
import org.apache.tomcat.util.bcel.Constants;
26
23
Lines 29-34 import org.apache.tomcat.util.bcel.Constants; Link Here
29
 * local variables and the the of stack items at a given byte code offset.
26
 * local variables and the the of stack items at a given byte code offset.
30
 * See CLDC specification &sect;5.3.1.2
27
 * See CLDC specification &sect;5.3.1.2
31
 *
28
 *
29
 * @version $Id$
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33
 * @see     StackMap
31
 * @see     StackMap
34
 * @see     StackMapType
32
 * @see     StackMapType
Lines 50-57 public final class StackMapTableEntry implements Cloneable, Serializable { Link Here
50
     * @param file Input stream
48
     * @param file Input stream
51
     * @throws IOException
49
     * @throws IOException
52
     */
50
     */
53
    StackMapTableEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
51
    StackMapTableEntry(DataInput file, ConstantPool constant_pool) throws IOException {
54
        this(file.read(), -1, -1, null, -1, null);
52
        this(file.readUnsignedByte(), -1, -1, null, -1, null);
55
        
53
        
56
        if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
54
        if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
57
            byte_code_offset_delta = frame_type - Constants.SAME_FRAME;
55
            byte_code_offset_delta = frame_type - Constants.SAME_FRAME;
(-)a/classfile/StackMapType.java (+1 lines)
Lines 28-33 import org.apache.tomcat.util.bcel.Constants; Link Here
28
 * This class represents the type of a local variable or item on stack
28
 * This class represents the type of a local variable or item on stack
29
 * used in the StackMap entries.
29
 * used in the StackMap entries.
30
 *
30
 *
31
 * @version $Id$
31
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32
 * @see     StackMapEntry
33
 * @see     StackMapEntry
33
 * @see     StackMap
34
 * @see     StackMap
(-)a/classfile/Synthetic.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
22
23
import org.apache.tomcat.util.bcel.Constants;
23
import org.apache.tomcat.util.bcel.Constants;
Lines 31-36 import org.apache.tomcat.util.bcel.Constants; Link Here
31
 * is intended to be instantiated from the
31
 * is intended to be instantiated from the
32
 * <em>Attribute.readAttribute()</em> method.
32
 * <em>Attribute.readAttribute()</em> method.
33
 *
33
 *
34
 * @version $Id$
34
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
35
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
35
 * @see     Attribute
36
 * @see     Attribute
36
 */
37
 */
Lines 62-68 public final class Synthetic extends Attribute { Link Here
62
     * @param constant_pool Array of constants
63
     * @param constant_pool Array of constants
63
     * @throws IOException
64
     * @throws IOException
64
     */
65
     */
65
    Synthetic(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
66
    Synthetic(int name_index, int length, DataInput file, ConstantPool constant_pool)
66
            throws IOException {
67
            throws IOException {
67
        this(name_index, length, (byte[]) null, constant_pool);
68
        this(name_index, length, (byte[]) null, constant_pool);
68
        if (length > 0) {
69
        if (length > 0) {
(-)a/classfile/Unknown.java (-2 / +3 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInputStream;
20
import java.io.DataInput;
21
import java.io.IOException;
21
import java.io.IOException;
22
import java.util.HashMap;
22
import java.util.HashMap;
23
import java.util.Map;
23
import java.util.Map;
Lines 35-40 import org.apache.tomcat.util.bcel.Constants; Link Here
35
 * org.apache.tomcat.util.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>.
35
 * org.apache.tomcat.util.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>.
36
36
37
 *
37
 *
38
 * @version $Id$
38
 * @see org.apache.tomcat.util.bcel.classfile.Attribute
39
 * @see org.apache.tomcat.util.bcel.classfile.Attribute
39
 * @see org.apache.tomcat.util.bcel.classfile.AttributeReader
40
 * @see org.apache.tomcat.util.bcel.classfile.AttributeReader
40
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
41
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
Lines 73-79 public final class Unknown extends Attribute { Link Here
73
     * @param constant_pool Array of constants
74
     * @param constant_pool Array of constants
74
     * @throws IOException
75
     * @throws IOException
75
     */
76
     */
76
    Unknown(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
77
    Unknown(int name_index, int length, DataInput file, ConstantPool constant_pool)
77
            throws IOException {
78
            throws IOException {
78
        this(name_index, length, (byte[]) null, constant_pool);
79
        this(name_index, length, (byte[]) null, constant_pool);
79
        if (length > 0) {
80
        if (length > 0) {
(-)a/classfile/Utility.java (-20 / +1 lines)
Lines 17-23 Link Here
17
 */
17
 */
18
package org.apache.tomcat.util.bcel.classfile;
18
package org.apache.tomcat.util.bcel.classfile;
19
19
20
import java.io.DataInput;
21
import java.io.IOException;
20
import java.io.IOException;
22
21
23
import org.apache.tomcat.util.bcel.Constants;
22
import org.apache.tomcat.util.bcel.Constants;
Lines 26-31 import org.apache.tomcat.util.bcel.util.ByteSequence; Link Here
26
/**
25
/**
27
 * Utility functions that do not really belong to any class in particular.
26
 * Utility functions that do not really belong to any class in particular.
28
 *
27
 *
28
 * @version $Id$
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30
 */
30
 */
31
public abstract class Utility {
31
public abstract class Utility {
Lines 778-800 public abstract class Utility { Link Here
778
        }
778
        }
779
        return buf.toString();
779
        return buf.toString();
780
    }
780
    }
781
782
    static void swallowBootstrapMethods(DataInput file) throws IOException {
783
        int num_bootstrap_methods = file.readUnsignedShort();
784
        for (int i = 0; i < num_bootstrap_methods; i++) {
785
            file.readUnsignedShort();   // Unused bootstrap_method_ref
786
            int num_bootstrap_args = file.readUnsignedShort();
787
            for (int j = 0; j < num_bootstrap_args; j++) {
788
                file.readUnsignedShort(); // Unused bootstrap method argument
789
            }
790
        }
791
    }
792
793
    static void swallowMethodParameters(DataInput file) throws IOException {
794
        int parameters_count = file.readUnsignedByte();
795
        for (int i = 0; i < parameters_count; i++) {
796
            file.readUnsignedShort();   // Unused name_index
797
            file.readUnsignedShort();   // Unused access_flags
798
        }
799
    }
800
}
781
}
(-)a/classfile/package.html (+3 lines)
Lines 17-22 Link Here
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
18
<html>
18
<html>
19
<head>
19
<head>
20
<!--
21
$Id$
22
-->
20
</head>
23
</head>
21
<body bgcolor="white">
24
<body bgcolor="white">
22
<p>
25
<p>
(-)a/util/BCELComparator.java (+1 lines)
Lines 21-26 package org.apache.tomcat.util.bcel.util; Link Here
21
 * Used for BCEL comparison strategy
21
 * Used for BCEL comparison strategy
22
 * 
22
 * 
23
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
23
 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
24
 * @version $Id$
24
 * @since 5.2
25
 * @since 5.2
25
 */
26
 */
26
public interface BCELComparator {
27
public interface BCELComparator {
(-)a/util/ByteSequence.java (+1 lines)
Lines 25-30 import java.io.DataInputStream; Link Here
25
 * via the `readByte()' method. This is used to implement a wrapper for the 
25
 * via the `readByte()' method. This is used to implement a wrapper for the 
26
 * Java byte code stream to gain some more readability.
26
 * Java byte code stream to gain some more readability.
27
 *
27
 *
28
 * @version $Id$
28
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29
 */
30
 */
30
public final class ByteSequence extends DataInputStream {
31
public final class ByteSequence extends DataInputStream {
(-)a/util/FastDataInputStream.java (+345 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
package org.apache.tomcat.util.bcel.util;
19
20
import java.io.DataInput;
21
import java.io.EOFException;
22
import java.io.FilterInputStream;
23
import java.io.IOException;
24
import java.io.InputStream;
25
import java.io.UTFDataFormatException;
26
27
28
/**
29
 * Created by xshao on 7/31/14.
30
 */
31
public class FastDataInputStream extends FilterInputStream implements DataInput {
32
	/**
33
     * Creates a DataInputStream that uses the specified
34
     * underlying InputStream.
35
     *
36
     * @param  in   the specified input stream
37
	 * @throws IOException 
38
     */
39
	
40
	//Buff
41
	private static int defaultBufferSize = 8192;
42
	protected volatile byte buf[];
43
    protected int cnt;
44
    protected int pos;
45
    
46
    //Constructor
47
    public FastDataInputStream(InputStream in) {
48
    	super(in);
49
    	buf = new byte[defaultBufferSize];
50
    }
51
    
52
    public FastDataInputStream(InputStream in, int size) {
53
    	super(in);
54
            if (size <= 0) {
55
                throw new IllegalArgumentException("Buffer size <= 0");
56
            }
57
    	buf = new byte[size];
58
    }
59
60
    public final int read(byte b[]) throws IOException {
61
        return this.read(b, 0, b.length);
62
    }
63
    
64
    public int read(byte b[], int off, int len)
65
            throws IOException
66
    {
67
        if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
68
            throw new IndexOutOfBoundsException();
69
        } else if (len == 0) {
70
            return 0;
71
        }
72
73
        int n = 0;
74
        for (;;) {
75
            int nread = read1(b, off + n, len - n);
76
            if (nread <= 0)
77
                return (n == 0) ? nread : n;
78
            n += nread;
79
            if (n >= len)
80
                return n;
81
            // if not closed but no bytes available, return
82
            InputStream input = in;
83
            if (input != null && input.available() <= 0)
84
                return n;
85
        }
86
    }
87
    
88
    private int read1(byte[] b, int off, int len) throws IOException {
89
        int avail = cnt - pos;
90
        if (avail <= 0) {
91
            /* If the requested length is at least as large as the buffer, and
92
               if there is no mark/reset activity, do not bother to copy the
93
               bytes into the local buffer.  In this way buffered streams will
94
               cascade harmlessly. */
95
            if (len >= this.buf.length) {
96
                return this.in.read(b, off, len);
97
            }
98
            fill();
99
            avail = cnt - pos;
100
            if (avail <= 0) return -1;
101
        }
102
        int inc = (avail < len) ? avail : len;
103
        System.arraycopy(this.buf, pos, b, off, inc);
104
        pos += inc;
105
        return inc;
106
    }
107
    
108
    public final void readFully(byte b[]) throws IOException {
109
//    	System.out.println("readFully");
110
111
		readFully(b, 0, b.length);
112
	}
113
114
	@Override
115
	public final void readFully(byte b[], int off, int len) throws IOException {
116
		if (len < 0)
117
		    throw new IndexOutOfBoundsException();
118
		int n = 0;
119
		while (n < len) {
120
		    int count = this.read(b, off + n, len - n);
121
		    if (count < 0)
122
		    	throw new EOFException();
123
		    n += count;
124
		}
125
    }
126
127
	@Override
128
	public boolean readBoolean() throws IOException {
129
		if (pos >= cnt) {
130
            fill();
131
            if (pos >= cnt)
132
                throw new EOFException();
133
        }
134
		int ch = this.buf[pos++] & 0xff;
135
		return (ch != 0);
136
	}
137
	
138
    public final byte readByte() throws IOException {
139
//    	System.out.println("readByte");
140
141
    	if (pos >= cnt) {
142
            fill();
143
            if (pos >= cnt)
144
                throw new EOFException();
145
        }
146
    	return this.buf[pos++];
147
//		int ch = this.buf[pos++] & 0xff;
148
//    	return (byte)(ch);
149
    }
150
    
151
	@Override
152
	public int readUnsignedByte() throws IOException {
153
		if (pos >= cnt) {
154
            fill();
155
            if (pos >= cnt)
156
                throw new EOFException();
157
        }
158
		int ch = this.buf[pos++] & 0xff;
159
		return ch;
160
	}
161
    
162
	public final short readShort() throws IOException {
163
//    	System.out.println("readShort");
164
    	
165
    	if(pos + 1 >= cnt){
166
    		fill();
167
    		if(pos + 1 >= cnt) throw new EOFException();
168
    	}
169
    	int ch1 = this.buf[pos++] & 0xff;
170
    	int ch2 = this.buf[pos++] & 0xff;
171
        return (short)((ch1 << 8) + (ch2 << 0));
172
    }
173
	
174
    public int readUnsignedShort() throws IOException{
175
//    	System.out.println("readUnsignedShort");
176
177
    	if(pos + 1 >= cnt) {
178
    		fill();
179
    		if(pos + 1 >= cnt) throw new EOFException();
180
    	}
181
    	
182
    	int ch1 = this.buf[pos++] & 0xff;
183
    	int ch2 = this.buf[pos++] & 0xff;
184
        return (ch1 << 8) + (ch2 << 0);
185
    }
186
    
187
    public final char readChar() throws IOException {
188
//    	System.out.println("readChar");
189
190
    	if(pos + 1 >= cnt) {
191
    		fill();
192
    		if(pos + 1 >= cnt) throw new EOFException();
193
    	}
194
        int ch1 = this.buf[pos++] & 0xff;
195
        int ch2 = this.buf[pos++] & 0xff;
196
        return (char)((ch1 << 8) + (ch2 << 0));
197
    }
198
    
199
    public final int readInt() throws IOException {
200
//    	System.out.println("readInt");
201
202
    	if(pos + 3 >= cnt){
203
    		fill();
204
    		if(pos + 3 >= cnt) throw new EOFException();
205
    	}
206
    	int ch1 = this.buf[pos++] & 0xff;
207
        int ch2 = this.buf[pos++] & 0xff;
208
        int ch3 = this.buf[pos++] & 0xff;
209
        int ch4 = this.buf[pos++] & 0xff;
210
        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
211
    }
212
    
213
    private byte readBuffer[] = new byte[8];
214
215
    public final long readLong() throws IOException {
216
        readFully(readBuffer, 0, 8);
217
        return (((long)readBuffer[0] << 56) +
218
                ((long)(readBuffer[1] & 255) << 48) +
219
                ((long)(readBuffer[2] & 255) << 40) +
220
                ((long)(readBuffer[3] & 255) << 32) +
221
                ((long)(readBuffer[4] & 255) << 24) +
222
                ((readBuffer[5] & 255) << 16) +
223
                ((readBuffer[6] & 255) <<  8) +
224
                ((readBuffer[7] & 255) <<  0));
225
    }
226
    
227
    public final float readFloat() throws IOException {
228
        return Float.intBitsToFloat(readInt());
229
    }
230
231
	@Override
232
	public double readDouble() throws IOException {
233
		return Double.longBitsToDouble(readLong());
234
	}
235
    
236
    public final String readUTF() throws IOException {
237
//    	System.out.println("readUTF");
238
239
        return readUTF(this);
240
    }
241
    
242
    private byte bytearr[] = new byte[80];
243
    private char chararr[] = new char[80];
244
    
245
    public final String readUTF(DataInput in) throws IOException {
246
        int utflen = this.readUnsignedShort();
247
        byte[] bytearr = null;
248
        char[] chararr = null;
249
        if (in instanceof FastDataInputStream) {
250
        	FastDataInputStream dis = (FastDataInputStream)in;
251
            if (dis.bytearr.length < utflen){
252
                dis.bytearr = new byte[utflen*2];
253
                dis.chararr = new char[utflen*2];
254
            }
255
            chararr = dis.chararr;
256
            bytearr = dis.bytearr;
257
        } else {
258
            bytearr = new byte[utflen];
259
            chararr = new char[utflen];
260
        }
261
262
        int c, char2, char3;
263
        int count = 0;
264
        int chararr_count=0;
265
266
        this.readFully(bytearr, 0, utflen);
267
268
        while (count < utflen) {
269
            c = (int) bytearr[count] & 0xff;      
270
            if (c > 127) break;
271
            count++;
272
            chararr[chararr_count++]=(char)c;
273
        }
274
275
        while (count < utflen) {
276
            c = (int) bytearr[count] & 0xff;
277
            switch (c >> 4) {
278
                case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
279
                    /* 0xxxxxxx*/
280
                    count++;
281
                    chararr[chararr_count++]=(char)c;
282
                    break;
283
                case 12: case 13:
284
                    /* 110x xxxx   10xx xxxx*/
285
                    count += 2;
286
                    if (count > utflen)
287
                        throw new UTFDataFormatException(
288
                            "malformed input: partial character at end");
289
                    char2 = (int) bytearr[count-1];
290
                    if ((char2 & 0xC0) != 0x80)
291
                        throw new UTFDataFormatException(
292
                            "malformed input around byte " + count); 
293
                    chararr[chararr_count++]=(char)(((c & 0x1F) << 6) | 
294
                                                    (char2 & 0x3F));  
295
                    break;
296
                case 14:
297
                    /* 1110 xxxx  10xx xxxx  10xx xxxx */
298
                    count += 3;
299
                    if (count > utflen)
300
                        throw new UTFDataFormatException(
301
                            "malformed input: partial character at end");
302
                    char2 = (int) bytearr[count-2];
303
                    char3 = (int) bytearr[count-1];
304
                    if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
305
                        throw new UTFDataFormatException(
306
                            "malformed input around byte " + (count-1));
307
                    chararr[chararr_count++]=(char)(((c     & 0x0F) << 12) |
308
                                                    ((char2 & 0x3F) << 6)  |
309
                                                    ((char3 & 0x3F) << 0));
310
                    break;
311
                default:
312
                    /* 10xx xxxx,  1111 xxxx */
313
                    throw new UTFDataFormatException(
314
                        "malformed input around byte " + count);
315
            }
316
        }
317
        // The number of chars produced may be less than utflen
318
        return new String(chararr, 0, chararr_count);
319
    }
320
    
321
    private void fill() throws IOException {
322
//    	System.out.println("fill");
323
    	int remain = 0;
324
    	if(pos < cnt){
325
        	remain = cnt - pos;
326
        	System.arraycopy(buf, cnt - remain, buf, 0, remain);
327
    	}
328
    	pos = 0;
329
    	int n = this.in.read(buf, remain, defaultBufferSize - remain);
330
    	cnt = pos + n + remain;
331
    }
332
    
333
// unimplemented
334
	@Override
335
	public int skipBytes(int n) throws IOException {
336
		// TODO Auto-generated method stub
337
		throw new IOException();
338
	}
339
	
340
	@Override
341
	public String readLine() throws IOException {
342
		// TODO Auto-generated method stub
343
		throw new IOException();
344
	}
345
}
(-)a/util/package.html (-1 / +4 lines)
Lines 17-27 Link Here
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
18
<html>
18
<html>
19
<head>
19
<head>
20
<!--
21
$Id$
22
-->
20
</head>
23
</head>
21
<body bgcolor="white">
24
<body bgcolor="white">
22
<p>
25
<p>
23
This package contains utility classes for the
26
This package contains utility classes for the
24
<a href="http://commons.apache.org/bcel/">Byte Code Engineering
27
<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering
25
Library</a>, namely:
28
Library</a>, namely:
26
</p>
29
</p>
27
<p>
30
<p>

Return to bug 56953