|
20091031, rgf | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.asm.ClassAdapter
org.rexxla.bsf.engines.rexx.RexxExtendClass
public class RexxExtendClass
Extends a supplied class and creates proxy methods (dispatching to RexxProxy objects), if the Java methods are defined as abstract or if a list of Java methods to proxy gets supplied in the constructor. All public constructors in the extended class expect a RexxProxy object as the first argument, followed by all the arguments in the defined order, if arguments are defined in the original class.
The extended class supplies the static public methods setDefaultHandler(RexxProxy rp)
and RexxProxy getDefaultHandler()
to set and get the default RexxProxy handler, which
is used for forwarding static methods and when creating instances of the class and superclass constructors
invoke instance methods.
An instance of the extended class has the methods RexxProxy getTargetRexxProxy()
and setTargetRexxProxy(RexxProxy rp)
implemented, which allow to retrieve or set
the RexxProxy object to which method invocations get forwarded to.
If concrete instance methods of a class are generated in the extended class, then a
method named "forwardToSuper"
and one named
"forwardToSuperStrict"
will be created which allow the Rexx programmer
to explicitly invoke masked methods in the super (extended) class.
If concrete static methods of a class are generated in the extended class, then a
method named "forwardToSuperStatic"
and one named
"forwardToSuperStaticStrict"
will be created which allow the Rexx programmer
to explicitly invoke masked methods in the super (extended) class.
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2009 Rony G. Flatscher Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------
Field Summary | |
---|---|
(package private) static int[] |
arr_ICONST
|
protected static boolean |
bDebugClassVisitor
|
protected static boolean |
bDebugMethodVisitor
|
protected org.objectweb.asm.ClassVisitor |
cv
The ClassVisitor to which this adapter delegates calls. |
(package private) static java.lang.String |
FORWARD_TO_SUPER_APPEND_STRING
|
(package private) static java.util.HashSet |
primitiveTypes
|
(package private) static java.lang.String |
rexxExceptionName
|
(package private) static java.lang.String |
rexxProxyName
|
(package private) static java.lang.String |
thisPgmName
|
(package private) TransformationData |
tranData
|
(package private) static java.util.HashMap |
type2getPrimitiveValue
|
(package private) static java.util.HashMap |
type2initDesc
|
(package private) static java.util.HashMap |
type2syntheticWrapperFields
|
(package private) static java.util.HashMap |
type2valueOfDesc
|
(package private) static java.util.HashMap |
type2wrapperClass
|
Fields inherited from interface org.objectweb.asm.Opcodes |
---|
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEDYNAMIC_OWNER, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7 |
Constructor Summary | |
---|---|
RexxExtendClass(org.objectweb.asm.ClassVisitor cv)
Constructs a new ClassAdapter object. |
|
RexxExtendClass(org.objectweb.asm.ClassVisitor cv,
java.lang.String newClassName,
int newClassVersion)
Constructs a new ClassAdapter object. |
|
RexxExtendClass(org.objectweb.asm.ClassVisitor cv,
java.lang.String newClassName,
int newClassVersion,
java.lang.String[] methodNamesToAdd)
Constructs a new ClassAdapter object. |
Method Summary | |
---|---|
static java.lang.String |
getMethodAccessAsString(int access)
|
(package private) static java.lang.String |
getPlainMethodSignature(TransformationData td)
Create and return a string with the method's "desc" delimited with
" | " and followed by the method's signature as one would
have to give it in a Java program. |
(package private) static java.lang.String |
getPlainValueSignature(org.objectweb.asm.Type t)
Turn a desc type into the plain Java style; arrays like "[Z" or "[[java.lang.String" into "boolean []" resp. |
TransformationData |
getTranData()
|
(package private) static java.lang.String |
pp(java.lang.Object o)
|
void |
visit(int version,
int access,
java.lang.String name,
java.lang.String signature,
java.lang.String superName,
java.lang.String[] interfaces)
Visits the header of the class. |
org.objectweb.asm.AnnotationVisitor |
visitAnnotation(java.lang.String desc,
boolean visible)
Visits an annotation of the class. |
void |
visitAttribute(org.objectweb.asm.Attribute attr)
Visits a non standard attribute of the class. |
void |
visitEnd()
Visits the end of the class. |
org.objectweb.asm.FieldVisitor |
visitField(int access,
java.lang.String name,
java.lang.String desc,
java.lang.String signature,
java.lang.Object value)
Visits a field of the class. |
void |
visitInnerClass(java.lang.String name,
java.lang.String outerName,
java.lang.String innerName,
int access)
Visits information about an inner class. |
org.objectweb.asm.MethodVisitor |
visitMethod(int access,
java.lang.String name,
java.lang.String desc,
java.lang.String signature,
java.lang.String[] exceptions)
Visits a method of the class. |
void |
visitOuterClass(java.lang.String owner,
java.lang.String name,
java.lang.String desc)
Visits the enclosing class of the class. |
void |
visitSource(java.lang.String source,
java.lang.String debug)
Visits the source of the class. |
(package private) void |
workAddClinitMethod(org.objectweb.asm.ClassVisitor cv)
Create class initializer method. |
(package private) void |
workAddFields(org.objectweb.asm.ClassVisitor cv)
Create instance and static fields we need. |
(package private) void |
workAddMethods(org.objectweb.asm.ClassVisitor cv)
Create instance and static fields we need. |
(package private) void |
workConstructor(org.objectweb.asm.MethodVisitor mv)
Creates the bytecode for processing arguments. |
(package private) void |
workProcessArgsAndInvoke(org.objectweb.asm.MethodVisitor mv)
Creates the bytecode for processing arguments. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.objectweb.asm.ClassVisitor cv
ClassVisitor
to which this adapter delegates calls.
protected static final boolean bDebugClassVisitor
protected static final boolean bDebugMethodVisitor
static final java.lang.String thisPgmName
static final java.lang.String rexxExceptionName
static final java.lang.String rexxProxyName
static final java.lang.String FORWARD_TO_SUPER_APPEND_STRING
static final java.util.HashMap type2wrapperClass
static final java.util.HashMap type2valueOfDesc
static final java.util.HashMap type2initDesc
static final java.util.HashMap type2getPrimitiveValue
static final java.util.HashMap type2syntheticWrapperFields
static final java.util.HashSet primitiveTypes
static final int[] arr_ICONST
TransformationData tranData
Constructor Detail |
---|
public RexxExtendClass(org.objectweb.asm.ClassVisitor cv)
ClassAdapter
object. This mode of operation will
only implement abstract methods which will be executed by the RexxProxy.
cv
- the class visitor to which this adapter must delegate calls.public RexxExtendClass(org.objectweb.asm.ClassVisitor cv, java.lang.String newClassName, int newClassVersion)
ClassAdapter
object. This mode of operation will
implement public abstract methods which will be executed by the RexxProxy. In addition
it creates proxy methods for each Java method that carries a name as supplied
in the methodNamesToAdd
array.
This constructor will only create proxy methods for public abstract methods.
cv
- the class visitor to which this adapter must delegate calls.newClassName
- determines new name of the class, if null, an attempt to create
a unique name is undertakennewClassVersion
- if >0 overrides the source class' versionpublic RexxExtendClass(org.objectweb.asm.ClassVisitor cv, java.lang.String newClassName, int newClassVersion, java.lang.String[] methodNamesToAdd)
ClassAdapter
object. This mode of operation will
implement public abstract methods which will be executed by the RexxProxy. In addition
it creates proxy methods for each Java method that carries a name as supplied
in the methodNamesToAdd
array. If the methodNamesToAdd
array
is null
or empty, then all public methods will have a proxy method created for.
cv
- the class visitor to which this adapter must delegate calls.newClassName
- determines new name of the class, if null, an attempt to create
a unique name is undertakennewClassVersion
- if >0 overrides the source class' versionmethodNamesToAdd
- a String array containing (caseless) method names for
which proxy methods should be created; if callbacks to the RexxProxy are desired
from constructors, then they need to be added to this String array under the name
"Method Detail |
---|
public TransformationData getTranData()
public void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
org.objectweb.asm.ClassVisitor
visit
in interface org.objectweb.asm.ClassVisitor
visit
in class org.objectweb.asm.ClassAdapter
version
- the class version.access
- the class's access flags (see Opcodes
). This
parameter also indicates if the class is deprecated.name
- the internal name of the class (see
getInternalName
).signature
- the signature of this class. May be null if
the class is not a generic one, and does not extend or implement
generic classes or interfaces.superName
- the internal of name of the super class (see
getInternalName
). For interfaces,
the super class is Object
. May be null, but
only for the Object
class.interfaces
- the internal names of the class's interfaces (see
getInternalName
). May be
null.public void visitSource(java.lang.String source, java.lang.String debug)
org.objectweb.asm.ClassVisitor
visitSource
in interface org.objectweb.asm.ClassVisitor
visitSource
in class org.objectweb.asm.ClassAdapter
source
- the name of the source file from which the class was
compiled. May be null.debug
- additional debug information to compute the correspondance
between source and compiled elements of the class. May be
null.public void visitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)
org.objectweb.asm.ClassVisitor
visitOuterClass
in interface org.objectweb.asm.ClassVisitor
visitOuterClass
in class org.objectweb.asm.ClassAdapter
owner
- internal name of the enclosing class of the class.name
- the name of the method that contains the class, or
null if the class is not enclosed in a method of its
enclosing class.desc
- the descriptor of the method that contains the class, or
null if the class is not enclosed in a method of its
enclosing class.public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String desc, boolean visible)
org.objectweb.asm.ClassVisitor
visitAnnotation
in interface org.objectweb.asm.ClassVisitor
visitAnnotation
in class org.objectweb.asm.ClassAdapter
desc
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.
public void visitAttribute(org.objectweb.asm.Attribute attr)
org.objectweb.asm.ClassVisitor
visitAttribute
in interface org.objectweb.asm.ClassVisitor
visitAttribute
in class org.objectweb.asm.ClassAdapter
attr
- an attribute.public void visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
org.objectweb.asm.ClassVisitor
visitInnerClass
in interface org.objectweb.asm.ClassVisitor
visitInnerClass
in class org.objectweb.asm.ClassAdapter
name
- the internal name of an inner class (see
getInternalName
).outerName
- the internal name of the class to which the inner class
belongs (see getInternalName
). May
be null for not member classes.innerName
- the (simple) name of the inner class inside its
enclosing class. May be null for anonymous inner
classes.access
- the access flags of the inner class as originally declared
in the enclosing class.public org.objectweb.asm.FieldVisitor visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
org.objectweb.asm.ClassVisitor
visitField
in interface org.objectweb.asm.ClassVisitor
visitField
in class org.objectweb.asm.ClassAdapter
access
- the field's access flags (see Opcodes
). This
parameter also indicates if the field is synthetic and/or
deprecated.name
- the field's name.desc
- the field's descriptor (see Type
).signature
- the field's signature. May be null if the
field's type does not use generic types.value
- the field's initial value. This parameter, which may be
null if the field does not have an initial value, must
be an Integer
, a Float
, a Long
, a
Double
or a String
(for int,
float, long or String fields
respectively). This parameter is only used for static fields.
Its value is ignored for non static fields, which must be
initialized through bytecode instructions in constructors or
methods.
public org.objectweb.asm.MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
org.objectweb.asm.ClassVisitor
MethodVisitor
instance (or null) each time it is
called, i.e., it should not return a previously returned visitor.
visitMethod
in interface org.objectweb.asm.ClassVisitor
visitMethod
in class org.objectweb.asm.ClassAdapter
access
- the method's access flags (see Opcodes
). This
parameter also indicates if the method is synthetic and/or
deprecated.name
- the method's name.desc
- the method's descriptor (see Type
).signature
- the method's signature. May be null if the
method parameters, return type and exceptions do not use generic
types.exceptions
- the internal names of the method's exception classes
(see getInternalName
). May be
null.
public void visitEnd()
org.objectweb.asm.ClassVisitor
visitEnd
in interface org.objectweb.asm.ClassVisitor
visitEnd
in class org.objectweb.asm.ClassAdapter
void workConstructor(org.objectweb.asm.MethodVisitor mv)
void workProcessArgsAndInvoke(org.objectweb.asm.MethodVisitor mv)
mv
- MethodVisitor object to interact withvoid workAddFields(org.objectweb.asm.ClassVisitor cv)
void workAddMethods(org.objectweb.asm.ClassVisitor cv)
void workAddClinitMethod(org.objectweb.asm.ClassVisitor cv)
public static java.lang.String getMethodAccessAsString(int access)
static java.lang.String getPlainMethodSignature(TransformationData td)
"desc"
delimited with
" | "
and followed by the method's signature as one would
have to give it in a Java program.
static java.lang.String getPlainValueSignature(org.objectweb.asm.Type t)
static java.lang.String pp(java.lang.Object o)
|
20091031, rgf | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |