Package edu.umd.cs.findbugs.detect
Class ReflectiveFieldAccessor
- java.lang.Object
-
- edu.umd.cs.findbugs.detect.ReflectiveFieldAccessor
-
class ReflectiveFieldAccessor extends java.lang.ObjectA 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
accessorFieldis filled in. For a MethodHandle theaccessTypeis fixed at creation (GETTER or SETTER); for VarHandle/AtomicFieldUpdater it isReflectiveAccessTracker.AccessType.BOTHbecause the actual access type is only known at invocation time.expectedAssignmentPCis 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
Fields Modifier and Type Field Description private XFieldaccessorFieldThe field holding the handle; set once the handle is stored.private ReflectiveAccessTracker.AccessTypeaccessTypeGETTER/SETTER for MethodHandle, BOTH for VarHandle/AtomicFieldUpdater.private XFieldactualFieldThe field the accessor reads or writes.private SourceLineAnnotationdeclarationSourceLineSource line where the accessor was declared.private intexpectedAssignmentPCPC at which the handle is expected to be stored into its field.private booleanwasUsedSet during resolution if the accessor is actually invoked.
-
Constructor Summary
Constructors Constructor Description ReflectiveFieldAccessor(XField actualField, ReflectiveAccessTracker.AccessType accessType, SourceLineAnnotation declarationSourceLine, int expectedAssignmentPC)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) XFieldaccessorField()(package private) ReflectiveAccessTracker.AccessTypeaccessType()(package private) XFieldactualField()(package private) intexpectedAssignmentPC()(package private) voidmarkUsed()(package private) voidsetAccessorField(XField accessorField)(package private) SourceLineAnnotationsourceLine()(package private) booleanwasUsed()
-
-
-
Field Detail
-
actualField
private final XField actualField
The field the accessor reads or writes.
-
accessType
private final ReflectiveAccessTracker.AccessType accessType
GETTER/SETTER for MethodHandle, BOTH for VarHandle/AtomicFieldUpdater.
-
declarationSourceLine
private final SourceLineAnnotation declarationSourceLine
Source line where the accessor was declared.
-
expectedAssignmentPC
private final int expectedAssignmentPC
PC at which the handle is expected to be stored into its field.
-
accessorField
private XField accessorField
The field holding the handle; set once the handle is stored.
-
wasUsed
private boolean wasUsed
Set during resolution if the accessor is actually invoked.
-
-
Constructor Detail
-
ReflectiveFieldAccessor
ReflectiveFieldAccessor(XField actualField, ReflectiveAccessTracker.AccessType accessType, SourceLineAnnotation declarationSourceLine, int expectedAssignmentPC)
-
-
Method Detail
-
expectedAssignmentPC
int expectedAssignmentPC()
-
markUsed
void markUsed()
-
wasUsed
boolean wasUsed()
-
accessorField
XField accessorField()
-
setAccessorField
void setAccessorField(XField accessorField)
-
actualField
XField actualField()
-
accessType
ReflectiveAccessTracker.AccessType accessType()
-
sourceLine
SourceLineAnnotation sourceLine()
-
-