JML

org.multijava.util.classfile
Class BaseAttributeParser

java.lang.Object
  extended byorg.multijava.util.classfile.BaseAttributeParser
All Implemented Interfaces:
AttributeParser

public class BaseAttributeParser
extends Object
implements AttributeParser

This class implements a parser for regular Java bytecode attributes as defined in the JVM specification.

Version:
$Revision: 1.6 $
Author:
Curtis Clifton

Constructor Summary
BaseAttributeParser()
           
 
Method Summary
 Attribute read(String tag, DataInput in, ConstantPool cp)
          Checks the next attribute in the given input, in, and parses it if it is recognized.
 Attribute readCodeInfoAttribute(String tag, DataInput in, ConstantPool cp, Instruction[] insns)
          Checks the next attribute in the given input, in, and parses it if it is recognized, but only parses attributes that may appear within a CodeInfo attribute.
 Attribute readInterfaceOnly(String tag, DataInput in, ConstantPool cp)
          Checks the next attribute in the given input, in, and parses it if it is recognized, but skips CodeInfo attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseAttributeParser

public BaseAttributeParser()
Method Detail

read

public Attribute read(String tag,
                      DataInput in,
                      ConstantPool cp)
               throws IOException,
                      ClassFileFormatException
Checks the next attribute in the given input, in, and parses it if it is recognized.

Specified by:
read in interface AttributeParser
Parameters:
tag - a String giving the name of the next attribute in in
in - an input stream for the bytecode ClassInfo being parsed, whose read cursor is positioned just after the attribute_name_index of the next attribute (see JVM2, 4.7)
cp - the ConstantPool for the bytecode ClassInfo being parsed
Returns:
an Attribute value if the next bytes in in represent an Attribute recognized by this, or null if the next bytes are not recognized
Throws:
IOException - if an error occurs while reading from the bytecode file represented by in
ClassFileFormatException - if the next bytes begin like a recognized Attribute but are then malformed

readInterfaceOnly

public Attribute readInterfaceOnly(String tag,
                                   DataInput in,
                                   ConstantPool cp)
                            throws IOException,
                                   ClassFileFormatException
Checks the next attribute in the given input, in, and parses it if it is recognized, but skips CodeInfo attributes.

Specified by:
readInterfaceOnly in interface AttributeParser
Parameters:
tag - a String giving the name of the next attribute in in
in - an input stream for the bytecode ClassInfo being parsed, whose read cursor is positioned just after the attribute_name_index of the next attribute (see JVM2, 4.7)
cp - the ConstantPool for the bytecode ClassInfo being parsed
Returns:
an Attribute value if the next bytes in in represent an Attribute recognized by this, or null if the next bytes are not recognized
Throws:
IOException - if an error occurs while reading from the bytecode file represented by in
ClassFileFormatException - if the next bytes begin like a recognized Attribute but are then malformed

readCodeInfoAttribute

public Attribute readCodeInfoAttribute(String tag,
                                       DataInput in,
                                       ConstantPool cp,
                                       Instruction[] insns)
                                throws IOException,
                                       ClassFileFormatException
Checks the next attribute in the given input, in, and parses it if it is recognized, but only parses attributes that may appear within a CodeInfo attribute.

Specified by:
readCodeInfoAttribute in interface AttributeParser
Parameters:
tag - a String giving the name of the next attribute in in
in - an input stream for the bytecode ClassInfo being parsed, whose read cursor is positioned just after the attribute_name_index of the next attribute (see JVM2, 4.7)
cp - the ConstantPool for the bytecode ClassInfo being parsed
insns - (sparse) array of instructions
Returns:
an Attribute value if the next bytes in in represent an Attribute recognized by this, or null if the next bytes are not recognized
Throws:
IOException - if an error occurs while reading from the bytecode file represented by in
ClassFileFormatException - if the next bytes begin like a recognized Attribute but are then malformed or if the next bytes are not valid within a CodeInfo attribute

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.