Package com.mebigfatguy.fbcontrib.detect
Class PossibleIncompleteSerialization
java.lang.Object
com.mebigfatguy.fbcontrib.detect.PossibleIncompleteSerialization
- All Implemented Interfaces:
edu.umd.cs.findbugs.Detector,edu.umd.cs.findbugs.Priorities
looks for classes that don't handle serialization of parent class member
fields when the class in question is serializable but is derived from non
serializable classes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final edu.umd.cs.findbugs.BugReporterstatic final Stringstatic final StringFields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionPossibleIncompleteSerialization(edu.umd.cs.findbugs.BugReporter bugReporter) constructs a PIS detector given the reporter to report bugs on -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanhasSerializableFields(org.apache.bcel.classfile.JavaClass cls) looks for fields that are candidates for serializationprivate static booleanhasSerializingMethods(org.apache.bcel.classfile.JavaClass cls) looks to see if this class implements method described by Serializable or Externalizableprivate static booleanisSerializable(org.apache.bcel.classfile.JavaClass cls) returns if the class implements Serializable or Externalizablevoidreport()toString()voidvisitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) implements the visitor to look for classes that are serializable, and are derived from non serializable classes and don't either implement methods in Externalizable or Serializable to save parent class fields.
-
Field Details
-
SIG_OBJECT_OUTPUT_STREAM_TO_VOID
-
SIG_OBJECT_OUTPUT_TO_VOID
-
bugReporter
private final edu.umd.cs.findbugs.BugReporter bugReporter
-
-
Constructor Details
-
PossibleIncompleteSerialization
public PossibleIncompleteSerialization(edu.umd.cs.findbugs.BugReporter bugReporter) constructs a PIS detector given the reporter to report bugs on- Parameters:
bugReporter- the sync of bug reports
-
-
Method Details
-
visitClassContext
public void visitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) implements the visitor to look for classes that are serializable, and are derived from non serializable classes and don't either implement methods in Externalizable or Serializable to save parent class fields.- Specified by:
visitClassContextin interfaceedu.umd.cs.findbugs.Detector- Parameters:
classContext- the context object of the currently parsed class
-
isSerializable
private static boolean isSerializable(org.apache.bcel.classfile.JavaClass cls) throws ClassNotFoundException returns if the class implements Serializable or Externalizable- Parameters:
cls- the class to check for interfaces- Returns:
- if the class implements Serializable or Externalizable
- Throws:
ClassNotFoundException- if a super class or super interfaces can't be found
-
hasSerializableFields
private static boolean hasSerializableFields(org.apache.bcel.classfile.JavaClass cls) looks for fields that are candidates for serialization- Parameters:
cls- the class to look for fields- Returns:
- if their is a field that looks like it should be serialized
-
hasSerializingMethods
private static boolean hasSerializingMethods(org.apache.bcel.classfile.JavaClass cls) looks to see if this class implements method described by Serializable or Externalizable- Parameters:
cls- the class to examine for serializing methods- Returns:
- whether the class handles it's own serializing/externalizing
-
report
public void report()- Specified by:
reportin interfaceedu.umd.cs.findbugs.Detector
-
toString
-