ANNOTATION statement
- Last Updated: July 27, 2026
- 2 minute read
- OpenEdge
- Version 13.1
- Documentation
Defines a user-defined annotation class that represents a strongly typed annotation. Annotation classes are used to declare metadata that can be associated with classes and class members and later retrieved at runtime through the ABL reflection API. Annotation definitions are compiled into r-code and validated by the compiler for correctness and consistency.
An annotation class is defined in its own .cls file and contains
only property definitions that describe the metadata carried by the annotation. It
cannot define methods, constructors, events, or other executable elements.
Syntax
|
- annotation-type-name
- Specifies the name of the annotation class. The name follows the same naming rules as an ABL class and typically includes a package qualifier. The annotation class name must match the name of the .cls file in which it is defined.
- property-definition
- Defines a property that represents a piece of metadata carried by the annotation.
Properties are defined using a restricted form of the
DEFINE PROPERTYstatement:DEFINE [PUBLIC] PROPERTY property-name AS primitive-type-name [ INITIAL constant ].Only built-in primitive data types (
INTEGER,INT64,CHARACTER,DECIMAL,DATE,DATETIME,DATETIME-TZ, andLOGICAL) are allowed for annotation properties.
Example
The following example defines an annotation class named
service.ResourceMapping with several properties that describe
how a service method is exposed:
|
The annotation can then be applied to a class member by enclosing the annotation usage in square brackets:
|
When the class is compiled, the annotation and its property values are stored in r-code and can be accessed at runtime via reflection.
Notes
- Only one annotation class definition is allowed per .cls file.
- Annotation classes may define properties only. Methods, constructors, events, inheritance from regular classes, and interfaces are not allowed.
- Annotation properties are always public, implicitly read-only, and cannot be assigned values programmatically at runtime. Their values are set only through annotation usage in source code.
- Annotation classes cannot be directly instantiated using
NEW,DYNAMIC-NEW(), or reflection class constructors. Annotation instances are created implicitly by the runtime when accessed through the reflection API. - An annotation class implicitly inherits from
Progress.Lang.Annotation. This inheritance cannot be specified explicitly in the annotation definition. - An annotation class may be used as a marker annotation by defining no properties. In this case, the presence of the annotation alone conveys meaning.
See also
[ ] Strongly typed annotation, DEFINE PROPERTY statement, Progress.Lang.Annotation class, IsAnnotation( ) method, GetAnnotation( ) method, GetAnnotations( ) method,