Annotation Interface PostConstructionInitializer
Marks a method as a post-construction initializer. The WPILib compiler plugin will check for uses
of methods with this annotation and report a compiler error if the method is not called after the
object is constructed.
Limitations of this annotation:
- Initializer methods must be called on the variable directly. They cannot be detected if
called indirectly (e.g., on an object returned by a method)
// This is OK Foo foo = new Foo(); foo.init(); // This is not OK Box box = new Box(new Foo()); box.getFoo().init(); - Static initializer methods must accept exactly one parameter of the type that defines the static method (they cannot accept a parameter of a supertype or derived type).
- Static initializer methods with multiple parameters of the initialized type must annotate
one of them with
PostConstructionInitializer.InitializedParamto disambiguate for the compiler.
Errors reported by the compiler plugin may be suppressed by annotating the offending method
with SuppressWarnings("PostConstructionInitializer") or
SuppressWarnings(PostConstructionInitializer.SUPPRESSION_KEY). This is intended to be used in
tests to allow runtime error handling code to be tested, but may also be used to suppress
spurious warnings in production code.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceMarks a specific parameter in a static initializer method as being the initialized object. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe string key to use inSuppressWarningsannotations to suppress compiler error messages related to this annotation.
-
Field Details
-
SUPPRESSION_KEY
The string key to use inSuppressWarningsannotations to suppress compiler error messages related to this annotation.- See Also:
-