Class ReflectiveFieldAccessor
java.lang.Object
edu.umd.cs.findbugs.detect.ReflectiveFieldAccessor
A reflective field accessor (VarHandle, MethodHandle or AtomicFieldUpdater).
A plain mutable value class. It is created when the accessor handle is obtained (findGetter,
findVarHandle, newUpdater, ...) and completed once the handle is stored into a field, at which
point accessorField is filled in. For a MethodHandle the accessType is fixed
at creation (GETTER or SETTER); for VarHandle/AtomicFieldUpdater it is ReflectiveAccessTracker.AccessType.BOTH
because the actual access type is only known at invocation time.
expectedAssignmentPC is scanning-phase state: it tells the detector at which PC the
handle is expected to be stored into its field, and is meaningless once the accessor has been
registered.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XFieldThe field holding the handle; set once the handle is stored.private final ReflectiveAccessTracker.AccessTypeGETTER/SETTER for MethodHandle, BOTH for VarHandle/AtomicFieldUpdater.private final XFieldThe field the accessor reads or writes.private final SourceLineAnnotationSource line where the accessor was declared.private final intPC at which the handle is expected to be stored into its field.private booleanSet during resolution if the accessor is actually invoked. -
Constructor Summary
ConstructorsConstructorDescriptionReflectiveFieldAccessor(XField actualField, ReflectiveAccessTracker.AccessType accessType, SourceLineAnnotation declarationSourceLine, int expectedAssignmentPC) -
Method Summary
Modifier and TypeMethodDescription(package private) XField(package private) ReflectiveAccessTracker.AccessType(package private) XField(package private) int(package private) voidmarkUsed()(package private) voidsetAccessorField(XField accessorField) (package private) SourceLineAnnotation(package private) booleanwasUsed()
-
Field Details
-
actualField
The field the accessor reads or writes. -
accessType
GETTER/SETTER for MethodHandle, BOTH for VarHandle/AtomicFieldUpdater. -
declarationSourceLine
Source line where the accessor was declared. -
expectedAssignmentPC
private final int expectedAssignmentPCPC at which the handle is expected to be stored into its field. -
accessorField
The field holding the handle; set once the handle is stored. -
wasUsed
private boolean wasUsedSet during resolution if the accessor is actually invoked.
-
-
Constructor Details
-
ReflectiveFieldAccessor
ReflectiveFieldAccessor(XField actualField, ReflectiveAccessTracker.AccessType accessType, SourceLineAnnotation declarationSourceLine, int expectedAssignmentPC)
-
-
Method Details
-
expectedAssignmentPC
int expectedAssignmentPC() -
markUsed
void markUsed() -
wasUsed
boolean wasUsed() -
accessorField
XField accessorField() -
setAccessorField
-
actualField
XField actualField() -
accessType
ReflectiveAccessTracker.AccessType accessType() -
sourceLine
SourceLineAnnotation sourceLine()
-