org.codehaus.aspectwerkz.reflect.impl.asm
Class AsmClassInfo

java.lang.Object
  extended byorg.codehaus.aspectwerkz.reflect.impl.asm.AsmClassInfo
All Implemented Interfaces:
ClassInfo, ReflectionInfo

public class AsmClassInfo
extends Object
implements ClassInfo

Implementation of the ClassInfo interface utilizing the ASM bytecode library for the info retriaval. Annotations are lazily gathered, unless required to visit them at the same time as we visit methods and fields.

Author:
Jonas Bonér , Alexandre Vasseur

Nested Class Summary
static class AsmClassInfo.ClassNameRetrievalClassAdapter
          ASM bytecode visitor that retrieves the class name from the bytecode.
 
Nested classes inherited from class org.codehaus.aspectwerkz.reflect.ClassInfo
ClassInfo.NullClassInfo
 
Field Summary
protected static List EMPTY_LIST
           
 
Method Summary
 boolean equals(Object o)
           
static AnnotationInfo getAnnotationInfo(org.objectweb.asm.attrs.Annotation annotation, ClassLoader loader)
          Creates and returns a new annotation info build up from the Java5 annotation.
 List getAnnotations()
          Returns the annotations infos.
static ClassInfo getArrayClassInfo(String className, ClassLoader loader, ClassInfo componentClassInfo, int dimension)
          Create a ClassInfo based on a component type and a given dimension
static ClassInfo getClassInfo(byte[] bytecode, ClassLoader loader)
          Returns the class info for a specific class.
static ClassInfo getClassInfo(InputStream stream, ClassLoader loader)
          Returns the class info for a specific class.
static ClassInfo getClassInfo(InputStream stream, ClassLoader loader, boolean lazyAttributes)
          Returns the class info for a specific class.
static ClassInfo getClassInfo(String className, ClassLoader loader)
          Returns the class info for a specific class.
static ClassInfo getClassInfo(String className, ClassLoader loader, boolean lazyAttributes)
          Returns the class info for a specific class.
 ClassInfo getComponentType()
          Returns the component type if array type else null.
 ConstructorInfo getConstructor(int hash)
          Returns a constructor info by its hash.
 ConstructorInfo[] getConstructors()
          Returns a list with all the constructors info.
 FieldInfo getField(int hash)
          Returns a field info by its hash.
 FieldInfo[] getFields()
          Returns a list with all the field info.
 ClassInfo[] getInterfaces()
          Returns the interfaces.
 MethodInfo getMethod(int hash)
          Returns a method info by its hash.
 MethodInfo[] getMethods()
          Returns a list with all the methods info.
 int getModifiers()
          Returns the class modifiers.
 String getName()
          Returns the name of the class.
static Class getPrimitiveClass(String className)
          Checks if the class is a of a primitive type, if so create and return the class for the type else return null.
 ClassInfo getSuperClass()
          Returns the super class.
 int hashCode()
           
 boolean isArray()
          Is the class an array type.
 boolean isInterface()
          Is the class an interface.
 boolean isPrimitive()
          Is the class a primitive type.
static void markDirty(String className, ClassLoader loader)
          Marks the class as dirty (since it has been modified and needs to be rebuild).
static String retrieveClassNameFromBytecode(byte[] bytecode)
          Retrieves the class name from the bytecode of a class.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_LIST

protected static final List EMPTY_LIST
Method Detail

getClassInfo

public static ClassInfo getClassInfo(String className,
                                     ClassLoader loader)
Returns the class info for a specific class.

Parameters:
className -
loader -
Returns:
the class info

getClassInfo

public static ClassInfo getClassInfo(String className,
                                     ClassLoader loader,
                                     boolean lazyAttributes)
Returns the class info for a specific class.

Parameters:
className -
loader -
Returns:
the class info

getClassInfo

public static ClassInfo getClassInfo(byte[] bytecode,
                                     ClassLoader loader)
Returns the class info for a specific class.

Parameters:
bytecode -
loader -
Returns:
the class info

getClassInfo

public static ClassInfo getClassInfo(InputStream stream,
                                     ClassLoader loader)
Returns the class info for a specific class.

Parameters:
stream -
loader -
Returns:
the class info

getClassInfo

public static ClassInfo getClassInfo(InputStream stream,
                                     ClassLoader loader,
                                     boolean lazyAttributes)
Returns the class info for a specific class.

Parameters:
stream -
loader -
lazyAttributes -
Returns:
the class info

markDirty

public static void markDirty(String className,
                             ClassLoader loader)
Marks the class as dirty (since it has been modified and needs to be rebuild).

Parameters:
className -

retrieveClassNameFromBytecode

public static String retrieveClassNameFromBytecode(byte[] bytecode)
Retrieves the class name from the bytecode of a class.

Parameters:
bytecode -
Returns:
the class name

getPrimitiveClass

public static Class getPrimitiveClass(String className)
Checks if the class is a of a primitive type, if so create and return the class for the type else return null.

Parameters:
className -
Returns:
the class for the primitive type or null

getAnnotations

public List getAnnotations()
Returns the annotations infos.

Specified by:
getAnnotations in interface ReflectionInfo
Returns:
the annotations infos

getName

public String getName()
Returns the name of the class.

Specified by:
getName in interface ReflectionInfo
Returns:
the name of the class

getModifiers

public int getModifiers()
Returns the class modifiers.

Specified by:
getModifiers in interface ReflectionInfo
Returns:
the class modifiers

getConstructor

public ConstructorInfo getConstructor(int hash)
Returns a constructor info by its hash.

Specified by:
getConstructor in interface ClassInfo
Parameters:
hash -
Returns:

getConstructors

public ConstructorInfo[] getConstructors()
Returns a list with all the constructors info.

Specified by:
getConstructors in interface ClassInfo
Returns:
the constructors info

getMethod

public MethodInfo getMethod(int hash)
Returns a method info by its hash.

Specified by:
getMethod in interface ClassInfo
Parameters:
hash -
Returns:

getMethods

public MethodInfo[] getMethods()
Returns a list with all the methods info.

Specified by:
getMethods in interface ClassInfo
Returns:
the methods info

getField

public FieldInfo getField(int hash)
Returns a field info by its hash.

Specified by:
getField in interface ClassInfo
Parameters:
hash -
Returns:

getFields

public FieldInfo[] getFields()
Returns a list with all the field info.

Specified by:
getFields in interface ClassInfo
Returns:
the field info

getInterfaces

public ClassInfo[] getInterfaces()
Returns the interfaces.

Specified by:
getInterfaces in interface ClassInfo
Returns:
the interfaces

getSuperClass

public ClassInfo getSuperClass()
Returns the super class.

Specified by:
getSuperClass in interface ClassInfo
Returns:
the super class

getComponentType

public ClassInfo getComponentType()
Returns the component type if array type else null.

Specified by:
getComponentType in interface ClassInfo
Returns:
the component type

isInterface

public boolean isInterface()
Is the class an interface.

Specified by:
isInterface in interface ClassInfo
Returns:

isPrimitive

public boolean isPrimitive()
Is the class a primitive type.

Specified by:
isPrimitive in interface ClassInfo
Returns:

isArray

public boolean isArray()
Is the class an array type.

Specified by:
isArray in interface ClassInfo
Returns:

equals

public boolean equals(Object o)
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
See Also:
Object.hashCode()

toString

public String toString()

getArrayClassInfo

public static ClassInfo getArrayClassInfo(String className,
                                          ClassLoader loader,
                                          ClassInfo componentClassInfo,
                                          int dimension)
Create a ClassInfo based on a component type and a given dimension

Parameters:
className -
loader -
componentClassInfo -
dimension -
Returns:

getAnnotationInfo

public static AnnotationInfo getAnnotationInfo(org.objectweb.asm.attrs.Annotation annotation,
                                               ClassLoader loader)
Creates and returns a new annotation info build up from the Java5 annotation.

Parameters:
annotation - the ASM annotation abstractiono
loader - the class loader that has loaded the proxy class to use
Returns:
the annotation info


Copyright © 2002-2004 Jonas Bonér, Alexandre Vasseur. All Rights Reserved.