Package com.strobel.reflection.emit
Class MethodBuilder
- java.lang.Object
-
- com.strobel.reflection.MemberInfo
-
- com.strobel.reflection.MethodBase
-
- com.strobel.reflection.MethodInfo
-
- com.strobel.reflection.emit.MethodBuilder
-
- All Implemented Interfaces:
java.lang.reflect.AnnotatedElement
public final class MethodBuilder extends MethodInfo
-
-
Field Summary
Fields Modifier and Type Field Description private ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>>_annotationsprivate byte[]_bodyprivate TypeBuilder<?>_declaringTypeprivate java.lang.Object_defaultValueprivate __ExceptionInstance[]_exceptionsprivate boolean_isFinishedprivate int_modifiersprivate java.lang.String_nameprivate int_numberOfExceptionsprivate SignatureType_signatureTypeprivate TypeList_thrownTypes(package private) MethodInfogeneratedMethod(package private) CodeGeneratorgenerator(package private) GenericParameterBuilder<?>[]genericParameterBuilders(package private) ParameterBuilder[]parameterBuilders-
Fields inherited from class com.strobel.reflection.MethodInfo
_erasedMethodDefinition
-
-
Constructor Summary
Constructors Constructor Description MethodBuilder(java.lang.String name, int modifiers, Type<?> returnType, TypeList parameterTypes, TypeList thrownTypes, TypeBuilder<?> declaringType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends java.lang.annotation.Annotation>
voidaddCustomAnnotation(AnnotationBuilder<A> annotation)java.lang.StringBuilderappendDescription(java.lang.StringBuilder sb)java.lang.StringBuilderappendErasedSignature(java.lang.StringBuilder sb)java.lang.StringBuilderappendSignature(java.lang.StringBuilder sb)java.lang.StringBuilderappendSimpleDescription(java.lang.StringBuilder sb)private static intcalculateNumberOfExceptions(__ExceptionInfo[] exceptions)voidcreateMethodBody(byte[] bytecode, int size)(package private) voidcreateMethodBodyHelper(CodeGenerator code)(package private) ParameterListcreateParameters()GenericParameterBuilder<?>[]defineGenericParameters(java.lang.String... names)ParameterBuilderdefineParameter(int position, java.lang.String name)<T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.Class<T> annotationClass)java.lang.annotation.Annotation[]getAnnotations()(package private) byte[]getBody()CodeGeneratorgetCodeGenerator()CodeGeneratorgetCodeGenerator(int initialSize)ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>>getCustomAnnotations()java.lang.annotation.Annotation[]getDeclaredAnnotations()TypeBuilder<?>getDeclaringType()java.lang.ObjectgetDefaultValue()java.util.List<ParameterBuilder>getDefinedParameters()MethodInfogetErasedMethodDefinition()(package private) __ExceptionInstance[]getExceptionInstances()TypeListgetGenericMethodParameters()intgetModifiers()java.lang.StringgetName()(package private) intgetNumberOfExceptions()ParameterListgetParameters()TypeListgetParameterTypes()java.lang.reflect.MethodgetRawMethod()Type<?>getReflectedType()Type<?>getReturnType()SignatureTypegetSignatureType()TypeListgetThrownTypes()booleanisAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)booleanisFinished()booleanisGenericMethod()booleanisGenericMethodDefinition()booleanisTypeCreated()(package private) voidreleaseBakedStructures()voidsetDefaultValue(java.lang.Object value)voidsetParameters(TypeList types)voidsetReturnType(Type<?> type)voidsetSignature(Type<?> returnType, TypeList parameterTypes)voidsetThrownTypes(TypeList types)(package private) voidverifyCodeGeneratorNotCreated()(package private) voidverifyNotAbstract()(package private) voidverifyNotGeneric()-
Methods inherited from class com.strobel.reflection.MethodInfo
appendBriefDescription, appendErasedDescription, appendModifiers, containsGenericParameter, containsGenericParameters, emptyMethods, findBaseMethod, findOverriddenMethod, getGenericMethodDefinition, getMemberType, getTypeArguments, getTypeBindings, invoke, isAbstract, isDefault, isEquivalentTo, makeGenericMethod, makeGenericMethod
-
Methods inherited from class com.strobel.reflection.MethodBase
getCallingConvention
-
Methods inherited from class com.strobel.reflection.MemberInfo
appendGenericSignature, emptyAnnotations, equals, getAnnotationsByType, getBriefDescription, getDeclaredAnnotation, getDeclaredAnnotationsByType, getDescription, getErasedDescription, getErasedSignature, getSignature, getSimpleDescription, hashCode, invalidateCaches, isFinal, isNonPublic, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, toString
-
-
-
-
Field Detail
-
_name
private final java.lang.String _name
-
_declaringType
private final TypeBuilder<?> _declaringType
-
_modifiers
private final int _modifiers
-
_signatureType
private SignatureType _signatureType
-
_thrownTypes
private TypeList _thrownTypes
-
_isFinished
private boolean _isFinished
-
_annotations
private ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>> _annotations
-
_body
private byte[] _body
-
_numberOfExceptions
private int _numberOfExceptions
-
_exceptions
private __ExceptionInstance[] _exceptions
-
_defaultValue
private java.lang.Object _defaultValue
-
genericParameterBuilders
GenericParameterBuilder<?>[] genericParameterBuilders
-
parameterBuilders
ParameterBuilder[] parameterBuilders
-
generator
CodeGenerator generator
-
generatedMethod
MethodInfo generatedMethod
-
-
Constructor Detail
-
MethodBuilder
MethodBuilder(java.lang.String name, int modifiers, Type<?> returnType, TypeList parameterTypes, TypeList thrownTypes, TypeBuilder<?> declaringType)
-
-
Method Detail
-
verifyNotGeneric
void verifyNotGeneric()
-
verifyNotAbstract
void verifyNotAbstract()
-
getCodeGenerator
public CodeGenerator getCodeGenerator()
-
getCodeGenerator
public CodeGenerator getCodeGenerator(int initialSize)
-
getName
public java.lang.String getName()
- Overrides:
getNamein classMethodInfo
-
getReturnType
public Type<?> getReturnType()
- Specified by:
getReturnTypein classMethodInfo
-
getSignatureType
public SignatureType getSignatureType()
- Specified by:
getSignatureTypein classMethodBase
-
getRawMethod
public java.lang.reflect.Method getRawMethod()
- Specified by:
getRawMethodin classMethodInfo
-
getDefaultValue
public java.lang.Object getDefaultValue()
- Overrides:
getDefaultValuein classMethodInfo
-
setDefaultValue
public void setDefaultValue(java.lang.Object value)
-
getDeclaringType
public TypeBuilder<?> getDeclaringType()
- Specified by:
getDeclaringTypein classMemberInfo
-
getModifiers
public int getModifiers()
- Specified by:
getModifiersin classMemberInfo
-
getParameters
public ParameterList getParameters()
- Overrides:
getParametersin classMethodBase
-
createParameters
ParameterList createParameters()
-
getThrownTypes
public TypeList getThrownTypes()
- Overrides:
getThrownTypesin classMethodBase
-
getParameterTypes
public TypeList getParameterTypes()
-
getDefinedParameters
public java.util.List<ParameterBuilder> getDefinedParameters()
-
isTypeCreated
public boolean isTypeCreated()
-
isFinished
public boolean isFinished()
-
setReturnType
public void setReturnType(Type<?> type)
-
verifyCodeGeneratorNotCreated
void verifyCodeGeneratorNotCreated()
-
setParameters
public void setParameters(TypeList types)
-
setThrownTypes
public void setThrownTypes(TypeList types)
-
getReflectedType
public Type<?> getReflectedType()
- Overrides:
getReflectedTypein classMemberInfo
-
addCustomAnnotation
public <A extends java.lang.annotation.Annotation> void addCustomAnnotation(AnnotationBuilder<A> annotation)
-
getCustomAnnotations
public ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>> getCustomAnnotations()
-
getAnnotation
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotationClass)
- Specified by:
getAnnotationin interfacejava.lang.reflect.AnnotatedElement- Overrides:
getAnnotationin classMethodInfo
-
getAnnotations
@NotNull public java.lang.annotation.Annotation[] getAnnotations()
- Specified by:
getAnnotationsin interfacejava.lang.reflect.AnnotatedElement- Overrides:
getAnnotationsin classMethodInfo
-
getDeclaredAnnotations
@NotNull public java.lang.annotation.Annotation[] getDeclaredAnnotations()
- Specified by:
getDeclaredAnnotationsin interfacejava.lang.reflect.AnnotatedElement- Overrides:
getDeclaredAnnotationsin classMethodInfo
-
isAnnotationPresent
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
- Specified by:
isAnnotationPresentin interfacejava.lang.reflect.AnnotatedElement- Overrides:
isAnnotationPresentin classMethodInfo
-
isGenericMethod
public boolean isGenericMethod()
- Overrides:
isGenericMethodin classMethodInfo
-
isGenericMethodDefinition
public boolean isGenericMethodDefinition()
- Overrides:
isGenericMethodDefinitionin classMethodInfo
-
getGenericMethodParameters
public TypeList getGenericMethodParameters()
- Overrides:
getGenericMethodParametersin classMethodInfo
-
getErasedMethodDefinition
public MethodInfo getErasedMethodDefinition()
- Overrides:
getErasedMethodDefinitionin classMethodInfo
-
appendDescription
public java.lang.StringBuilder appendDescription(java.lang.StringBuilder sb)
- Overrides:
appendDescriptionin classMethodInfo
-
appendSimpleDescription
public java.lang.StringBuilder appendSimpleDescription(java.lang.StringBuilder sb)
- Overrides:
appendSimpleDescriptionin classMethodInfo
-
appendErasedSignature
public java.lang.StringBuilder appendErasedSignature(java.lang.StringBuilder sb)
- Overrides:
appendErasedSignaturein classMethodInfo
-
appendSignature
public java.lang.StringBuilder appendSignature(java.lang.StringBuilder sb)
- Overrides:
appendSignaturein classMethodInfo
-
defineGenericParameters
public GenericParameterBuilder<?>[] defineGenericParameters(java.lang.String... names)
-
defineParameter
public ParameterBuilder defineParameter(int position, java.lang.String name)
-
createMethodBody
public void createMethodBody(byte[] bytecode, int size)
-
getBody
byte[] getBody()
-
getExceptionInstances
__ExceptionInstance[] getExceptionInstances()
-
getNumberOfExceptions
int getNumberOfExceptions()
-
createMethodBodyHelper
void createMethodBodyHelper(CodeGenerator code)
-
calculateNumberOfExceptions
private static int calculateNumberOfExceptions(__ExceptionInfo[] exceptions)
-
releaseBakedStructures
void releaseBakedStructures()
-
-