JBoss Reflection 2.2.1.SP1

org.jboss.reflect.plugins.javassist.bytecode
Class JavassistMemberFactory

java.lang.Object
  extended by org.jboss.reflect.plugins.javassist.bytecode.JavassistMemberFactory
Direct Known Subclasses:
JavassistBehaviorFactory

public abstract class JavassistMemberFactory
extends Object

Abstract base class to create implementations of the JavassistMethod, JavassistConstructor and JavassistField 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 JavassistConstructor createJavassistConstructor(Class<?> superClass, JavassistConstructorInfo constructor, boolean debug)
          Creates a new JavassistConstructor implementation for a given constructor
static JavassistField createJavassistField(Class<?> superClass, JavassistFieldInfo field, boolean debug)
          Creates a new JavassistField implementation for a given field
static JavassistMethod createJavassistMethod(Class<?> superClass, JavassistMethodInfo method, boolean debug)
          Creates a new JavassistMethod implementation for a given method
protected
<T> T
instantiate(Class<T> clazz)
          Instantiates the class
protected
<T> Class<T>
makeClass(Class<T> expected, JavassistTypeInfo target)
          Creates a JavassistMethod/-Field/-Constructor 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

createJavassistMethod

public static JavassistMethod createJavassistMethod(Class<?> superClass,
                                                    JavassistMethodInfo method,
                                                    boolean debug)
Creates a new JavassistMethod implementation for a given method

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

createJavassistConstructor

public static JavassistConstructor createJavassistConstructor(Class<?> superClass,
                                                              JavassistConstructorInfo constructor,
                                                              boolean debug)
Creates a new JavassistConstructor implementation for a given constructor

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

createJavassistField

public static JavassistField createJavassistField(Class<?> superClass,
                                                  JavassistFieldInfo field,
                                                  boolean debug)
Creates a new JavassistField implementation for a given field

Parameters:
superClass - the super class of the JavassistField implementation
field - the JavassistFieldInfo for which we want to create a JavassistField 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,
                                 JavassistTypeInfo target)
Creates a JavassistMethod/-Field/-Constructor implementation

Returns:
the generated class

JBoss Reflection 2.2.1.SP1

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