[ ] Strongly typed annotation
- Last Updated: October 14, 2026
- 2 minute read
- OpenEdge
- Version 13.1
- Documentation
Square brackets ([ ]) enclose a strongly typed annotation applied to a class,
interface, enum, or a supported class member. A strongly typed annotation associates
metadata, defined by a user‑defined annotation class, with the program element that
immediately follows the annotation.
Annotations enclosed in square brackets are validated by the compiler against the corresponding annotation class definition and are stored in r-code. At runtime, the annotation metadata can be retrieved through the ABL reflection API as a read-only object of the annotation type with its property values populated.
Syntax
|
- annotation-name
- The name of a user-defined annotation class. The annotation class must be defined using the
ANNOTATIONstatement and be available on the PROPATH or specified using aUSINGstatement. - property-name
- The name of a property defined in the annotation class. Property names are not case-sensitive and must be unique within the annotation usage.
- constant
- A constant value compatible with the data type of the annotation property. Only constant values are allowed.
Example
The following example defines an annotation class and applies it to a method.
Annotation definition:
|
Annotation usage:
|
In this example, the ResourceMapping annotation is associated with the
ReadTestBE() method. The compiler validates the property names
and values and stores the annotation metadata in r-code for runtime access through
reflection.
Notes
- The annotation usage should appear on its own line, enclosed in square brackets, and precede the class or class member it annotates.
- An annotation is associated with the next syntactic element encountered by the compiler, ignoring intervening comments and other annotations. Multiple annotations may apply to the same element, but the same annotation type cannot be repeated on that element.
- You are not required to specify values for all properties defined in the
annotation class. Properties not specified in the annotation usage retain their
default or
INITIALvalues. - The order of property assignments in an annotation usage is not significant.
- For marker annotations (annotation classes with no properties), the parentheses
are optional:
or[Exportable].[Exportable()]. - Annotation values cannot be modified at runtime. Annotation metadata is retrieved via the ABL reflection API as a read‑only instance of the annotation type. This instance is created by the runtime on demand and cannot be instantiated directly by application code.
- Strongly typed annotations (enclosed in
[ ]) may be used alongside source-only annotations (@) in the same source file. Each follows its own syntax and rules.
See also
ANNOTATION statement, DEFINE PROPERTY statement, Progress.Lang.Annotation class, IsAnnotation( ) method, GetAnnotation( ) method, GetAnnotations( ) method, HasAnnotation( ) method