Reading Annotations via Reflection
Defining annotations alone is meaningless; the key is being able to read and use this metadata at runtime. Cangjie's TypeInfo provides the findAnnotation method to find annotation instances attached to types based on annotation type.
findAnnotation returns an Option type: if the corresponding annotation is found, it returns Some(annotation instance); otherwise, it returns None. Pattern matching can be used to safely extract and use annotation information. Annotations are not inherited—subclasses do not automatically have the annotation metadata of their parent class.
The code on the right defines an @Author annotation and applies it to multiple classes, then uses reflection to iterate through an array of objects and read the author information for each object.
Try adding an @Author annotation to PluginA, or create new annotated classes, and observe the output changes.