@Internal public abstract class AbstractClassFileWriter extends Object implements org.objectweb.asm.Opcodes
Modifier and Type | Field and Description |
---|---|
protected static String |
CONSTRUCTOR_NAME |
protected static int |
DEFAULT_MAX_STACK |
protected static String |
DESCRIPTOR_DEFAULT_CONSTRUCTOR |
protected static org.objectweb.asm.commons.Method |
METHOD_DEFAULT_CONSTRUCTOR |
protected static Map<String,String> |
NAME_TO_TYPE_MAP |
protected static org.objectweb.asm.Type |
TYPE_ARGUMENT |
protected static org.objectweb.asm.Type |
TYPE_ARGUMENT_ARRAY |
protected static org.objectweb.asm.Type |
TYPE_CLASS |
protected static org.objectweb.asm.Type |
TYPE_OBJECT |
protected static String |
ZERO_ARGUMENTS_CONSTANT |
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_MANDATED, ACC_MODULE, ACC_NATIVE, ACC_OPEN, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STATIC_PHASE, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_TRANSITIVE, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASM5, ASM6, ASM7, 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, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, 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, 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, V_PREVIEW, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8, V10, V11, V12, V9
Constructor and Description |
---|
AbstractClassFileWriter() |
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(ClassWriterOutputVisitor classWriterOutputVisitor)
Accept a ClassWriterOutputVisitor to write this writer to disk.
|
protected static void |
buildArgument(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter,
String argumentName,
Object objectType)
Builds an argument instance.
|
protected void |
generateServiceDescriptor(String className,
GeneratedFile generatedFile)
Generates a service discovery for the given class name and file.
|
protected String |
getClassFileName(String className) |
protected static String |
getConstructorDescriptor(Collection<Object> argList) |
protected static String |
getConstructorDescriptor(Object... argumentTypes) |
protected static String |
getInternalName(String className) |
protected static String |
getInternalNameForCast(Object type) |
protected static String |
getMethodDescriptor(Object returnType,
Collection<Object> argumentTypes) |
protected static String |
getMethodDescriptor(String returnType,
String... argumentTypes) |
protected static String |
getMethodSignature(String returnTypeReference,
String... argReferenceTypes) |
protected static org.objectweb.asm.Type |
getObjectType(Object type) |
protected org.objectweb.asm.Type[] |
getObjectTypes(Collection types) |
protected static String |
getTypeDescriptor(Object type)
Returns the descriptor corresponding to the given class.
|
protected static String |
getTypeDescriptor(String className,
String... genericTypes) |
protected org.objectweb.asm.Type |
getTypeForElement(TypedElement type)
Obtain the type for a given element.
|
protected static org.objectweb.asm.Type |
getTypeReference(Object type)
Return the type reference for a class.
|
protected static org.objectweb.asm.Type |
getTypeReferenceForName(String className,
String... genericTypes)
Returns the Type reference corresponding to the given class.
|
protected static Class |
getWrapperType(Object type) |
protected void |
invokeConstructor(org.objectweb.asm.MethodVisitor cv,
Class superClass,
Class... argumentTypes) |
protected static void |
invokeInterfaceStaticMethod(org.objectweb.asm.MethodVisitor visitor,
Class targetType,
org.objectweb.asm.commons.Method method) |
protected static boolean |
isPrimitive(Object type) |
protected ClassWriterOutputVisitor |
newClassWriterOutputVisitor(File compilationDir) |
protected static void |
pushBoxPrimitiveIfNecessary(Object fieldType,
org.objectweb.asm.MethodVisitor injectMethodVisitor) |
protected static void |
pushBuildArgumentsForMethod(org.objectweb.asm.Type owningType,
org.objectweb.asm.ClassWriter declaringClassWriter,
org.objectweb.asm.commons.GeneratorAdapter generatorAdapter,
Map<String,Object> argumentTypes,
Map<String,AnnotationMetadata> argumentAnnotationMetadata,
Map<String,Map<String,Object>> genericTypes,
Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) |
protected static void |
pushCastToType(org.objectweb.asm.MethodVisitor methodVisitor,
Object type) |
protected static void |
pushMethodNameAndTypesArguments(org.objectweb.asm.commons.GeneratorAdapter methodVisitor,
String methodName,
Collection<Object> argumentTypes) |
protected static void |
pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor,
Class arrayType,
int size) |
protected void |
pushNewInstance(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter,
org.objectweb.asm.Type typeToInstantiate)
Push the instantiation of the given type.
|
protected static void |
pushReturnValue(org.objectweb.asm.MethodVisitor methodVisitor,
Object type) |
protected static void |
pushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor,
int index,
int size,
Runnable runnable) |
protected static void |
pushStoreStringInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor,
int index,
int size,
String string) |
protected static void |
pushStoreTypeInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor,
int index,
int size,
Object type) |
protected static void |
pushTypeArgumentElements(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter,
TypedElement declaringElement,
Map<String,ClassElement> types)
Pushes type arguments onto the stack.
|
protected static void |
pushTypeArguments(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter,
Map<String,Object> types)
Pushes type arguments onto the stack.
|
protected void |
returnVoid(org.objectweb.asm.commons.GeneratorAdapter overriddenMethodGenerator) |
protected void |
startClass(org.objectweb.asm.ClassVisitor classWriter,
String className,
org.objectweb.asm.Type superType) |
protected void |
startClass(org.objectweb.asm.ClassWriter classWriter,
String className,
org.objectweb.asm.Type superType,
String genericSignature) |
protected org.objectweb.asm.commons.GeneratorAdapter |
startConstructor(org.objectweb.asm.ClassVisitor classWriter) |
protected org.objectweb.asm.commons.GeneratorAdapter |
startConstructor(org.objectweb.asm.ClassVisitor classWriter,
Object... argumentTypes) |
protected void |
startFinalClass(org.objectweb.asm.ClassVisitor classWriter,
String className,
org.objectweb.asm.Type superType) |
protected org.objectweb.asm.commons.GeneratorAdapter |
startProtectedMethod(org.objectweb.asm.ClassWriter writer,
String methodName,
String returnType,
String... argumentTypes) |
protected void |
startPublicClass(org.objectweb.asm.ClassVisitor classWriter,
String className,
org.objectweb.asm.Type superType) |
protected void |
startPublicFinalClass(org.objectweb.asm.ClassVisitor classWriter,
String className,
org.objectweb.asm.Type superType) |
protected org.objectweb.asm.commons.GeneratorAdapter |
startPublicMethod(org.objectweb.asm.ClassWriter writer,
String methodName,
String returnType,
String... argumentTypes) |
protected org.objectweb.asm.commons.GeneratorAdapter |
startPublicMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter,
Class returnType,
String methodName) |
protected Map<String,Object> |
toParameterTypes(ParameterElement... parameters)
Converts a parameters to type arguments.
|
protected Map<String,Object> |
toTypeArguments(Map<String,ClassElement> typeArguments)
Converts a map of class elements to type arguments.
|
protected Map<String,Map<String,Object>> |
toTypeArguments(ParameterElement... parameters)
Converts a map of class elements to type arguments.
|
protected org.objectweb.asm.commons.GeneratorAdapter |
visitStaticInitializer(org.objectweb.asm.ClassVisitor classWriter) |
protected void |
writeClassToDisk(File targetDir,
org.objectweb.asm.ClassWriter classWriter,
String className)
Writes the class file to disk in the given directory.
|
protected void |
writeClassToDisk(OutputStream out,
org.objectweb.asm.ClassWriter classWriter) |
void |
writeTo(File targetDir)
Write the class to the target directory.
|
protected static final org.objectweb.asm.Type TYPE_ARGUMENT
protected static final org.objectweb.asm.Type TYPE_ARGUMENT_ARRAY
protected static final String ZERO_ARGUMENTS_CONSTANT
protected static final String CONSTRUCTOR_NAME
protected static final String DESCRIPTOR_DEFAULT_CONSTRUCTOR
protected static final org.objectweb.asm.commons.Method METHOD_DEFAULT_CONSTRUCTOR
protected static final org.objectweb.asm.Type TYPE_OBJECT
protected static final org.objectweb.asm.Type TYPE_CLASS
protected static final int DEFAULT_MAX_STACK
protected static void pushTypeArgumentElements(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, TypedElement declaringElement, Map<String,ClassElement> types)
generatorAdapter
- The generator adapterdeclaringElement
- The declaring class element of the genericstypes
- The type referencesprotected static void pushTypeArguments(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, Map<String,Object> types)
generatorAdapter
- The generator adaptertypes
- The type referencesprotected static void buildArgument(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, Object objectType)
generatorAdapter
- The generator adapter.argumentName
- The argument nameobjectType
- The object typeprotected static void pushBuildArgumentsForMethod(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, Map<String,Object> argumentTypes, Map<String,AnnotationMetadata> argumentAnnotationMetadata, Map<String,Map<String,Object>> genericTypes, Map<String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)
owningType
- The owning typedeclaringClassWriter
- The declaring class writergeneratorAdapter
- The GeneratorAdapter
argumentTypes
- The argument typesargumentAnnotationMetadata
- The argument annotation metadatagenericTypes
- The generic typesloadTypeMethods
- The load type methodspublic void writeTo(File targetDir) throws IOException
targetDir
- The target directoryIOException
- if there is an error writing the fileprotected org.objectweb.asm.Type getTypeForElement(@Nonnull TypedElement type)
type
- The element type@NotNull protected Map<String,Object> toTypeArguments(@NotNull Map<String,ClassElement> typeArguments)
typeArguments
- The type arguments@NotNull protected Map<String,Map<String,Object>> toTypeArguments(ParameterElement... parameters)
parameters
- The parametesr@NotNull protected Map<String,Object> toParameterTypes(ParameterElement... parameters)
parameters
- The parameterspublic abstract void accept(ClassWriterOutputVisitor classWriterOutputVisitor) throws IOException
classWriterOutputVisitor
- The ClassWriterOutputVisitor
IOException
- if there is an error writing to diskprotected static String getTypeDescriptor(Object type)
type
- The typeprotected static org.objectweb.asm.Type getTypeReferenceForName(String className, String... genericTypes)
className
- The class namegenericTypes
- The generic typesType
protected static org.objectweb.asm.Type getTypeReference(Object type)
type
- The typeType
protected static void pushBoxPrimitiveIfNecessary(Object fieldType, org.objectweb.asm.MethodVisitor injectMethodVisitor)
fieldType
- The field typeinjectMethodVisitor
- The MethodVisitor
protected static void pushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, Object type)
methodVisitor
- The MethodVisitor
type
- The typeprotected static void pushReturnValue(org.objectweb.asm.MethodVisitor methodVisitor, Object type)
methodVisitor
- The MethodVisitor
type
- The typeprotected static Class getWrapperType(Object type)
type
- The typeprotected static boolean isPrimitive(Object type)
type
- The typeprotected static void pushMethodNameAndTypesArguments(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, String methodName, Collection<Object> argumentTypes)
methodVisitor
- The method visitor as GeneratorAdapter
methodName
- The method nameargumentTypes
- The argument typesprotected static void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class arrayType, int size)
methodVisitor
- The method visitor as GeneratorAdapter
arrayType
- The array classsize
- The sizeprotected static void pushStoreStringInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, String string)
methodVisitor
- The method visitor as GeneratorAdapter
index
- The indexsize
- The sizestring
- The stringprotected static void pushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, Runnable runnable)
methodVisitor
- The method visitor as GeneratorAdapter
index
- The indexsize
- The sizerunnable
- The runnableprotected static void pushStoreTypeInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, Object type)
methodVisitor
- The method visitor as GeneratorAdapter
index
- The indexsize
- The sizetype
- The typeprotected org.objectweb.asm.Type[] getObjectTypes(Collection types)
types
- The typesType
of the objectsprotected static org.objectweb.asm.Type getObjectType(Object type)
type
- The typeType
for the object typeprotected static String getTypeDescriptor(String className, String... genericTypes)
className
- The class namegenericTypes
- The generic typesprotected static String getMethodDescriptor(String returnType, String... argumentTypes)
returnType
- The return typeargumentTypes
- The argument typesprotected static String getMethodDescriptor(Object returnType, Collection<Object> argumentTypes)
returnType
- The return typeargumentTypes
- The argument typesprotected static String getMethodSignature(String returnTypeReference, String... argReferenceTypes)
returnTypeReference
- The return type referenceargReferenceTypes
- The argument reference typesprotected static String getConstructorDescriptor(Object... argumentTypes)
argumentTypes
- The argument typesprotected static String getConstructorDescriptor(Collection<Object> argList)
argList
- The argument listprotected void writeClassToDisk(File targetDir, org.objectweb.asm.ClassWriter classWriter, String className) throws IOException
targetDir
- The target directoryclassWriter
- The current class writerclassName
- The class nameIOException
- if there is a problem writing the class to diskprotected void writeClassToDisk(OutputStream out, org.objectweb.asm.ClassWriter classWriter) throws IOException
out
- The output streamclassWriter
- The current class writerIOException
- if there is a problem writing the class to diskprotected org.objectweb.asm.commons.GeneratorAdapter startConstructor(org.objectweb.asm.ClassVisitor classWriter)
classWriter
- The current class writerGeneratorAdapter
for the constructorprotected org.objectweb.asm.commons.GeneratorAdapter startConstructor(org.objectweb.asm.ClassVisitor classWriter, Object... argumentTypes)
classWriter
- The current class writerargumentTypes
- The argument typesGeneratorAdapter
for the constructorprotected void startClass(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType)
classWriter
- The current class writerclassName
- The class namesuperType
- The super typeprotected void startPublicClass(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType)
classWriter
- The current class writerclassName
- The class namesuperType
- The super typeprotected void startFinalClass(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType)
classWriter
- The current class writerclassName
- The class namesuperType
- The super typeprotected void startPublicFinalClass(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType)
classWriter
- The current class writerclassName
- The class namesuperType
- The super typeprotected void startClass(org.objectweb.asm.ClassWriter classWriter, String className, org.objectweb.asm.Type superType, String genericSignature)
classWriter
- The current class writerclassName
- The class namesuperType
- The super typegenericSignature
- The generic signatureprotected void invokeConstructor(org.objectweb.asm.MethodVisitor cv, Class superClass, Class... argumentTypes)
cv
- The constructor visitorsuperClass
- The super classargumentTypes
- The argument typesprotected static void invokeInterfaceStaticMethod(org.objectweb.asm.MethodVisitor visitor, Class targetType, org.objectweb.asm.commons.Method method)
visitor
- The interface visitortargetType
- The target typemethod
- The methodprotected org.objectweb.asm.commons.GeneratorAdapter startPublicMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter, Class returnType, String methodName)
classWriter
- The current class writerreturnType
- The return typemethodName
- The method nameGeneratorAdapter
for the methodprotected static String getInternalName(String className)
className
- The class nameprotected static String getInternalNameForCast(Object type)
type
- The typeprotected String getClassFileName(String className)
className
- The class nameprotected ClassWriterOutputVisitor newClassWriterOutputVisitor(File compilationDir)
compilationDir
- The compilation directoryprotected void returnVoid(org.objectweb.asm.commons.GeneratorAdapter overriddenMethodGenerator)
overriddenMethodGenerator
- The overriden method generatorprotected org.objectweb.asm.commons.GeneratorAdapter visitStaticInitializer(org.objectweb.asm.ClassVisitor classWriter)
classWriter
- The current class writerGeneratorAdapter
protected org.objectweb.asm.commons.GeneratorAdapter startPublicMethod(org.objectweb.asm.ClassWriter writer, String methodName, String returnType, String... argumentTypes)
writer
- The class writermethodName
- The method namereturnType
- The return typeargumentTypes
- The argument typesGeneratorAdapter
protected org.objectweb.asm.commons.GeneratorAdapter startProtectedMethod(org.objectweb.asm.ClassWriter writer, String methodName, String returnType, String... argumentTypes)
writer
- The class writermethodName
- The method namereturnType
- The return typeargumentTypes
- The argument typesGeneratorAdapter
protected void generateServiceDescriptor(String className, GeneratedFile generatedFile) throws IOException
className
- The class namegeneratedFile
- The generated fileIOException
- An exception if an error occursprotected void pushNewInstance(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type typeToInstantiate)
generatorAdapter
- The generator adaptortypeToInstantiate
- The type to instantiate.