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,BeanDefinitionWriter,DispatchWriter,ExecutableMethodsDefinitionWriter
@Internal public abstract class AbstractClassFileWriter extends java.lang.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
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.regex.PatternARRAY_PATTERNprotected static java.lang.StringCONSTRUCTOR_NAMEprotected static intDEFAULT_MAX_STACKprotected static java.lang.StringDESCRIPTOR_DEFAULT_CONSTRUCTORprotected static org.objectweb.asm.commons.MethodMETHOD_CREATE_ARGUMENT_SIMPLEprotected static org.objectweb.asm.commons.MethodMETHOD_CREATE_TYPE_VARIABLE_SIMPLEprotected static org.objectweb.asm.commons.MethodMETHOD_DEFAULT_CONSTRUCTORprotected static org.objectweb.asm.commons.MethodMETHOD_GENERIC_PLACEHOLDER_SIMPLEprotected OriginatingElementsoriginatingElementsprotected static org.objectweb.asm.TypeTYPE_ARGUMENTprotected static org.objectweb.asm.TypeTYPE_ARGUMENT_ARRAYprotected static org.objectweb.asm.TypeTYPE_CLASSprotected static org.objectweb.asm.TypeTYPE_GENERATEDprotected static org.objectweb.asm.TypeTYPE_OBJECTprotected static java.lang.StringZERO_ARGUMENTS_CONSTANT-
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, V9
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClassFileWriter(Element originatingElement)Deprecated.UseAbstractClassFileWriter(Element...)insteadprotectedAbstractClassFileWriter(Element... originatingElements)protectedAbstractClassFileWriter(OriginatingElements originatingElements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOriginatingElement(Element element)Add another element that should be included in the originating elements.protected static voidbuildArgument(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String argumentName, ClassElement objectType)Builds an argument instance.protected static voidbuildArgument(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String argumentName, org.objectweb.asm.Type objectType)Builds an argument instance.protected static voidbuildArgumentWithGenerics(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type type, AnnotationMetadataReference annotationMetadata, ClassElement[] generics)Builds generic type arguments recursively.protected static voidbuildArgumentWithGenerics(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String argumentName, org.objectweb.asm.Type typeReference, ClassElement classElement, java.util.Map<java.lang.String,ClassElement> typeArguments, java.util.Set<java.lang.String> visitedTypes, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Builds generic type arguments recursively.protected voidgenerateServiceDescriptor(java.lang.String className, GeneratedFile generatedFile)Generates a service discovery for the given class name and file.protected java.lang.StringgetClassFileName(java.lang.String className)protected static java.lang.StringgetConstructorDescriptor(java.lang.Class<?>... argumentTypes)protected static java.lang.StringgetConstructorDescriptor(java.util.Collection<ParameterElement> argList)protected static java.lang.StringgetConstructorDescriptor(org.objectweb.asm.Type[] argumentTypes)protected static java.lang.StringgetInternalName(java.lang.String className)protected static java.lang.StringgetInternalNameForCast(TypedElement type)protected static java.lang.StringgetInternalNameForCast(java.lang.Class<?> typeClass)protected static java.lang.StringgetInternalNameForCast(org.objectweb.asm.Type type)protected static java.lang.StringgetMethodDescriptor(TypedElement returnType, java.util.Collection<? extends TypedElement> argumentTypes)protected static java.lang.StringgetMethodDescriptor(java.lang.Class<?> returnType, java.util.Collection<java.lang.Class<?>> argumentTypes)protected static java.lang.StringgetMethodDescriptor(java.lang.String returnType, java.lang.String... argumentTypes)protected static java.lang.StringgetMethodDescriptor(org.objectweb.asm.Type returnType, java.util.Collection<org.objectweb.asm.Type> argumentTypes)protected static java.lang.StringgetMethodDescriptorForReturnType(org.objectweb.asm.Type returnType, java.util.Collection<? extends TypedElement> argumentTypes)protected static java.lang.StringgetMethodSignature(java.lang.String returnTypeReference, java.lang.String... argReferenceTypes)protected static org.objectweb.asm.TypegetObjectType(java.lang.Object type)ElementgetOriginatingElement()Element[]getOriginatingElements()protected static java.lang.StringgetTypeDescriptor(TypedElement type)Returns the descriptor corresponding to the given class.protected static java.lang.StringgetTypeDescriptor(java.lang.Class<?> type)Returns the descriptor corresponding to the given class.protected static java.lang.StringgetTypeDescriptor(java.lang.String type)Returns the descriptor corresponding to the given class.protected static java.lang.StringgetTypeDescriptor(java.lang.String className, java.lang.String... genericTypes)protected static org.objectweb.asm.TypegetTypeReference(TypedElement type)Return the type reference for a class.protected static org.objectweb.asm.TypegetTypeReferenceForName(java.lang.String className, java.lang.String... genericTypes)Returns the Type reference corresponding to the given class.protected org.objectweb.asm.Type[]getTypes(java.util.Collection<ClassElement> types)protected voidimplementInterceptedTypeMethod(org.objectweb.asm.Type interceptedType, org.objectweb.asm.ClassWriter classWriter)Implements a method called "getInterceptedType" for the given type and class writer.protected voidinvokeConstructor(org.objectweb.asm.MethodVisitor cv, java.lang.Class superClass, java.lang.Class... argumentTypes)protected static voidinvokeInterfaceStaticMethod(org.objectweb.asm.MethodVisitor visitor, java.lang.Class targetType, org.objectweb.asm.commons.Method method)protected ClassElementinvokeMethod(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, MethodElement method)Invokes the given method.protected ClassWriterOutputVisitornewClassWriterOutputVisitor(java.io.File compilationDir)protected static voidpushBoxPrimitiveIfNecessary(TypedElement fieldType, org.objectweb.asm.MethodVisitor injectMethodVisitor)protected static voidpushBoxPrimitiveIfNecessary(java.lang.Class<?> fieldType, org.objectweb.asm.MethodVisitor injectMethodVisitor)protected static voidpushBoxPrimitiveIfNecessary(org.objectweb.asm.Type fieldType, org.objectweb.asm.MethodVisitor injectMethodVisitor)protected static voidpushBuildArgumentsForMethod(java.lang.String declaringElementName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.util.Collection<ParameterElement> argumentTypes, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)protected static voidpushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, TypedElement type)protected static voidpushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> type)protected static voidpushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, org.objectweb.asm.Type type)protected static voidpushCreateArgument(java.lang.String declaringTypeName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String argumentName, TypedElement typedElement, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.util.Map<java.lang.String,ClassElement> typeArguments, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Pushes a new Argument creation.protected static voidpushMethodNameAndTypesArguments(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, java.lang.String methodName, java.util.Collection<ClassElement> argumentTypes)protected static voidpushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, java.lang.Class<?> arrayType, int size)protected static voidpushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type arrayType, int size)protected voidpushNewInstance(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, org.objectweb.asm.Type typeToInstantiate)Push the instantiation of the given type.protected voidpushReturnTypeArgument(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String declaringTypeName, ClassElement argument, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Pushes an argument.protected static voidpushReturnValue(org.objectweb.asm.MethodVisitor methodVisitor, TypedElement type)protected static voidpushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, java.lang.Runnable runnable)protected static voidpushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, org.objectweb.asm.Type type, int index, int size, java.lang.Runnable runnable)protected static voidpushStoreStringInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, java.lang.String string)protected static voidpushStoreTypeInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, ClassElement type)static <T> voidpushStringMapOf(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.util.Map<? extends java.lang.CharSequence,T> annotationData, boolean skipEmpty, T empty, java.util.function.Consumer<T> pushValue)protected static voidpushTypeArgumentElements(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningTypeWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String declaringElementName, java.util.Map<java.lang.String,ClassElement> types, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Pushes type arguments onto the stack.protected voidreturnVoid(org.objectweb.asm.commons.GeneratorAdapter overriddenMethodGenerator)protected voidstartClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.String className, org.objectweb.asm.Type superType)protected voidstartClass(org.objectweb.asm.ClassWriter classWriter, java.lang.String className, org.objectweb.asm.Type superType, java.lang.String genericSignature)protected org.objectweb.asm.commons.GeneratorAdapterstartConstructor(org.objectweb.asm.ClassVisitor classWriter)protected org.objectweb.asm.commons.GeneratorAdapterstartConstructor(org.objectweb.asm.ClassVisitor classWriter, java.lang.Class<?>... argumentTypes)protected voidstartFinalClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.String className, org.objectweb.asm.Type superType)protected org.objectweb.asm.commons.GeneratorAdapterstartProtectedMethod(org.objectweb.asm.ClassWriter writer, java.lang.String methodName, java.lang.String returnType, java.lang.String... argumentTypes)protected voidstartPublicClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.String className, org.objectweb.asm.Type superType)protected voidstartPublicFinalClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.String className, org.objectweb.asm.Type superType)Starts a public final class.protected org.objectweb.asm.commons.GeneratorAdapterstartPublicFinalMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter, java.lang.Class returnType, java.lang.String methodName)protected org.objectweb.asm.commons.GeneratorAdapterstartPublicMethod(org.objectweb.asm.ClassWriter writer, java.lang.String methodName, java.lang.String returnType, java.lang.String... argumentTypes)protected org.objectweb.asm.commons.GeneratorAdapterstartPublicMethod(org.objectweb.asm.ClassWriter writer, org.objectweb.asm.commons.Method asmMethod)protected org.objectweb.asm.commons.GeneratorAdapterstartPublicMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter, java.lang.Class returnType, java.lang.String methodName)protected voidstartService(org.objectweb.asm.ClassVisitor classWriter, java.lang.Class<?> serviceType, java.lang.String internalClassName, org.objectweb.asm.Type superType)protected voidstartService(org.objectweb.asm.ClassVisitor classWriter, java.lang.String serviceName, java.lang.String internalClassName, org.objectweb.asm.Type superType, java.lang.String... interfaces)protected org.objectweb.asm.commons.GeneratorAdaptervisitStaticInitializer(org.objectweb.asm.ClassVisitor classWriter)protected voidwriteBooleanMethod(org.objectweb.asm.ClassWriter classWriter, java.lang.String methodName, java.util.function.Supplier<java.lang.Boolean> valueSupplier)Writes a method that returns a boolean value with the value supplied by the given supplier.protected voidwriteClassToDisk(java.io.File targetDir, org.objectweb.asm.ClassWriter classWriter, java.lang.String className)Writes the class file to disk in the given directory.protected voidwriteClassToDisk(java.io.OutputStream out, org.objectweb.asm.ClassWriter classWriter)voidwriteTo(java.io.File targetDir)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 Detail
-
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
protected static final java.lang.String ZERO_ARGUMENTS_CONSTANT
- See Also:
- Constant Field Values
-
CONSTRUCTOR_NAME
protected static final java.lang.String CONSTRUCTOR_NAME
- See Also:
- Constant Field Values
-
DESCRIPTOR_DEFAULT_CONSTRUCTOR
protected static final java.lang.String DESCRIPTOR_DEFAULT_CONSTRUCTOR
- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
TYPE_GENERATED
protected static final org.objectweb.asm.Type TYPE_GENERATED
-
ARRAY_PATTERN
protected static final java.util.regex.Pattern 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
protected final OriginatingElements originatingElements
-
-
Constructor Detail
-
AbstractClassFileWriter
@Deprecated protected AbstractClassFileWriter(Element originatingElement)
Deprecated.UseAbstractClassFileWriter(Element...)instead- Parameters:
originatingElement- The originating element
-
AbstractClassFileWriter
protected AbstractClassFileWriter(Element... originatingElements)
- Parameters:
originatingElements- The originating elements
-
AbstractClassFileWriter
protected AbstractClassFileWriter(OriginatingElements originatingElements)
- Parameters:
originatingElements- The originating elements
-
-
Method Detail
-
getOriginatingElements
@NonNull public Element[] getOriginatingElements()
- Specified by:
getOriginatingElementsin interfaceOriginatingElements- Returns:
- The elements where the bean definition originated from as an array.
-
addOriginatingElement
public void addOriginatingElement(@NonNull Element element)Description copied from interface:OriginatingElementsAdd another element that should be included in the originating elements.- Specified by:
addOriginatingElementin interfaceOriginatingElements- Parameters:
element- The element to add
-
pushTypeArgumentElements
protected static void pushTypeArgumentElements(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningTypeWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String declaringElementName, java.util.Map<java.lang.String,ClassElement> types, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Pushes type arguments onto the stack.- Parameters:
owningType- 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, java.lang.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, java.lang.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(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter owningClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String argumentName, org.objectweb.asm.Type typeReference, ClassElement classElement, java.util.Map<java.lang.String,ClassElement> typeArguments, java.util.Set<java.lang.String> visitedTypes, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Builds generic type arguments recursively.- Parameters:
owningType- 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(java.lang.String declaringElementName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.util.Collection<ParameterElement> argumentTypes, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)- Parameters:
declaringElementName- The declaring element nameowningType- The owning typedeclaringClassWriter- The declaring class writergeneratorAdapter- TheGeneratorAdapterargumentTypes- The argument typesdefaults- The annotation defaultsloadTypeMethods- The load type methods
-
pushReturnTypeArgument
protected void pushReturnTypeArgument(org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter classWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String declaringTypeName, ClassElement argument, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Pushes an argument.- Parameters:
owningType- 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(java.lang.String declaringTypeName, org.objectweb.asm.Type owningType, org.objectweb.asm.ClassWriter declaringClassWriter, org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.lang.String argumentName, TypedElement typedElement, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.util.Map<java.lang.String,ClassElement> typeArguments, java.util.Map<java.lang.String,java.lang.Integer> defaults, java.util.Map<java.lang.String,org.objectweb.asm.commons.GeneratorAdapter> loadTypeMethods)Pushes a new Argument creation.- Parameters:
declaringTypeName- 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
public void writeTo(java.io.File targetDir) throws java.io.IOExceptionWrite the class to the target directory.- Parameters:
targetDir- The target directory- Throws:
java.io.IOException- if there is an error writing the file
-
writeBooleanMethod
protected void writeBooleanMethod(org.objectweb.asm.ClassWriter classWriter, java.lang.String methodName, java.util.function.Supplier<java.lang.Boolean> valueSupplier)Writes a method that returns a boolean value with the value supplied by the given supplier.- Parameters:
classWriter- The class writermethodName- The method namevalueSupplier- The supplier
-
getOriginatingElement
@Nullable public Element 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
protected static java.lang.String getTypeDescriptor(TypedElement type)
Returns the descriptor corresponding to the given class.- Parameters:
type- The type- Returns:
- The descriptor for the class
-
getTypeDescriptor
protected static java.lang.String getTypeDescriptor(java.lang.Class<?> type)
Returns the descriptor corresponding to the given class.- Parameters:
type- The type- Returns:
- The descriptor for the class
-
getTypeDescriptor
protected static java.lang.String getTypeDescriptor(java.lang.String type)
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(java.lang.String className, java.lang.String... genericTypes)Returns the Type reference corresponding to the given class.- Parameters:
className- The class namegenericTypes- The generic types- Returns:
- The
Type
-
getTypeReference
protected static org.objectweb.asm.Type getTypeReference(TypedElement type)
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.MethodVisitor injectMethodVisitor)- Parameters:
fieldType- The field typeinjectMethodVisitor- TheMethodVisitor
-
pushBoxPrimitiveIfNecessary
protected static void pushBoxPrimitiveIfNecessary(java.lang.Class<?> fieldType, org.objectweb.asm.MethodVisitor injectMethodVisitor)- Parameters:
fieldType- The field typeinjectMethodVisitor- TheMethodVisitor
-
pushBoxPrimitiveIfNecessary
protected static void pushBoxPrimitiveIfNecessary(TypedElement fieldType, org.objectweb.asm.MethodVisitor injectMethodVisitor)
- Parameters:
fieldType- The field typeinjectMethodVisitor- TheMethodVisitor
-
pushCastToType
protected static void pushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, org.objectweb.asm.Type type)- Parameters:
methodVisitor- TheMethodVisitortype- The type
-
pushCastToType
protected static void pushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, TypedElement type)- Parameters:
methodVisitor- TheMethodVisitortype- The type
-
pushCastToType
protected static void pushCastToType(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> type)- Parameters:
methodVisitor- TheMethodVisitortype- The type
-
pushReturnValue
protected static void pushReturnValue(org.objectweb.asm.MethodVisitor methodVisitor, TypedElement type)- Parameters:
methodVisitor- TheMethodVisitortype- The type
-
pushMethodNameAndTypesArguments
protected static void pushMethodNameAndTypesArguments(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, java.lang.String methodName, java.util.Collection<ClassElement> argumentTypes)- Parameters:
methodVisitor- The method visitor asGeneratorAdaptermethodName- The method nameargumentTypes- The argument types
-
pushNewArray
protected static void pushNewArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, java.lang.Class<?> arrayType, int size)- Parameters:
methodVisitor- The method visitor asGeneratorAdapterarrayType- 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 asGeneratorAdapterarrayType- The array classsize- The size
-
pushStoreStringInArray
protected static void pushStoreStringInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, java.lang.String string)- Parameters:
methodVisitor- The method visitor asGeneratorAdapterindex- The indexsize- The sizestring- The string
-
pushStoreInArray
protected static void pushStoreInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, java.lang.Runnable runnable)- Parameters:
methodVisitor- The method visitor asGeneratorAdapterindex- 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, java.lang.Runnable runnable)- Parameters:
methodVisitor- The method visitor asGeneratorAdaptertype- The type of the arrayindex- The indexsize- The sizerunnable- The runnable
-
pushStoreTypeInArray
protected static void pushStoreTypeInArray(org.objectweb.asm.commons.GeneratorAdapter methodVisitor, int index, int size, ClassElement type)- Parameters:
methodVisitor- The method visitor asGeneratorAdapterindex- The indexsize- The sizetype- The type
-
getTypes
protected org.objectweb.asm.Type[] getTypes(java.util.Collection<ClassElement> types)
- Parameters:
types- The types- Returns:
- An array with the
Typeof the objects
-
getObjectType
protected static org.objectweb.asm.Type getObjectType(java.lang.Object type)
- Parameters:
type- The type- Returns:
- The
Typefor the object type
-
getTypeDescriptor
protected static java.lang.String getTypeDescriptor(java.lang.String className, java.lang.String... genericTypes)- Parameters:
className- The class namegenericTypes- The generic types- Returns:
- The type descriptor as String
-
getMethodDescriptor
protected static java.lang.String getMethodDescriptor(java.lang.String returnType, java.lang.String... argumentTypes)- Parameters:
returnType- The return typeargumentTypes- The argument types- Returns:
- The method descriptor
-
getMethodDescriptor
protected static java.lang.String getMethodDescriptor(TypedElement returnType, java.util.Collection<? extends TypedElement> argumentTypes)
- Parameters:
returnType- The return typeargumentTypes- The argument types- Returns:
- The method descriptor
-
getMethodDescriptorForReturnType
protected static java.lang.String getMethodDescriptorForReturnType(org.objectweb.asm.Type returnType, java.util.Collection<? extends TypedElement> argumentTypes)- Parameters:
returnType- The return typeargumentTypes- The argument types- Returns:
- The method descriptor
-
getMethodDescriptor
protected static java.lang.String getMethodDescriptor(java.lang.Class<?> returnType, java.util.Collection<java.lang.Class<?>> argumentTypes)- Parameters:
returnType- The return typeargumentTypes- The argument types- Returns:
- The method descriptor
-
getMethodDescriptor
protected static java.lang.String getMethodDescriptor(org.objectweb.asm.Type returnType, java.util.Collection<org.objectweb.asm.Type> argumentTypes)- Parameters:
returnType- The return typeargumentTypes- The argument types- Returns:
- The method descriptor
-
getMethodSignature
protected static java.lang.String getMethodSignature(java.lang.String returnTypeReference, java.lang.String... argReferenceTypes)- Parameters:
returnTypeReference- The return type referenceargReferenceTypes- The argument reference types- Returns:
- The method signature
-
getConstructorDescriptor
protected static java.lang.String getConstructorDescriptor(java.lang.Class<?>... argumentTypes)
- Parameters:
argumentTypes- The argument types- Returns:
- The constructor descriptor
-
getConstructorDescriptor
protected static java.lang.String getConstructorDescriptor(org.objectweb.asm.Type[] argumentTypes)
- Parameters:
argumentTypes- The argument types- Returns:
- The constructor descriptor
-
getConstructorDescriptor
protected static java.lang.String getConstructorDescriptor(java.util.Collection<ParameterElement> argList)
- Parameters:
argList- The argument list- Returns:
- The constructor descriptor
-
writeClassToDisk
protected void writeClassToDisk(java.io.File targetDir, org.objectweb.asm.ClassWriter classWriter, java.lang.String className) throws java.io.IOExceptionWrites the class file to disk in the given directory.- Parameters:
targetDir- The target directoryclassWriter- The current class writerclassName- The class name- Throws:
java.io.IOException- if there is a problem writing the class to disk
-
writeClassToDisk
protected void writeClassToDisk(java.io.OutputStream out, org.objectweb.asm.ClassWriter classWriter) throws java.io.IOException- Parameters:
out- The output streamclassWriter- The current class writer- Throws:
java.io.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
GeneratorAdapterfor the constructor
-
startConstructor
protected org.objectweb.asm.commons.GeneratorAdapter startConstructor(org.objectweb.asm.ClassVisitor classWriter, java.lang.Class<?>... argumentTypes)- Parameters:
classWriter- The current class writerargumentTypes- The argument types- Returns:
- The
GeneratorAdapterfor the constructor
-
startClass
protected void startClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.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, java.lang.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, java.lang.Class<?> serviceType, java.lang.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, java.lang.String serviceName, java.lang.String internalClassName, org.objectweb.asm.Type superType, java.lang.String... interfaces)- Parameters:
classWriter- The current class writerserviceName- The service nameinternalClassName- The class namesuperType- The super typeinterfaces- The interfaces
-
startFinalClass
protected void startFinalClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.String className, org.objectweb.asm.Type superType)- Parameters:
classWriter- The current class writerclassName- The class namesuperType- The super type
-
startPublicFinalClass
protected void startPublicFinalClass(org.objectweb.asm.ClassVisitor classWriter, java.lang.String className, org.objectweb.asm.Type superType)Starts a public final class.- Parameters:
classWriter- The current class writerclassName- The class namesuperType- The super type
-
startClass
protected void startClass(org.objectweb.asm.ClassWriter classWriter, java.lang.String className, org.objectweb.asm.Type superType, java.lang.String genericSignature)- Parameters:
classWriter- The current class writerclassName- The class namesuperType- The super typegenericSignature- The generic signature
-
invokeConstructor
protected void invokeConstructor(org.objectweb.asm.MethodVisitor cv, java.lang.Class superClass, java.lang.Class... argumentTypes)- Parameters:
cv- The constructor visitorsuperClass- The super classargumentTypes- The argument types
-
invokeInterfaceStaticMethod
protected static void invokeInterfaceStaticMethod(org.objectweb.asm.MethodVisitor visitor, java.lang.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, java.lang.Class returnType, java.lang.String methodName)- Parameters:
classWriter- The current class writerreturnType- The return typemethodName- The method name- Returns:
- TheThe
GeneratorAdapterfor the method
-
startPublicFinalMethodZeroArgs
protected org.objectweb.asm.commons.GeneratorAdapter startPublicFinalMethodZeroArgs(org.objectweb.asm.ClassWriter classWriter, java.lang.Class returnType, java.lang.String methodName)- Parameters:
classWriter- The current class writerreturnType- The return typemethodName- The method name- Returns:
- TheThe
GeneratorAdapterfor the method
-
getInternalName
protected static java.lang.String getInternalName(java.lang.String className)
- Parameters:
className- The class name- Returns:
- The internal name
-
getInternalNameForCast
protected static java.lang.String getInternalNameForCast(TypedElement type)
- Parameters:
type- The type- Returns:
- the internal name for cast
-
getInternalNameForCast
protected static java.lang.String getInternalNameForCast(java.lang.Class<?> typeClass)
- Parameters:
typeClass- The type- Returns:
- the internal name for cast
-
getInternalNameForCast
protected static java.lang.String getInternalNameForCast(org.objectweb.asm.Type type)
- Parameters:
type- The type- Returns:
- the internal name for cast
-
getClassFileName
protected java.lang.String getClassFileName(java.lang.String className)
- Parameters:
className- The class name- Returns:
- The class file name
-
newClassWriterOutputVisitor
protected ClassWriterOutputVisitor newClassWriterOutputVisitor(java.io.File compilationDir)
- Parameters:
compilationDir- The compilation directory- Returns:
- The directory class writer output visitor
-
returnVoid
protected void returnVoid(org.objectweb.asm.commons.GeneratorAdapter overriddenMethodGenerator)
- Parameters:
overriddenMethodGenerator- The overridden method generator
-
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, java.lang.String methodName, java.lang.String returnType, java.lang.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, java.lang.String methodName, java.lang.String returnType, java.lang.String... argumentTypes)- Parameters:
writer- The class writermethodName- The method namereturnType- The return typeargumentTypes- The argument types- Returns:
- The
GeneratorAdapter
-
generateServiceDescriptor
protected void generateServiceDescriptor(java.lang.String className, GeneratedFile generatedFile) throws java.io.IOExceptionGenerates a service discovery for the given class name and file.- Parameters:
className- The class namegeneratedFile- The generated file- Throws:
java.io.IOException- An exception if an error occurs
-
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.
-
invokeMethod
@NonNull protected ClassElement invokeMethod(@NonNull org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, @NonNull MethodElement method)
Invokes the given method.- Parameters:
generatorAdapter- The generator adaptermethod- The method to invoke- Returns:
- The return type
-
pushStringMapOf
public static <T> void pushStringMapOf(org.objectweb.asm.commons.GeneratorAdapter generatorAdapter, java.util.Map<? extends java.lang.CharSequence,T> annotationData, boolean skipEmpty, T empty, java.util.function.Consumer<T> pushValue)
-
-