| java.lang.Object com.tc.object.bytecode.ByteCodeUtil
ByteCodeUtil | public class ByteCodeUtil implements Opcodes(Code) | | Utility methods for working with byte code.
|
Method Summary | |
public static String[] | addInterfaces(String[] existing, String[] toAdd) | public static void | addTypeSpecificParameterLoad(MethodVisitor c, Type type, int offset) Add instructions to load type-specific value from local variable onto stack. | final public static String | classNameToFileName(String className) | public static String | codeToName(String typeCode) | public static void | createParametersToArrayByteCode(MethodVisitor c, Type[] parameters) | public static void | createParametersToArrayByteCode(MethodVisitor c, Type[] parameters, int offset) | public static String | fieldGetterMethod(String fieldName) | public static String | fieldSetterMethod(String fieldName) | public static String | generateAutolockName(ObjectID id) | public static String | generateLiteralLockName(int literalValuesValueFor, Object obj) The first argument should be "(new LiteralValues()).valueFor(obj)", but I didn't want to slurp in a whole mess of
classes into the boot jar by including LiteralValues. | public static String | generateNamedLockName(Object obj) | public static String | generateVolatileLockName(ObjectID id, String fieldName) | final public static byte[] | getBytesForClass(String className, ClassLoader loader) | final public static byte[] | getBytesForInputstream(InputStream is) Read input stream into a byte array using a 4k buffer. | public static int | getFirstLocalVariableOffset(int callingMethodModifier, String desc) | public static int | getLocalVariableOffset(int methodModifier) Returns 0 if the method is static. | public static boolean | isAutolockName(String lockName) | public static boolean | isParent(String fieldName) Check whether the field name indicates that this is an inner classes synthetic
field referring to the parent "this" reference. | public static boolean | isPrimitive(Type t) | public static boolean | isSynthetic(String fieldName) | public static boolean | isSynthetic(int access) | public static boolean | isTCSynthetic(String fieldName) | public static String | methodDescriptionToMethodArgument(String desc) | public static String | methodDescriptionToReturnType(String desc) | public static long | objectIdFromLockName(String lockName) | public static void | prepareStackForMethodCall(int callingMethodModifier, String desc, MethodVisitor c) | public static void | pushDefaultValue(int variable, MethodVisitor c, Type type) | public static void | pushInstanceVariable(MethodVisitor c, String className, String fieldName, String description) Add instruction to retrieve specified field in the object on the stack and replace
with the field value. | public static void | pushMethodArguments(int callingMethodModifier, String desc, MethodVisitor c) | public static void | pushThis(MethodVisitor c) | public static String | sortToPrimitiveMethodName(int sort) Convert from
com.tc.asm.Type.getSort to a primitive method
name like "booleanValue". | public static String | sortToWrapperName(int sort) | public static String | stripGeneratedLockHeader(String lockName) | public static void | systemOutPrintln(MethodVisitor mv, String msg) |
DMI_METHOD_RENAME_PREFIX | final public static String DMI_METHOD_RENAME_PREFIX(Code) | | |
MANAGEABLE_CLASS | final public static String MANAGEABLE_CLASS(Code) | | |
MANAGEABLE_TYPE | final public static String MANAGEABLE_TYPE(Code) | | |
MANAGED_VALUES_GETTER | final public static String MANAGED_VALUES_GETTER(Code) | | |
MANAGED_VALUES_GETTER_DESCRIPTION | final public static String MANAGED_VALUES_GETTER_DESCRIPTION(Code) | | |
MANAGED_VALUES_SETTER | final public static String MANAGED_VALUES_SETTER(Code) | | |
METHOD_RENAME_PREFIX | final public static String METHOD_RENAME_PREFIX(Code) | | |
NAMEDCLASSLOADER_CLASS | final public static String NAMEDCLASSLOADER_CLASS(Code) | | |
NAMEDCLASSLOADER_TYPE | final public static String NAMEDCLASSLOADER_TYPE(Code) | | |
SYNC_METHOD_RENAME_PREFIX | final public static String SYNC_METHOD_RENAME_PREFIX(Code) | | |
TC_FIELD_PREFIX | final public static String TC_FIELD_PREFIX(Code) | | |
TC_METHOD_PREFIX | final public static String TC_METHOD_PREFIX(Code) | | |
TRANSPARENT_ACCESS_CLASS | final public static String TRANSPARENT_ACCESS_CLASS(Code) | | |
TRANSPARENT_ACCESS_TYPE | final public static String TRANSPARENT_ACCESS_TYPE(Code) | | |
VALUES_GETTER_DESCRIPTION | final public static String VALUES_GETTER_DESCRIPTION(Code) | | |
VALUES_SETTER_DESCRIPTION | final public static String VALUES_SETTER_DESCRIPTION(Code) | | |
WEBAPPCONFIG_CLASS | final public static String WEBAPPCONFIG_CLASS(Code) | | |
WEBAPPCONFIG_TYPE | final public static String WEBAPPCONFIG_TYPE(Code) | | |
addInterfaces | public static String[] addInterfaces(String[] existing, String[] toAdd)(Code) | | Given a set of existing interfaces, add some more (without duplicates)
Parameters: existing - The existing interfaces Parameters: toAdd - The interfaces to add A set of interfaces containing all of existing and toAdd with no dups |
addTypeSpecificParameterLoad | public static void addTypeSpecificParameterLoad(MethodVisitor c, Type type, int offset)(Code) | | Add instructions to load type-specific value from local variable onto stack. Primitve
values are wrapped into their wrapper object.
Parameters: c - Method visitor Parameters: type - The type of the variable Parameters: offset - The local variable offset |
classNameToFileName | final public static String classNameToFileName(String className)(Code) | | Translate class name to file name
Parameters: className - The class name "java.lang.String" The file name on the classpath: "java/lang/String.class" |
codeToName | public static String codeToName(String typeCode)(Code) | | Translate type code to type name
Parameters: typeCode - Code from bytecode like B, C, etc Primitive type name: "byte", "char", etc |
createParametersToArrayByteCode | public static void createParametersToArrayByteCode(MethodVisitor c, Type[] parameters)(Code) | | Add instructions to convert the local variables typed with parameters into an array
assuming values start at local variable offset of 1
Parameters: c - Method visitor Parameters: parameters - Paramater to convert |
createParametersToArrayByteCode | public static void createParametersToArrayByteCode(MethodVisitor c, Type[] parameters, int offset)(Code) | | Add instructions to convert the parameters into an array
Parameters: c - Method visitor Parameters: parameters - Paramater types to convert Parameters: offset - Offset into local variables for values |
fieldGetterMethod | public static String fieldGetterMethod(String fieldName)(Code) | | Get name of synthetic field getter method added by Terracotta
Parameters: fieldName - The field name Getter method name |
fieldSetterMethod | public static String fieldSetterMethod(String fieldName)(Code) | | Get name of synthetic field setter method added by Terracotta
Parameters: fieldName - The field name Setter method name |
generateAutolockName | public static String generateAutolockName(ObjectID id)(Code) | | Get auto lock name for object identifier
Parameters: id - Identifier Auto lock name |
generateLiteralLockName | public static String generateLiteralLockName(int literalValuesValueFor, Object obj)(Code) | | The first argument should be "(new LiteralValues()).valueFor(obj)", but I didn't want to slurp in a whole mess of
classes into the boot jar by including LiteralValues. It's gross, but ManagerImpl just makes the call itself.
Parameters: literalValuesValueFor - Literal value code Parameters: obj - The lock object |
generateNamedLockName | public static String generateNamedLockName(Object obj)(Code) | | Get named lock name for the lock object
Parameters: obj - Lock object Named lock name |
generateVolatileLockName | public static String generateVolatileLockName(ObjectID id, String fieldName)(Code) | | Get volatile lock name
Parameters: id - Object identifier Parameters: field - Volatile field Lock name |
getBytesForClass | final public static byte[] getBytesForClass(String className, ClassLoader loader) throws ClassNotFoundException(Code) | | Read the bytes defining the class
Parameters: className - The class Parameters: loader - The classloader The underlying bytes |
getBytesForInputstream | final public static byte[] getBytesForInputstream(InputStream is) throws IOException(Code) | | Read input stream into a byte array using a 4k buffer. Close stream when done.
Parameters: is - Input stream Bytes read from stream throws: IOException - If there is an error reading the stream |
getFirstLocalVariableOffset | public static int getFirstLocalVariableOffset(int callingMethodModifier, String desc)(Code) | | Get offset of first local variable after method args
Parameters: callingMethodModifier - Calling method modifier Parameters: desc - Method descriptor First local variable offset |
getLocalVariableOffset | public static int getLocalVariableOffset(int methodModifier)(Code) | | Returns 0 if the method is static. 1 If the method is not.
Parameters: methodModifier - 0 if static, 1 if not |
isAutolockName | public static boolean isAutolockName(String lockName)(Code) | | Determine whether a lock is an autolock based on its name
Parameters: lockName - The lock name True if an autolock |
isParent | public static boolean isParent(String fieldName)(Code) | | Check whether the field name indicates that this is an inner classes synthetic
field referring to the parent "this" reference.
Parameters: fieldName - The field name True if this field refers to the parent this |
isPrimitive | public static boolean isPrimitive(Type t)(Code) | | Check whether the type is a primitve
Parameters: t - The ASM type True if primitive |
isSynthetic | public static boolean isSynthetic(String fieldName)(Code) | | Determine whether a field is synthetic
Parameters: fieldName - The field name True if synthetic |
isSynthetic | public static boolean isSynthetic(int access)(Code) | | Determine whether an access modifier code indicates synthetic
Parameters: access - Access modifier code True if synthetic flag is set |
isTCSynthetic | public static boolean isTCSynthetic(String fieldName)(Code) | | Determine whether a field is synthetic and was added by Terracotta
Parameters: fieldName - The field name True if synthetic and added by Terracotta |
methodDescriptionToMethodArgument | public static String methodDescriptionToMethodArgument(String desc)(Code) | | Turn method description with byte code types into a readable signature
Parameters: desc - The bytecode description The method argument form |
methodDescriptionToReturnType | public static String methodDescriptionToReturnType(String desc)(Code) | | Get return type (class name) from method descriptor
Parameters: desc - Method descriptor Return type class name |
objectIdFromLockName | public static long objectIdFromLockName(String lockName)(Code) | | Get lock ID from autolock name
Parameters: lockName - The lock name Lock ID throws: IllegalArgumentException - If not an autolock |
prepareStackForMethodCall | public static void prepareStackForMethodCall(int callingMethodModifier, String desc, MethodVisitor c)(Code) | | Push this (if not static) and all method args onto stack
Parameters: callingMethodModifier - Calling method modifier Parameters: desc - Method descriptor Parameters: c - Calling method visitor |
pushDefaultValue | public static void pushDefaultValue(int variable, MethodVisitor c, Type type)(Code) | | Assign the default value to the variable
Parameters: variable - The local variable to which the default value will be assigned Parameters: c - MethodVisitor Parameters: type - Type of the variable |
pushInstanceVariable | public static void pushInstanceVariable(MethodVisitor c, String className, String fieldName, String description)(Code) | | Add instruction to retrieve specified field in the object on the stack and replace
with the field value.
Parameters: c - Current method visitor Parameters: className - The field class Parameters: fieldName - The field name Parameters: description - The field type |
pushMethodArguments | public static void pushMethodArguments(int callingMethodModifier, String desc, MethodVisitor c)(Code) | | Add instructions to load method args into the stack
Parameters: callingMethodModifier - Calling method modifier Parameters: desc - Method descriptor Parameters: c - Current method visitor |
pushThis | public static void pushThis(MethodVisitor c)(Code) | | Add instruction to retrieve "this" from the local vars and load onto the stack
Parameters: c - The current method visitor |
sortToPrimitiveMethodName | public static String sortToPrimitiveMethodName(int sort)(Code) | | Convert from
com.tc.asm.Type.getSort to a primitive method
name like "booleanValue".
Parameters: Type - kind Primitive method name |
sortToWrapperName | public static String sortToWrapperName(int sort)(Code) | | Map from primite type to wrapper class type
Parameters: sort - Kind of primitve type as in com.tc.asm.Type.getSort Wrapper class name, like "java/lang/Boolean" |
stripGeneratedLockHeader | public static String stripGeneratedLockHeader(String lockName)(Code) | | Strip generated lock header from lock name
Parameters: lockName - Lock name Real lock name |
systemOutPrintln | public static void systemOutPrintln(MethodVisitor mv, String msg)(Code) | | Add instructions to print msg to System.out
Parameters: mv - Method visitor Parameters: msg - Message to print |
|
|