Package org.datanucleus.enhancer
Class EnhanceUtils
java.lang.Object
org.datanucleus.enhancer.EnhanceUtils
Utility class for bytecode enhancement using ASM.
ASM operates around two basic pieces of information about any type.
- ASM class name (ACN) : this is the normal fully qualified class name but replacing the dots with slashes. So java.lang.String will have an ASM class name of "java/lang/String".
- Class Descriptor (CD) : this is used where a type is referred to in a calling sequence etc. and for object types is typically things like "Ljava.lang.String;", but there are variants for primitives.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
ASM class name for boolean.static final String
ASM class name for Boolean.static final String
ASM class name for byte.static final String
ASM class name for Byte.static final String
ASM class name for char.static final String
ASM class name for Character.static final String
ASM class name for double.static final String
ASM class name for Double.static final String
ASM class name for float.static final String
ASM class name for Float.static final String
ASM class name for int.static final String
ASM class name for Integer.static final String
ASM class name for long.static final String
ASM class name for Long.static final String
ASM class name for java.lang.Object.static final String
ASM class name for short.static final String
ASM class name for Short.static final String
ASM class name for java.lang.String.static final String
Descriptor for java.lang.Object.static final String
Class descriptor for String. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
private constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addBIPUSHToMethod
(MethodVisitor visitor, int i) Convenience method to add a BIPUSH-type int to the visitor.static void
addLoadForType
(MethodVisitor visitor, Class type, int number) Convenience method to add a load statement based on the type to be loaded.static void
addReturnForType
(MethodVisitor visitor, Class type) Convenience method to add a return statement based on the type to be returned.static String
Convenience method to return the ASM class name to use as input via the SingleFieldIdentity constructor.static int
static String
Convenience method to give the descriptor for use in an enhanced "field" method.static String
getTypeDescriptorForType
(String clsName) Return the ASM type descriptor for the input class.static String
Convenience method to give the type name given the type.
-
Field Details
-
ACN_boolean
ASM class name for boolean. -
ACN_byte
ASM class name for byte. -
ACN_char
ASM class name for char. -
ACN_double
ASM class name for double. -
ACN_float
ASM class name for float. -
ACN_int
ASM class name for int. -
ACN_long
ASM class name for long. -
ACN_short
ASM class name for short. -
ACN_Boolean
ASM class name for Boolean. -
ACN_Byte
ASM class name for Byte. -
ACN_Character
ASM class name for Character. -
ACN_Double
ASM class name for Double. -
ACN_Float
ASM class name for Float. -
ACN_Integer
ASM class name for Integer. -
ACN_Long
ASM class name for Long. -
ACN_Short
ASM class name for Short. -
ACN_String
ASM class name for java.lang.String. -
ACN_Object
ASM class name for java.lang.Object. -
CD_String
Class descriptor for String. -
CD_Object
Descriptor for java.lang.Object.
-
-
Constructor Details
-
EnhanceUtils
private EnhanceUtils()private constructor to prevent instantiation.
-
-
Method Details
-
addBIPUSHToMethod
Convenience method to add a BIPUSH-type int to the visitor.- Parameters:
visitor
- The MethodVisitori
- number
-
addReturnForType
Convenience method to add a return statement based on the type to be returned.- Parameters:
visitor
- The MethodVisitortype
- The type to return
-
addLoadForType
Convenience method to add a load statement based on the type to be loaded.- Parameters:
visitor
- The MethodVisitortype
- The type to loadnumber
- Number to load
-
getTypeNameForPersistableMethod
Convenience method to give the type name given the type. This is for the assorted methods on the StateManager called things like "replacingStringField", "replacingObjectField", "providedIntField", etc. Just returns the "type" part of the name.- Boolean, bool : returns "Boolean"
- Byte, byte : returns "Byte"
- Character, char : returns "Char"
- Double, double : returns "Double"
- Float, float : returns "Float"
- Integer, int : returns "Int"
- Long, long : returns "Long"
- Short, short : returns "Short"
- String : returns "String"
- all others : returns "Object"
- Parameters:
cls
- The type of the field- Returns:
- Name for the method
-
getTypeDescriptorForType
Return the ASM type descriptor for the input class.- Parameters:
clsName
- The input class name- Returns:
- The ASM type descriptor name
-
getTypeDescriptorForEnhanceMethod
Convenience method to give the descriptor for use in an enhanced "field" method. This is for the assorted methods on the StateManager called things like "replacingStringField", "replacingObjectField", "providedIntField", etc. Returns the ASM descriptor equivalent for the method used- Boolean, bool : returns "Boolean"
- Byte, byte : returns "Byte"
- Character, char : returns "Char"
- Double, double : returns "Double"
- Float, float : returns "Float"
- Integer, int : returns "Int"
- Long, long : returns "Long"
- Short, short : returns "Short"
- String : returns "String"
- all others : returns "Object"
- Parameters:
cls
- The type of the field- Returns:
- Name for the method
-
getASMClassNameForSingleFieldIdentityConstructor
Convenience method to return the ASM class name to use as input via the SingleFieldIdentity constructor. Means that if the fieldType is primitive we return the ASM class name of the object wrapper.- Parameters:
fieldType
- Type of the field- Returns:
- ASM class name to use as input in the constructor
-
getAsmVersionForJRE
public static int getAsmVersionForJRE()
-