Top Description Fields Constructors Methods
javassist.tools.rmi

public Class StubGenerator

extends Object
implements Translator
Class Inheritance
All Implemented Interfaces
javassist.Translator
Imports
java.lang.reflect.Method, java.util.Hashtable, .Map, javassist.CannotCompileException, .ClassPool, .CtClass, .CtConstructor, .CtField, .CtMethod, .CtMethod.ConstParameter, .CtNewConstructor, .CtNewMethod, .Modifier, .NotFoundException, .Translator

A stub-code generator. It is used for producing a proxy class.

The proxy class for class A is as follows:

public class A implements Proxy, Serializable {
  private ObjectImporter importer;
  private int objectId;
  public int _getObjectId() { return objectId; }
  public A(ObjectImporter oi, int id) {
    importer = oi; objectId = id;
  }

  ... the same methods that the original class A declares ...
}

Instances of the proxy class is created by an ObjectImporter object.

Field Summary

Modifier and TypeField and Description
private static final String
private ClassPool
private CtClass[]
private static final String
private static final String
private CtMethod
private CtMethod
private CtClass[]
private Map<String, CtClass>
private CtClass[]
private static final String

Constructor Summary

AccessConstructor and Description
public
StubGenerator()

Constructs a stub-code generator.

Method Summary

Modifier and TypeMethod and Description
private void
addMethods(CtClass proxy, Method[] ms)

public boolean
isProxyClass(String
a fully-qualified class name
name
)

Returns true if the specified class is a proxy class recorded by makeProxyClass().

public synchronized boolean

Returns:

false if the proxy class has been already produced.
makeProxyClass
(Class<?>
the class referenced through the proxy class.
clazz
)

Makes a proxy class.

private void
modifySuperclass(CtClass orgclass)

Adds a default constructor to the super classes.

public void
onLoad(ClassPool
the ClassPool that this translator should use.
pool
,
String
the name of the class being loaded.
classname
)

Implements javassist.Translator.onLoad.

Does nothing.

private CtClass
produceProxyClass(CtClass orgclass, Class<?> orgRtClass)

public void
start(ClassPool
the ClassPool that this translator should use.
pool
)

Implements javassist.Translator.start.

Initializes the object.

private CtClass
toCtClass(Class<?> rtclass)

private CtClass[]
toCtClass(Class<?>[] rtclasses)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessorObjectIdback to summary
private static final String accessorObjectId
classPoolback to summary
private ClassPool classPool
exceptionForProxyback to summary
private CtClass[] exceptionForProxy
fieldImporterback to summary
private static final String fieldImporter
fieldObjectIdback to summary
private static final String fieldObjectId
forwardMethodback to summary
private CtMethod forwardMethod
forwardStaticMethodback to summary
private CtMethod forwardStaticMethod
interfacesForProxyback to summary
private CtClass[] interfacesForProxy
proxyClassesback to summary
private Map<String, CtClass> proxyClasses
proxyConstructorParamTypesback to summary
private CtClass[] proxyConstructorParamTypes
sampleClassback to summary
private static final String sampleClass

Constructor Detail

StubGeneratorback to summary
public StubGenerator()

Constructs a stub-code generator.

Method Detail

addMethodsback to summary
private void addMethods(CtClass proxy, Method[] ms) throws CannotCompileException, NotFoundException
isProxyClassback to summary
public boolean isProxyClass(String name)

Returns true if the specified class is a proxy class recorded by makeProxyClass().

Parameters
name:String

a fully-qualified class name

makeProxyClassback to summary
public synchronized boolean makeProxyClass(Class<?> clazz) throws CannotCompileException, NotFoundException

Makes a proxy class. The produced class is substituted for the original class.

Parameters
clazz:Class<?>

the class referenced through the proxy class.

Returns:boolean

false if the proxy class has been already produced.

modifySuperclassback to summary
private void modifySuperclass(CtClass orgclass) throws CannotCompileException, NotFoundException

Adds a default constructor to the super classes.

onLoadback to summary
public void onLoad(ClassPool pool, String classname)

Implements javassist.Translator.onLoad.

Does nothing. This is a method declared in javassist.Translator.

Parameters
pool:ClassPool

Doc from javassist.Translator.onLoad.

the ClassPool that this translator should use.

classname:String

Doc from javassist.Translator.onLoad.

the name of the class being loaded.

Annotations
@Override
See Also
javassist.Translator#onLoad(ClassPool, String)
produceProxyClassback to summary
private CtClass produceProxyClass(CtClass orgclass, Class<?> orgRtClass) throws CannotCompileException, NotFoundException
startback to summary
public void start(ClassPool pool) throws NotFoundException

Implements javassist.Translator.start.

Initializes the object. This is a method declared in javassist.Translator.

Parameters
pool:ClassPool

Doc from javassist.Translator.start.

the ClassPool that this translator should use.

Annotations
@Override
Exceptions
NotFoundException:

Doc from javassist.Translator.start.

if a CtClass cannot be found.

See Also
javassist.Translator#start(ClassPool)
toCtClassback to summary
private CtClass toCtClass(Class<?> rtclass) throws NotFoundException
toCtClassback to summary
private CtClass[] toCtClass(Class<?>[] rtclasses) throws NotFoundException