org.apache.axis.utils.bytecode

Class ClassReader

Known Direct Subclasses:
ParamReader

public class ClassReader
extends ByteArrayInputStream

This is the class file reader for obtaining the parameter names for declared methods in a class. The class must have debugging attributes for us to obtain this information.

This does not work for inherited methods. To obtain parameter names for inherited methods, you must use a paramReader for the class that originally declared the method.

don't get tricky, it's the bare minimum. Instances of this class are not threadsafe -- don't share them.

Author:
Edwin Smith, Macromedia

Constructor Summary

ClassReader(buf[] , Map attrMethods)

Method Summary

protected static Map
findAttributeReaders(Class c)
protected static byte[]
getBytes(Class c)
load the bytecode for a given class, by using the class's defining classloader and assuming that for a class named P.C, the bytecodes are in a resource named /P/C.class.
protected static String
getSignature(Member method, Class[] paramTypes)
protected void
readAttributes()
read an attributes array.
void
readCode()
read a code attribute
protected void
readCpool()
protected int
readInt()
protected int
readShort()
protected Class
resolveClass(int i)
protected Field
resolveField(int i)
protected Member
resolveMethod(int index)
protected org.apache.axis.utils.bytecode.ClassReader.NameAndType
resolveNameAndType(int i)
protected String
resolveUtf8(int i)
protected void
skipAttributes()
protected void
skipFully(int n)
skip n bytes in the input stream.

Constructor Details

ClassReader

protected ClassReader(buf[] ,
                      Map attrMethods)

Method Details

findAttributeReaders

protected static Map findAttributeReaders(Class c)


getBytes

protected static byte[] getBytes(Class c)
            throws IOException
load the bytecode for a given class, by using the class's defining classloader and assuming that for a class named P.C, the bytecodes are in a resource named /P/C.class.

Parameters:
c - the class of interest

Returns:
a byte array containing the bytecode


getSignature

protected static String getSignature(Member method,
                                     Class[] paramTypes)


readAttributes

protected final void readAttributes()
            throws IOException
read an attributes array. the elements of a class file that can contain attributes are: fields, methods, the class itself, and some other types of attributes.


readCode

public void readCode()
            throws IOException
read a code attribute


readCpool

protected final void readCpool()
            throws IOException


readInt

protected final int readInt()

Returns:
the next signed 32 bit value


readShort

protected final int readShort()

Returns:
the next unsigned 16 bit value


resolveClass

protected final Class resolveClass(int i)
            throws IOException,
                   ClassNotFoundException


resolveField

protected final Field resolveField(int i)
            throws IOException,
                   ClassNotFoundException,
                   NoSuchFieldException


resolveMethod

protected final Member resolveMethod(int index)
            throws IOException,
                   ClassNotFoundException,
                   NoSuchMethodException


resolveNameAndType

protected final org.apache.axis.utils.bytecode.ClassReader.NameAndType resolveNameAndType(int i)
            throws IOException


resolveUtf8

protected final String resolveUtf8(int i)
            throws IOException


skipAttributes

protected final void skipAttributes()
            throws IOException


skipFully

protected void skipFully(int n)
            throws IOException
skip n bytes in the input stream.


Copyright B) 2005 Apache Web Services Project. All Rights Reserved.