Package org.apache.axis.utils.bytecode
Class ClassReader
- java.lang.Object
-
- java.io.InputStream
-
- java.io.ByteArrayInputStream
-
- org.apache.axis.utils.bytecode.ClassReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
ParamReader
public class ClassReader extends java.io.ByteArrayInputStreamThis 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
Constructors Modifier Constructor Description protectedClassReader(byte[] buf, java.util.Map attrMethods)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.util.MapfindAttributeReaders(java.lang.Class c)protected static byte[]getBytes(java.lang.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 java.lang.StringgetSignature(java.lang.reflect.Member method, java.lang.Class[] paramTypes)protected voidreadAttributes()read an attributes array.voidreadCode()read a code attributeprotected voidreadCpool()protected intreadInt()protected intreadShort()protected java.lang.ClassresolveClass(int i)protected java.lang.reflect.FieldresolveField(int i)protected java.lang.reflect.MemberresolveMethod(int index)protected org.apache.axis.utils.bytecode.ClassReader.NameAndTyperesolveNameAndType(int i)protected java.lang.StringresolveUtf8(int i)protected voidskipAttributes()protected voidskipFully(int n)skip n bytes in the input stream.
-
-
-
Method Detail
-
getBytes
protected static byte[] getBytes(java.lang.Class c) throws java.io.IOExceptionload 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
- Throws:
java.io.IOException
-
findAttributeReaders
protected static java.util.Map findAttributeReaders(java.lang.Class c)
-
getSignature
protected static java.lang.String getSignature(java.lang.reflect.Member method, java.lang.Class[] paramTypes)
-
readShort
protected final int readShort()
- Returns:
- the next unsigned 16 bit value
-
readInt
protected final int readInt()
- Returns:
- the next signed 32 bit value
-
skipFully
protected void skipFully(int n) throws java.io.IOExceptionskip n bytes in the input stream.- Throws:
java.io.IOException
-
resolveMethod
protected final java.lang.reflect.Member resolveMethod(int index) throws java.io.IOException, java.lang.ClassNotFoundException, java.lang.NoSuchMethodException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundExceptionjava.lang.NoSuchMethodException
-
resolveField
protected final java.lang.reflect.Field resolveField(int i) throws java.io.IOException, java.lang.ClassNotFoundException, java.lang.NoSuchFieldException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundExceptionjava.lang.NoSuchFieldException
-
resolveNameAndType
protected final org.apache.axis.utils.bytecode.ClassReader.NameAndType resolveNameAndType(int i) throws java.io.IOException- Throws:
java.io.IOException
-
resolveClass
protected final java.lang.Class resolveClass(int i) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
resolveUtf8
protected final java.lang.String resolveUtf8(int i) throws java.io.IOException- Throws:
java.io.IOException
-
readCpool
protected final void readCpool() throws java.io.IOException- Throws:
java.io.IOException
-
skipAttributes
protected final void skipAttributes() throws java.io.IOException- Throws:
java.io.IOException
-
readAttributes
protected final void readAttributes() throws java.io.IOExceptionread 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.- Throws:
java.io.IOException
-
readCode
public void readCode() throws java.io.IOExceptionread a code attribute- Throws:
java.io.IOException
-
-