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

java.lang.Object
  extended by org.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.

This implementation guarantees that the method, fields and constructors can be retrieved in the same order as they were in the bytecode (it can depends of the compiler and might not be the order of the source code - f.e. IBM compiler)

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/interfaces inherited from interface org.codehaus.aspectwerkz.reflect.ClassInfo
ClassInfo.NullClassInfo
 
Field Summary
protected static List EMPTY_LIST
           
protected static String[] EMPTY_STRING_ARRAY
           
 
Method Summary
 boolean equals(Object o)
           
 List getAnnotations()
          Returns the annotations infos.
static ClassInfo getArrayClassInfo(String className, ClassLoader loader, ClassInfo componentClassInfo)
          Create a ClassInfo based on a component type which can be himself an array
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.
 ClassLoader getClassLoader()
          Returns the class loader that loaded this 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.
 String getSignature()
          Returns the signature for the class.
 ClassInfo getSuperclass()
          Returns the super class.
 int hashCode()
           
 boolean hasStaticInitializer()
          Checks if the class has a static initalizer.
 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 ClassInfo newClassInfo(byte[] bytecode, ClassLoader loader)
          Returns a completely new class info for a specific class.
static String retrieveClassNameFromBytecode(byte[] bytecode)
          Retrieves the class name from the bytecode of a class.
 StaticInitializationInfo staticInitializer()
          Return the static initializer info or null if not present
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_STRING_ARRAY

protected static final String[] EMPTY_STRING_ARRAY

EMPTY_LIST

protected static final List EMPTY_LIST
Method Detail

newClassInfo

public static ClassInfo newClassInfo(byte[] bytecode,
                                     ClassLoader loader)
Returns a completely new class info for a specific class. Does not cache.

Parameters:
bytecode -
loader -
Returns:
the class info

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(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

getSignature

public String getSignature()
Returns the signature for the class.

Specified by:
getSignature in interface ReflectionInfo
Returns:
the signature for the class

getModifiers

public int getModifiers()
Returns the class modifiers.

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

getClassLoader

public ClassLoader getClassLoader()
Returns the class loader that loaded this class.

Specified by:
getClassLoader in interface ClassInfo
Returns:
the class loader

hasStaticInitializer

public boolean hasStaticInitializer()
Checks if the class has a static initalizer.

Specified by:
hasStaticInitializer in interface ClassInfo
Returns:

staticInitializer

public StaticInitializationInfo staticInitializer()
Return the static initializer info or null if not present

Specified by:
staticInitializer in interface ClassInfo
Returns:
See Also:
ClassInfo.staticInitializer()

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)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object

getArrayClassInfo

public static ClassInfo getArrayClassInfo(String className,
                                          ClassLoader loader,
                                          ClassInfo componentClassInfo)
Create a ClassInfo based on a component type which can be himself an array

Parameters:
className -
loader -
componentClassInfo -
Returns:


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