JBoss Reflection 2.2.1.SP1

org.jboss.reflect.plugins.bytecode.accessor.generated
Class GeneratedMemberAccessorFactory

java.lang.Object
  extended by org.jboss.reflect.plugins.bytecode.accessor.generated.GeneratedMemberAccessorFactory
Direct Known Subclasses:
GeneratedBehaviorAccessorFactory

public abstract class GeneratedMemberAccessorFactory
extends Object

Abstract base class to create implementations of the MethodAccessor, ConstructorAccessor and FieldAccessor interfaces.

This implementation generates raw bytecode to avoid the overhead of compilation via javassist. If sun.reflect.MagicAccessorImpl is used as the superClass field the implementation classes can access private and protected members of the target class.

Version:
$Revision: 1.1 $
Author:
Kabir Khan

Field Summary
protected static AtomicInteger counter
          The method class counter
protected static String OBJECT_NAME
          Object class name
protected static String[] THROWABLE_EXCEPTIONS
          Array of exceptions containing jvm name of Throwable
 
Method Summary
static ConstructorAccessor generateConstructorAccessor(Class<?> superClass, BytecodeConstructorInfo constructor, boolean debug)
          Creates a new GeneratedConstructor implementation for a given constructor
static FieldAccessor generateFieldAccessor(Class<?> superClass, BytecodeFieldInfo field, boolean debug)
          Creates a new GeneratedField implementation for a given field
static MethodAccessor generateMethodAccessor(Class<?> superClass, BytecodeMethodInfo method, boolean debug)
          Creates a new GeneratedMethod implementation for a given method
protected
<T> T
instantiate(Class<T> clazz)
          Instantiates the class
protected
<T> Class<T>
makeClass(Class<T> expected, BytecodeTypeInfo target)
          Creates a Method-/Field-/ConstructorAccessor implementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_NAME

protected static final String OBJECT_NAME
Object class name


THROWABLE_EXCEPTIONS

protected static final String[] THROWABLE_EXCEPTIONS
Array of exceptions containing jvm name of Throwable


counter

protected static final AtomicInteger counter
The method class counter

Method Detail

generateMethodAccessor

public static MethodAccessor generateMethodAccessor(Class<?> superClass,
                                                    BytecodeMethodInfo method,
                                                    boolean debug)
Creates a new GeneratedMethod implementation for a given method

Parameters:
superClass - the super class of the GeneratedMethod implementation
method - the BytecodeMethodInfo for which we want to create a GeneratedMethod implementation
debug - true if the bytecode should be output to file
Returns:
the generated class
Throws:
RuntimeException - if an error ocurred

generateConstructorAccessor

public static ConstructorAccessor generateConstructorAccessor(Class<?> superClass,
                                                              BytecodeConstructorInfo constructor,
                                                              boolean debug)
Creates a new GeneratedConstructor implementation for a given constructor

Parameters:
superClass - the super class of the GeneratedConstructor implementation
constructor - the BytecodeConstructorInfo for which we want to create a GeneratedConstructor implementation
debug - true if the bytecode should be output to file
Returns:
the generated class
Throws:
RuntimeException - if an error ocurred

generateFieldAccessor

public static FieldAccessor generateFieldAccessor(Class<?> superClass,
                                                  BytecodeFieldInfo field,
                                                  boolean debug)
Creates a new GeneratedField implementation for a given field

Parameters:
superClass - the super class of the GeneratedField implementation
field - the BytecodeFieldInfo for which we want to create a GeneratedField implementation
debug - true if the bytecode should be output to file
Returns:
the generated class
Throws:
RuntimeException - if an error ocurred

instantiate

protected <T> T instantiate(Class<T> clazz)
Instantiates the class

Parameters:
clazz - the class
Returns:
the instance
Throws:
RuntimeException - if an error ocurred

makeClass

protected <T> Class<T> makeClass(Class<T> expected,
                                 BytecodeTypeInfo target)
Creates a Method-/Field-/ConstructorAccessor implementation

Returns:
the generated class

JBoss Reflection 2.2.1.SP1

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.