Package edu.umd.cs.findbugs.bytecode
Class MemberUtils
- java.lang.Object
-
- edu.umd.cs.findbugs.bytecode.MemberUtils
-
public final class MemberUtils extends java.lang.ObjectUtility to analyze class members.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringGENERATED_NAME_SUFFIXprivate static java.lang.StringGENERATED_TYPE_SUFFIXThis will capture annotations such asorg.immutables.value.Generatedorlombok.Generated.
-
Constructor Summary
Constructors Modifier Constructor Description privateMemberUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancouldBeLambda(XMethod m)Checks if the method could be a lambda.static booleancouldBeLambda(org.apache.bcel.classfile.Method m)Checks if the method could be a lambda.static booleancouldBeLambda(org.apache.bcel.generic.MethodGen m)Checks if the method could be a lambda.private static booleaninternalIsSynthetic(org.apache.bcel.classfile.FieldOrMethod m)private static booleaninternalIsSynthetic(org.apache.bcel.generic.FieldGenOrMethodGen m)private static booleanisGenerated(AnnotatedObject o)private static booleanisGeneratedMethod(org.apache.bcel.classfile.FieldOrMethod m)private static booleanisGeneratedMethod(org.apache.bcel.generic.FieldGenOrMethodGen m)static booleanisMainMethod(XMethod method)Checks if the given method is a main method.static booleanisMainMethod(org.apache.bcel.classfile.Method method)Checks if the given method is a main method.static booleanisUserGenerated(ClassMember m)Checks if the given method was user-generated.static booleanisUserGenerated(XClass c)Checks if the given class was user-generated, classes annotated with annotations such as Immutables' Generated are not considered user-generated.static booleanisUserGenerated(org.apache.bcel.classfile.FieldOrMethod m)Checks if the given method was user-generated.static booleanisUserGenerated(org.apache.bcel.generic.FieldGenOrMethodGen m)Checks if the given method was user-generated.
-
-
-
Field Detail
-
GENERATED_TYPE_SUFFIX
private static final java.lang.String GENERATED_TYPE_SUFFIX
This will capture annotations such asorg.immutables.value.Generatedorlombok.Generated. Note thatjavax.annotation.Generated,javax.annotation.processing.Generatedonly have source retention and are not visible to SpotBugs.- See Also:
- Constant Field Values
-
GENERATED_NAME_SUFFIX
private static final java.lang.String GENERATED_NAME_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
internalIsSynthetic
private static boolean internalIsSynthetic(org.apache.bcel.classfile.FieldOrMethod m)
-
internalIsSynthetic
private static boolean internalIsSynthetic(org.apache.bcel.generic.FieldGenOrMethodGen m)
-
isGeneratedMethod
private static boolean isGeneratedMethod(org.apache.bcel.classfile.FieldOrMethod m)
-
isGeneratedMethod
private static boolean isGeneratedMethod(org.apache.bcel.generic.FieldGenOrMethodGen m)
-
isGenerated
private static boolean isGenerated(AnnotatedObject o)
-
couldBeLambda
public static boolean couldBeLambda(org.apache.bcel.classfile.Method m)
Checks if the method could be a lambda. Notice this is a best-check, since once compiled lambda methods are not univocally distinguishable.- Parameters:
m- The method to check if it's a lambda- Returns:
- True if this could be a lambda, false otherwise
-
couldBeLambda
public static boolean couldBeLambda(XMethod m)
Checks if the method could be a lambda. Notice this is a best-check, since once compiled lambda methods are not univocally distinguishable.- Parameters:
m- The method to check if it's a lambda- Returns:
- True if this could be a lambda, false otherwise
-
couldBeLambda
public static boolean couldBeLambda(org.apache.bcel.generic.MethodGen m)
Checks if the method could be a lambda. Notice this is a best-check, since once compiled lambda methods are not univocally distinguishable.- Parameters:
m- The method to check if it's a lambda- Returns:
- True if this could be a lambda, false otherwise
-
isUserGenerated
public static boolean isUserGenerated(org.apache.bcel.classfile.FieldOrMethod m)
Checks if the given method was user-generated. This takes into account for instance lambda methods, that even though they are marked as "synthetic", they are user-generated, and therefore interesting to analysis. Methods annotated with annotations such as Lombok's Generated are not considered user-generated.- Parameters:
m- The field or method to check.- Returns:
- True if the given member is user generated, false otherwise.
-
isUserGenerated
public static boolean isUserGenerated(ClassMember m)
Checks if the given method was user-generated. This takes into account for instance lambda methods, that even though they are marked as "synthetic", they are user-generated, and therefore interesting to analysis. Methods annotated with annotations such as Lombok's Generated are not considered user-generated.- Parameters:
m- The field or method to check.- Returns:
- True if the given member is user generated, false otherwise.
-
isUserGenerated
public static boolean isUserGenerated(org.apache.bcel.generic.FieldGenOrMethodGen m)
Checks if the given method was user-generated. This takes into account for instance lambda methods, that even though they are marked as "synthetic", they are user-generated, and therefore interesting to analysis. Methods annotated with annotations such as Lombok's Generated are not considered user-generated.- Parameters:
m- The field or method to check.- Returns:
- True if the given member is user generated, false otherwise.
-
isUserGenerated
public static boolean isUserGenerated(XClass c)
Checks if the given class was user-generated, classes annotated with annotations such as Immutables' Generated are not considered user-generated.- Parameters:
c- The class to check.- Returns:
- True if the given class is user generated, false otherwise.
-
isMainMethod
public static boolean isMainMethod(org.apache.bcel.classfile.Method method)
Checks if the given method is a main method. It takes into account the changes introduced in JEP 445. A main method has non-private access, is named "main", returns void, and has a single string array argument or has no arguments.- Parameters:
method- The method to check- Returns:
- true if the method is a main method, false otherwise
- See Also:
- JEP 445: Unnamed Classes and Instance Main Methods
-
isMainMethod
public static boolean isMainMethod(XMethod method)
Checks if the given method is a main method. It takes into account the changes introduced in JEP 445. A main method has non-private access, is named "main", returns void, and has a single string array argument or has no arguments.- Parameters:
method- The method to check- Returns:
- true if the method is a main method, false otherwise
- See Also:
- JEP 445: Unnamed Classes and Instance Main Methods
-
-