Package io.micronaut.inject.writer
Class AbstractClassFileWriter
java.lang.Object
io.micronaut.inject.writer.AbstractClassFileWriter
- All Implemented Interfaces:
ClassOutputWriter
,OriginatingElements
,org.objectweb.asm.Opcodes
- Direct Known Subclasses:
AbstractAnnotationMetadataWriter
,AnnotationMetadataWriter
,AopProxyWriter
,BeanDefinitionWriter
,DispatchWriter
,EvaluatedExpressionWriter
,ExecutableMethodsDefinitionWriter
@Internal
public abstract class AbstractClassFileWriter
extends Object
implements org.objectweb.asm.Opcodes, OriginatingElements, ClassOutputWriter
Abstract class that writes generated classes to disk and provides convenience methods for building classes.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Pattern
protected static final String
protected static final int
protected static final String
protected static final org.objectweb.asm.commons.Method
protected static final org.objectweb.asm.commons.Method
protected static final org.objectweb.asm.commons.Method
protected static final org.objectweb.asm.commons.Method
protected final OriginatingElements
protected static final org.objectweb.asm.Type
protected static final org.objectweb.asm.Type
protected static final org.objectweb.asm.Type
protected static final org.objectweb.asm.Type
protected static final org.objectweb.asm.Type
protected static final String
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_MANDATED, ACC_MODULE, ACC_NATIVE, ACC_OPEN, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_RECORD, 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, ASM10_EXPERIMENTAL, ASM4, ASM5, ASM6, ASM7, ASM8, ASM9, 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, SOURCE_DEPRECATED, SOURCE_MASK, 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, V13, V14, V15, V16, V17, V18, V19, V20, V21, V22, V9
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractClassFileWriter
(Element... originatingElements) protected
AbstractClassFileWriter
(OriginatingElements originatingElements) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOriginatingElement
(@NonNull Element element) Add another element that should be included in the originating elements.protected static void
buildArgument
(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, ClassElement objectType) Builds an argument instance.protected static void
buildArgument
(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, org.objectweb.asm.Type objectType) Builds an argument instance.protected static void
buildArgumentWithGenerics
(AnnotationMetadata annotationMetadataWithDefaults, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, org.objectweb.asm.Type typeReference, ClassElement classElement, Map<String, ClassElement> typeArguments, Set<Object> visitedTypes, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Builds generic type arguments recursively.protected static void
buildArgumentWithGenerics
(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type type, AnnotationMetadataReference annotationMetadata, ClassElement[] generics) Builds generic type arguments recursively.protected static String
getConstructorDescriptor
(Class<?>... argumentTypes) protected static String
protected static String
getConstructorDescriptor
(org.objectweb.asm.Type[] argumentTypes) protected static String
getInternalName
(String className) protected static String
getMethodDescriptor
(TypedElement returnType, Collection<? extends TypedElement> argumentTypes) protected static String
getMethodDescriptor
(Class<?> returnType, Collection<Class<?>> argumentTypes) protected static String
getMethodDescriptor
(String returnType, String... argumentTypes) protected static String
getMethodDescriptor
(org.objectweb.asm.Type returnType, Collection<org.objectweb.asm.Type> argumentTypes) protected static String
getMethodDescriptorForReturnType
(org.objectweb.asm.Type returnType, Collection<? extends TypedElement> argumentTypes) protected static String
getMethodSignature
(String returnTypeReference, String... argReferenceTypes) protected static org.objectweb.asm.Type
getObjectType
(Object type) protected static String
Returns the descriptor corresponding to the given class.protected static String
getTypeDescriptor
(Class<?> type) Returns the descriptor corresponding to the given class.protected static String
getTypeDescriptor
(String type) Returns the descriptor corresponding to the given class.protected static String
getTypeDescriptor
(String className, String... genericTypes) protected static org.objectweb.asm.Type
getTypeReference
(TypedElement 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 void
implementInterceptedTypeMethod
(org.objectweb.asm.Type interceptedType, org.objectweb.asm.ClassWriter classWriter) Implements a method called "getInterceptedType" for the given type and class writer.protected void
invokeConstructor
(org.objectweb.asm.commons.GeneratorAdapter cv, Class<?> superClass, Class<?>... argumentTypes) protected static void
invokeInterfaceStaticMethod
(org.objectweb.asm.MethodVisitor visitor, Class<?> targetType, org.objectweb.asm.commons.Method method) protected ClassWriterOutputVisitor
newClassWriterOutputVisitor
(File compilationDir) protected static void
pushBoxPrimitiveIfNecessary
(TypedElement fieldType, org.objectweb.asm.commons.GeneratorAdapter injectMethodVisitor) protected static void
pushBoxPrimitiveIfNecessary
(Class<?> fieldType, org.objectweb.asm.commons.GeneratorAdapter injectMethodVisitor) protected static void
pushBoxPrimitiveIfNecessary
(org.objectweb.asm.Type fieldType, org.objectweb.asm.commons.GeneratorAdapter injectMethodVisitor) protected static void
pushBuildArgumentsForMethod
(AnnotationMetadata annotationMetadataWithDefaults, String declaringElementName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, Collection<ParameterElement> argumentTypes, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) protected static void
pushCastFromObjectToType
(org.objectweb.asm.commons.GeneratorAdapter ga, TypedElement to) protected static void
pushCastToType
(org.objectweb.asm.commons.GeneratorAdapter ga, TypedElement type) protected static void
pushCastToType
(org.objectweb.asm.commons.GeneratorAdapter ga, TypedElement from, TypedElement to) Cast from one type to another.protected static void
pushCastToType
(org.objectweb.asm.commons.GeneratorAdapter ga, Class<?> type) protected static void
pushCastToType
(org.objectweb.asm.commons.GeneratorAdapter ga, org.objectweb.asm.Type type) protected static void
pushCreateArgument
(AnnotationMetadata annotationMetadataWithDefaults, String declaringTypeName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, TypedElement typedElement, AnnotationMetadata annotationMetadata, Map<String, ClassElement> typeArguments, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Pushes a new Argument creation.static void
pushListOfString
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, List<String> names) protected static void
pushMethodNameAndTypesArguments
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, String methodName, Collection<ClassElement> argumentTypes) protected static void
pushNewArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, int size) protected static <T> void
pushNewArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, Collection<T> collection, Consumer<T> itemConsumer) protected static <T> void
pushNewArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, T[] array, Consumer<T> itemConsumer) protected static void
pushNewArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type arrayType, int size) protected static void
pushNewArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type arrayType, int size, Consumer<Integer> itemConsumer) protected static <T> void
pushNewArrayIndexed
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, Collection<T> collection, BiConsumer<Integer, T> itemConsumer) protected void
pushNewInstance
(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type typeToInstantiate) Push the instantiation of the given type.protected void
pushReturnTypeArgument
(AnnotationMetadata annotationMetadataWithDefaults, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String declaringTypeName, ClassElement argument, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Pushes an argument.protected static void
pushStoreInArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, Runnable runnable) protected static void
pushStoreInArray
(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type type, int index, int size, Runnable runnable) static <T> void
pushStringMapOf
(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, Map<? extends CharSequence, T> annotationData, boolean skipEmpty, T empty, Consumer<T> pushValue) protected static void
pushTypeArgumentElements
(AnnotationMetadata annotationMetadataWithDefaults, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningTypeWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String declaringElementName, Map<String, ClassElement> types, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Pushes type arguments onto the stack.protected void
startClass
(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType) protected org.objectweb.asm.commons.GeneratorAdapter
startConstructor
(org.objectweb.asm.ClassVisitor classWriter) protected org.objectweb.asm.commons.GeneratorAdapter
startConstructor
(org.objectweb.asm.ClassVisitor classWriter, Class<?>... argumentTypes) 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 org.objectweb.asm.commons.GeneratorAdapter
startPublicFinalMethodZeroArgs
(org.objectweb.asm.ClassWriter classWriter, Class<?> returnType, String methodName) protected org.objectweb.asm.commons.GeneratorAdapter
startPublicMethod
(org.objectweb.asm.ClassWriter writer, String methodName, String returnType, String... argumentTypes) protected org.objectweb.asm.commons.GeneratorAdapter
startPublicMethod
(org.objectweb.asm.ClassWriter writer, org.objectweb.asm.commons.Method asmMethod) protected org.objectweb.asm.commons.GeneratorAdapter
startPublicMethodZeroArgs
(org.objectweb.asm.ClassWriter classWriter, Class<?> returnType, String methodName) protected void
startService
(org.objectweb.asm.ClassVisitor classWriter, Class<?> serviceType, String internalClassName, org.objectweb.asm.Type superType) protected void
startService
(org.objectweb.asm.ClassVisitor classWriter, String serviceName, String internalClassName, org.objectweb.asm.Type superType, String... interfaces) protected static String
protected org.objectweb.asm.commons.GeneratorAdapter
visitStaticInitializer
(org.objectweb.asm.ClassVisitor classWriter) protected void
writeClassToDisk
(OutputStream out, org.objectweb.asm.ClassWriter classWriter) void
Write the class to the target directory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.inject.writer.ClassOutputWriter
accept
-
Field Details
-
TYPE_ARGUMENT
protected static final org.objectweb.asm.Type TYPE_ARGUMENT -
TYPE_ARGUMENT_ARRAY
protected static final org.objectweb.asm.Type TYPE_ARGUMENT_ARRAY -
ZERO_ARGUMENTS_CONSTANT
- See Also:
-
CONSTRUCTOR_NAME
- See Also:
-
DESCRIPTOR_DEFAULT_CONSTRUCTOR
- See Also:
-
METHOD_DEFAULT_CONSTRUCTOR
protected static final org.objectweb.asm.commons.Method METHOD_DEFAULT_CONSTRUCTOR -
TYPE_OBJECT
protected static final org.objectweb.asm.Type TYPE_OBJECT -
TYPE_CLASS
protected static final org.objectweb.asm.Type TYPE_CLASS -
DEFAULT_MAX_STACK
protected static final int DEFAULT_MAX_STACK- See Also:
-
TYPE_GENERATED
protected static final org.objectweb.asm.Type TYPE_GENERATED -
ARRAY_PATTERN
-
METHOD_CREATE_ARGUMENT_SIMPLE
protected static final org.objectweb.asm.commons.Method METHOD_CREATE_ARGUMENT_SIMPLE -
METHOD_GENERIC_PLACEHOLDER_SIMPLE
protected static final org.objectweb.asm.commons.Method METHOD_GENERIC_PLACEHOLDER_SIMPLE -
METHOD_CREATE_TYPE_VARIABLE_SIMPLE
protected static final org.objectweb.asm.commons.Method METHOD_CREATE_TYPE_VARIABLE_SIMPLE -
originatingElements
-
-
Constructor Details
-
AbstractClassFileWriter
- Parameters:
originatingElements
- The originating elements
-
AbstractClassFileWriter
- Parameters:
originatingElements
- The originating elements
-
-
Method Details
-
getOriginatingElements
- Specified by:
getOriginatingElements
in interfaceOriginatingElements
- Returns:
- The elements where the bean definition originated from as an array.
-
addOriginatingElement
Description copied from interface:OriginatingElements
Add another element that should be included in the originating elements.- Specified by:
addOriginatingElement
in interfaceOriginatingElements
- Parameters:
element
- The element to add
-
pushTypeArgumentElements
protected static void pushTypeArgumentElements(AnnotationMetadata annotationMetadataWithDefaults, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningTypeWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String declaringElementName, Map<String, ClassElement> types, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Pushes type arguments onto the stack.- Parameters:
annotationMetadataWithDefaults
- The annotation metadata with defaultsowningType
- The owning typeowningTypeWriter
- The declaring class writergeneratorAdapter
- The generator adapterdeclaringElementName
- The declaring class element of the genericstypes
- The type referencesdefaults
- The annotation defaultsloadTypeMethods
- The load type methods
-
buildArgument
protected static void buildArgument(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, org.objectweb.asm.Type objectType) Builds an argument instance.- Parameters:
generatorAdapter
- The generator adapter.argumentName
- The argument nameobjectType
- The object type
-
buildArgument
protected static void buildArgument(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, ClassElement objectType) Builds an argument instance.- Parameters:
generatorAdapter
- The generator adapter.argumentName
- The argument nameobjectType
- The object type
-
buildArgumentWithGenerics
protected static void buildArgumentWithGenerics(AnnotationMetadata annotationMetadataWithDefaults, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, org.objectweb.asm.Type typeReference, ClassElement classElement, Map<String, ClassElement> typeArguments, Set<Object> visitedTypes, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Builds generic type arguments recursively.- Parameters:
annotationMetadataWithDefaults
- The annotation metadata with defaultsowningType
- The owning typeowningClassWriter
- The declaring writergeneratorAdapter
- The generator adapter to useargumentName
- The argument nametypeReference
- The type nameclassElement
- The class element that declares the genericstypeArguments
- The nested type argumentsvisitedTypes
- The visited typesdefaults
- The annotation defaultsloadTypeMethods
- The load type methods
-
buildArgumentWithGenerics
protected static void buildArgumentWithGenerics(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type type, AnnotationMetadataReference annotationMetadata, ClassElement[] generics) Builds generic type arguments recursively.- Parameters:
generatorAdapter
- The generator adapter to usetype
- The type that declares the genericsannotationMetadata
- The annotation metadata referencegenerics
- The generics- Since:
- 3.0.0
-
pushBuildArgumentsForMethod
protected static void pushBuildArgumentsForMethod(AnnotationMetadata annotationMetadataWithDefaults, String declaringElementName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, Collection<ParameterElement> argumentTypes, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) - Parameters:
annotationMetadataWithDefaults
- The annotation metadata with defaultsdeclaringElementName
- The declaring element nameowningType
- The owning typedeclaringClassWriter
- The declaring class writergeneratorAdapter
- TheGeneratorAdapter
argumentTypes
- The argument typesdefaults
- The annotation defaultsloadTypeMethods
- The load type methods
-
pushReturnTypeArgument
protected void pushReturnTypeArgument(AnnotationMetadata annotationMetadataWithDefaults, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String declaringTypeName, ClassElement argument, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Pushes an argument.- Parameters:
annotationMetadataWithDefaults
- The annotation metadata with defaultsowningType
- The owning typeclassWriter
- The declaring class writergeneratorAdapter
- The generator adapterdeclaringTypeName
- The declaring type nameargument
- The argumentdefaults
- The annotation defaultsloadTypeMethods
- The load type methods
-
pushCreateArgument
protected static void pushCreateArgument(AnnotationMetadata annotationMetadataWithDefaults, String declaringTypeName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, String argumentName, TypedElement typedElement, AnnotationMetadata annotationMetadata, Map<String, ClassElement> typeArguments, Map<String, Integer> defaults, Map<String, org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods) Pushes a new Argument creation.- Parameters:
annotationMetadataWithDefaults
- The annotation metadata with defaultsdeclaringTypeName
- The declaring type nameowningType
- The owning typedeclaringClassWriter
- The declaring class writergeneratorAdapter
- The generator adapterargumentName
- The argument nametypedElement
- The typed elementannotationMetadata
- The annotation metadatatypeArguments
- The type argumentsdefaults
- The annotation defaultsloadTypeMethods
- The load type methods
-
writeTo
Write the class to the target directory.- Parameters:
targetDir
- The target directory- Throws:
IOException
- if there is an error writing the file
-
getOriginatingElement
- Returns:
- The originating element
-
implementInterceptedTypeMethod
protected void implementInterceptedTypeMethod(org.objectweb.asm.Type interceptedType, org.objectweb.asm.ClassWriter classWriter) Implements a method called "getInterceptedType" for the given type and class writer.- Parameters:
interceptedType
- The intercepted typeclassWriter
- The class writer
-
getTypeDescriptor
Returns the descriptor corresponding to the given class.- Parameters:
type
- The type- Returns:
- The descriptor for the class
-
getTypeDescriptor
Returns the descriptor corresponding to the given class.- Parameters:
type
- The type- Returns:
- The descriptor for the class
-
getTypeDescriptor
Returns the descriptor corresponding to the given class.- Parameters:
type
- The type- Returns:
- The descriptor for the class
-
getTypeReferenceForName
protected static org.objectweb.asm.Type getTypeReferenceForName(String className, String... genericTypes) Returns the Type reference corresponding to the given class.- Parameters:
className
- The class namegenericTypes
- The generic types- Returns:
- The
Type
-
getTypeReference
Return the type reference for a class.- Parameters:
type
- The type- Returns:
- The
Type
-
pushBoxPrimitiveIfNecessary
protected static void pushBoxPrimitiveIfNecessary(org.objectweb.asm.Type fieldType, org.objectweb.asm.commons.GeneratorAdapter injectMethodVisitor) - Parameters:
fieldType
- The field typeinjectMethodVisitor
- TheGeneratorAdapter
-
pushBoxPrimitiveIfNecessary
protected static void pushBoxPrimitiveIfNecessary(Class<?> fieldType, org.objectweb.asm.commons.GeneratorAdapter injectMethodVisitor) - Parameters:
fieldType
- The field typeinjectMethodVisitor
- TheMethodVisitor
-
pushBoxPrimitiveIfNecessary
protected static void pushBoxPrimitiveIfNecessary(TypedElement fieldType, org.objectweb.asm.commons.GeneratorAdapter injectMethodVisitor) - Parameters:
fieldType
- The field typeinjectMethodVisitor
- TheGeneratorAdapter
-
pushCastToType
protected static void pushCastToType(org.objectweb.asm.commons.GeneratorAdapter ga, org.objectweb.asm.Type type) - Parameters:
ga
- TheGeneratorAdapter
type
- The type
-
pushCastToType
protected static void pushCastToType(org.objectweb.asm.commons.GeneratorAdapter ga, TypedElement type) - Parameters:
ga
- TheMethodVisitor
type
- The type
-
pushCastFromObjectToType
protected static void pushCastFromObjectToType(org.objectweb.asm.commons.GeneratorAdapter ga, TypedElement to) - Parameters:
ga
- TheMethodVisitor
to
- The type
-
pushCastToType
protected static void pushCastToType(org.objectweb.asm.commons.GeneratorAdapter ga, TypedElement from, TypedElement to) Cast from one type to another.- Parameters:
ga
- TheMethodVisitor
from
- The from typeto
- The to type
-
pushCastToType
- Parameters:
ga
- TheMethodVisitor
type
- The type
-
pushMethodNameAndTypesArguments
protected static void pushMethodNameAndTypesArguments(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, String methodName, Collection<ClassElement> argumentTypes) - Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
methodName
- The method nameargumentTypes
- The argument types
-
pushNewArray
protected static <T> void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, Collection<T> collection, Consumer<T> itemConsumer) - Type Parameters:
T
- The type- Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
arrayType
- The array classcollection
- The collectionitemConsumer
- The item consumer
-
pushNewArrayIndexed
protected static <T> void pushNewArrayIndexed(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, Collection<T> collection, BiConsumer<Integer, T> itemConsumer) - Type Parameters:
T
- The type- Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
arrayType
- The array classcollection
- The collectionitemConsumer
- The item consumer
-
pushNewArray
protected static <T> void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, T[] array, Consumer<T> itemConsumer) - Type Parameters:
T
- The type- Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
arrayType
- The array classarray
- The collectionitemConsumer
- The item consumer
-
pushNewArray
protected static void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, Class<?> arrayType, int size) - Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
arrayType
- The array classsize
- The size
-
pushNewArray
protected static void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type arrayType, int size) - Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
arrayType
- The array classsize
- The size
-
pushNewArray
protected static void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type arrayType, int size, Consumer<Integer> itemConsumer) - Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
arrayType
- The array classsize
- The sizeitemConsumer
- The item consumer
-
pushStoreInArray
protected static void pushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, Runnable runnable) - Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
index
- The indexsize
- The sizerunnable
- The runnable
-
pushStoreInArray
protected static void pushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type type, int index, int size, Runnable runnable) - Parameters:
methodVisitor
- The method visitor asGeneratorAdapter
type
- The type of the arrayindex
- The indexsize
- The sizerunnable
- The runnable
-
getObjectType
- Parameters:
type
- The type- Returns:
- The
Type
for the object type
-
getTypeDescriptor
- Parameters:
className
- The class namegenericTypes
- The generic types- Returns:
- The type descriptor as String
-
getMethodDescriptor
- Parameters:
returnType
- The return typeargumentTypes
- The argument types- Returns:
- The method descriptor
-
getMethodDescriptor
protected static String getMethodDescriptor(TypedElement returnType, Collection<? extends TypedElement> argumentTypes) - Parameters:
returnType
- The return typeargumentTypes
- The argument types- Returns:
- The method descriptor
-
getMethodDescriptorForReturnType
protected static String getMethodDescriptorForReturnType(org.objectweb.asm.Type returnType, Collection<? extends TypedElement> argumentTypes) - Parameters:
returnType
- The return typeargumentTypes
- The argument types- Returns:
- The method descriptor
-
getMethodDescriptor
protected static String getMethodDescriptor(Class<?> returnType, Collection<Class<?>> argumentTypes) - Parameters:
returnType
- The return typeargumentTypes
- The argument types- Returns:
- The method descriptor
-
getMethodDescriptor
protected static String getMethodDescriptor(org.objectweb.asm.Type returnType, Collection<org.objectweb.asm.Type> argumentTypes) - Parameters:
returnType
- The return typeargumentTypes
- The argument types- Returns:
- The method descriptor
-
getMethodSignature
- Parameters:
returnTypeReference
- The return type referenceargReferenceTypes
- The argument reference types- Returns:
- The method signature
-
getConstructorDescriptor
- Parameters:
argumentTypes
- The argument types- Returns:
- The constructor descriptor
-
getConstructorDescriptor
- Parameters:
argumentTypes
- The argument types- Returns:
- The constructor descriptor
-
getConstructorDescriptor
- Parameters:
argList
- The argument list- Returns:
- The constructor descriptor
-
writeClassToDisk
protected void writeClassToDisk(OutputStream out, org.objectweb.asm.ClassWriter classWriter) throws IOException - Parameters:
out
- The output streamclassWriter
- The current class writer- Throws:
IOException
- if there is a problem writing the class to disk
-
startConstructor
protected org.objectweb.asm.commons.GeneratorAdapter startConstructor(org.objectweb.asm.ClassVisitor classWriter) - Parameters:
classWriter
- The current class writer- Returns:
- The
GeneratorAdapter
for the constructor
-
startConstructor
protected org.objectweb.asm.commons.GeneratorAdapter startConstructor(org.objectweb.asm.ClassVisitor classWriter, Class<?>... argumentTypes) - Parameters:
classWriter
- The current class writerargumentTypes
- The argument types- Returns:
- The
GeneratorAdapter
for the constructor
-
startClass
protected void startClass(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType) - Parameters:
classWriter
- The current class writerclassName
- The class namesuperType
- The super type
-
startPublicClass
protected void startPublicClass(org.objectweb.asm.ClassVisitor classWriter, String className, org.objectweb.asm.Type superType) - Parameters:
classWriter
- The current class writerclassName
- The class namesuperType
- The super type
-
startService
protected void startService(org.objectweb.asm.ClassVisitor classWriter, Class<?> serviceType, String internalClassName, org.objectweb.asm.Type superType) - Parameters:
classWriter
- The current class writerserviceType
- The service typeinternalClassName
- The class namesuperType
- The super type
-
startService
protected void startService(org.objectweb.asm.ClassVisitor classWriter, String serviceName, String internalClassName, org.objectweb.asm.Type superType, String... interfaces) - Parameters:
classWriter
- The current class writerserviceName
- The service nameinternalClassName
- The class namesuperType
- The super typeinterfaces
- The interfaces
-
invokeConstructor
protected void invokeConstructor(org.objectweb.asm.commons.GeneratorAdapter cv, Class<?> superClass, Class<?>... argumentTypes) - Parameters:
cv
- The constructor visitorsuperClass
- The super classargumentTypes
- The argument types
-
invokeInterfaceStaticMethod
protected static void invokeInterfaceStaticMethod(org.objectweb.asm.MethodVisitor visitor, Class<?> targetType, org.objectweb.asm.commons.Method method) - Parameters:
visitor
- The interface visitortargetType
- The target typemethod
- The method
-
startPublicMethodZeroArgs
protected org.objectweb.asm.commons.GeneratorAdapter startPublicMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter, Class<?> returnType, String methodName) - Parameters:
classWriter
- The current class writerreturnType
- The return typemethodName
- The method name- Returns:
- TheThe
GeneratorAdapter
for the method
-
startPublicFinalMethodZeroArgs
protected org.objectweb.asm.commons.GeneratorAdapter startPublicFinalMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter, Class<?> returnType, String methodName) - Parameters:
classWriter
- The current class writerreturnType
- The return typemethodName
- The method name- Returns:
- TheThe
GeneratorAdapter
for the method
-
getInternalName
- Parameters:
className
- The class name- Returns:
- The internal name
-
newClassWriterOutputVisitor
- Parameters:
compilationDir
- The compilation directory- Returns:
- The directory class writer output visitor
-
visitStaticInitializer
protected org.objectweb.asm.commons.GeneratorAdapter visitStaticInitializer(org.objectweb.asm.ClassVisitor classWriter) - Parameters:
classWriter
- The current class writer- Returns:
- The
GeneratorAdapter
-
startPublicMethod
protected org.objectweb.asm.commons.GeneratorAdapter startPublicMethod(org.objectweb.asm.ClassWriter writer, String methodName, String returnType, String... argumentTypes) - Parameters:
writer
- The class writermethodName
- The method namereturnType
- The return typeargumentTypes
- The argument types- Returns:
- The
GeneratorAdapter
-
startPublicMethod
protected org.objectweb.asm.commons.GeneratorAdapter startPublicMethod(org.objectweb.asm.ClassWriter writer, org.objectweb.asm.commons.Method asmMethod) - Parameters:
writer
- The class writerasmMethod
- The asm method- Returns:
- The
GeneratorAdapter
- Since:
- 2.3.0
-
startProtectedMethod
protected org.objectweb.asm.commons.GeneratorAdapter startProtectedMethod(org.objectweb.asm.ClassWriter writer, String methodName, String returnType, String... argumentTypes) - Parameters:
writer
- The class writermethodName
- The method namereturnType
- The return typeargumentTypes
- The argument types- Returns:
- The
GeneratorAdapter
-
pushNewInstance
protected void pushNewInstance(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type typeToInstantiate) Push the instantiation of the given type.- Parameters:
generatorAdapter
- The generator adaptortypeToInstantiate
- The type to instantiate.
-
pushStringMapOf
public static <T> void pushStringMapOf(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, Map<? extends CharSequence, T> annotationData, boolean skipEmpty, T empty, Consumer<T> pushValue) -
pushListOfString
-
toTypeString
- Parameters:
p
- The class element- Returns:
- The string representation
-