Interface IJavaMethod
- All Superinterfaces:
IJavaDecompilableElement,IJavaElement
Java AST interface to represent a Java method.
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
FLAG_BUILT, FLAG_CLUTTER, FLAG_FIELD_REFERENCES_OUTERCLASS, FLAG_LAMBDA_CLASS, FLAG_LAMBDA_IMPL, FLAG_OPTIONAL_RENDERING, FLAG_SECOND_PARAMETER_IS_OUTER_REF, FLAG_STICKY -
Method Summary
Modifier and TypeMethodDescriptionbooleanDelete a statement by reference.Duplicate this element.voidfromFlatList(List<IJavaStatement> list) Replace the method body from a flat statement list.voidgenerate(JavaOutputSink out, boolean bodyOnly) Generate this method.voidgenerate(JavaOutputSink out, int genkind) Generate this method.intRetrieve the method access flags.Retrieve anonymous classes declared by this method.Retrieve the signatures of anonymous classes declared by this method.getBody()Get the body of the method.Get the type of the entity containing this method.Get the default value provided by this method if there is one.Retrieve the identifier manager associated with this method.intRetrieve the index of the first visible parameter.Retrieve inner classes declared by this method.Retrieve the signatures of inner classes declared by this method.Retrieve the label factory associated with this method.Retrieve method annotations.getName()Get the original method name.getParameter(int index) Retrieve a method parameter by index.getParameterAnnotations(int index) Retrieve annotations for a parameter.intRetrieve the total number of parameters, including hidden parameters.Get the parameters of the method.Get the return type of the method.Get the original method signature.Walk the tree and get the ordered list of all (non-pseudo) statements that make up the method.intRetrieve the number of visible parameters.Retrieve the visible parameters.booleanDetermine whether this method is abstract.booleanDetermine whether this method is a class constructor.booleanDetermine whether this method is a class initializer.booleanDetermine whether this method is an instance constructor.booleanisEmpty()Determine whether the method body is empty.booleanisInner()Determine whether this method belongs to an inner type.booleanisNative()Determine whether this method is native.booleanDetermine whether this method is private.booleanDetermine whether this method is protected.booleanisPublic()Determine whether this method is public.booleanDetermine whether the second parameter is an outer-class reference.booleanisStatic()Determine whether this method is a static method.booleanDetermine whether this method is synthetic.voidMark the second parameter as an outer-class reference.voidsetDefaultValue(IJavaExpression defaultValue) Set the default value associated with this method.voidsetIndexOfFirstVisibleParameter(int index) Set the index of the first visible parameter.Flatten the method body into a statement list.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaDecompilableElement
getGlobalContext, isBuilt, isExternal, isOptionalRendering, markBuilt, markNotBuilt, markOptionalRenderingMethods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
addFlags, addTag, canCauseException, collectAllPhysicalOffsets, generate, getData, getElementType, getFlags, getOrigin, getPhysicalMethodIndex, getPhysicalOffset, getReconAnon, getReconEnum, getReconEnummap, getReconLambda, getSubElements, getTags, hasFlags, hasPhysicalMethodIndex, hasPhysicalOffset, isReconArtifact, removeFlags, removeTag, replaceSubElement, setData, setFlags, setLambdaRecon, setOrigin, setPhysicalMethodIndex, setPhysicalOffset, setReconAnon, setReconEnum, setReconEnummap, toShortString, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPre, visitDepthPre, visitDepthPre
-
Method Details
-
getLabelFactory
IJavaLabelFactory getLabelFactory()Retrieve the label factory associated with this method.- Returns:
- the label factory
-
getIdentifierManager
IJavaIdentifierManager getIdentifierManager()Retrieve the identifier manager associated with this method.- Returns:
- the identifier manager
-
getName
String getName()Get the original method name. The returned name is a simple name, without parameter, return, or type information.- Specified by:
getNamein interfaceIJavaDecompilableElement- Returns:
- the method name
-
getSignature
String getSignature()Get the original method signature.- Specified by:
getSignaturein interfaceIJavaDecompilableElement- Returns:
- the method signature
-
getParameter
Retrieve a method parameter by index.- Parameters:
index- parameter index- Returns:
- the parameter definition
-
getParameterCount
int getParameterCount()Retrieve the total number of parameters, including hidden parameters.- Returns:
- parameter count
-
setIndexOfFirstVisibleParameter
void setIndexOfFirstVisibleParameter(int index) Set the index of the first visible parameter.- Parameters:
index- parameter index
-
getIndexOfFirstVisibleParameter
int getIndexOfFirstVisibleParameter()Retrieve the index of the first visible parameter.- Returns:
- first visible parameter index
-
getVisibleParameterCount
int getVisibleParameterCount()Retrieve the number of visible parameters.- Returns:
- visible parameter count
-
getVisibleParameters
List<IJavaDefinition> getVisibleParameters()Retrieve the visible parameters.- Returns:
- list of visible parameter definitions
-
getParameters
List<IJavaDefinition> getParameters()Get the parameters of the method.Note: If the method is non-static, the first parameter in the list would be `this`.
- Returns:
- the list of parameters
-
markSecondParameterOuterClassReference
void markSecondParameterOuterClassReference()Mark the second parameter as an outer-class reference. -
isSecondParameterOuterClassReference
boolean isSecondParameterOuterClassReference()Determine whether the second parameter is an outer-class reference.- Returns:
- true if the second parameter is an outer-class reference
-
getReturnType
IJavaType getReturnType()Get the return type of the method.- Returns:
- the return type
-
getBody
IJavaBlock getBody()Get the body of the method.- Returns:
- the body, null if none
-
isEmpty
boolean isEmpty()Determine whether the method body is empty.- Returns:
- true if the method has no statements
-
isConstructor
boolean isConstructor()Determine whether this method is an instance constructor.- Returns:
- true if this method is a constructor
-
isClassConstructor
boolean isClassConstructor()Determine whether this method is a class constructor.- Returns:
- true if this method is a class constructor
-
isClassInitializer
boolean isClassInitializer()Determine whether this method is a class initializer.- Returns:
- true if this method is a class initializer
-
getAccessFlags
int getAccessFlags()Retrieve the method access flags.- Returns:
- access flags
-
isStatic
boolean isStatic()Determine whether this method is a static method.- Returns:
- true if the method is static, false otherwise (virtual method)
-
isSynthetic
boolean isSynthetic()Determine whether this method is synthetic.- Returns:
- true if the method is synthetic
-
isAbstract
boolean isAbstract()Determine whether this method is abstract.- Returns:
- true if the method is abstract
-
isNative
boolean isNative()Determine whether this method is native.- Returns:
- true if the method is native
-
isPublic
boolean isPublic()Determine whether this method is public.- Returns:
- true if the method is public
-
isProtected
boolean isProtected()Determine whether this method is protected.- Returns:
- true if the method is protected
-
isPrivate
boolean isPrivate()Determine whether this method is private.- Returns:
- true if the method is private
-
isInner
boolean isInner()Determine whether this method belongs to an inner type.- Returns:
- true if the method belongs to an inner type
-
getClassType
IJavaType getClassType()Get the type of the entity containing this method.- Returns:
- the containing class type
-
getInnerClassSignatures
Retrieve the signatures of inner classes declared by this method.- Returns:
- inner class signatures
-
getInnerClasses
List<IJavaClass> getInnerClasses()Retrieve inner classes declared by this method.- Returns:
- inner classes
-
getAnonymousClassSignatures
Retrieve the signatures of anonymous classes declared by this method.- Returns:
- anonymous class signatures
-
getAnonymousClasses
List<IJavaClass> getAnonymousClasses()Retrieve anonymous classes declared by this method.- Returns:
- anonymous classes
-
getMethodAnnotations
List<IJavaAnnotation> getMethodAnnotations()Retrieve method annotations.- Returns:
- method annotations
-
getParameterAnnotations
Retrieve annotations for a parameter.- Parameters:
index- parameter index- Returns:
- parameter annotations
-
setDefaultValue
Set the default value associated with this method.- Parameters:
defaultValue- default value, or null
-
getDefaultValue
IJavaExpression getDefaultValue()Get the default value provided by this method if there is one.Implementation note: currently used for annotation types only: if this object is an annotation method (i.e. it represents an attribute of an annotation type), this method will return the default value associated to this attribute, if there is one.
- Returns:
- a default value or null
-
getStatements
List<IJavaStatement> getStatements()Walk the tree and get the ordered list of all (non-pseudo) statements that make up the method.- Returns:
- ordered method statements
-
deleteStatement
Delete a statement by reference. This method performs a deep search within the entire method. This works because no method should contain the same statement (in the sense, same reference) twice.- Parameters:
stm- the statement to delete- Returns:
- true if the statement was found and deleted
-
generate
Generate this method.- Parameters:
out- output sinkbodyOnly- true to generate only the method body
-
generate
Generate this method.- Parameters:
out- output sinkgenkind- 0= regular method; 1= just the body of the method; 2= the method is a lambda
-
toFlatList
List<IJavaStatement> toFlatList()Flatten the method body into a statement list.- Returns:
- flattened statements
-
fromFlatList
Replace the method body from a flat statement list.- Parameters:
list- statements to use as the method body
-
duplicate
IJavaMethod duplicate()Description copied from interface:IJavaElementDuplicate this element.- Specified by:
duplicatein interfaceIJavaDecompilableElement- Specified by:
duplicatein interfaceIJavaElement- Returns:
- a (possibly) duplicated object of the same type
-