The ATTRIBUTE or CUSTOM-ATTRIBUTE clause specifies an attribute that provides metadata (information) about a JVM COBOL code native data item or a property that will be visible using reflection.

Format 1

{ ATTRIBUTE attribute-name(constructor-params, NAME property-name = property-value, ...) } ...

Format 2 (for Backward Compatibility)

{ CUSTOM-ATTRIBUTE IS  class-name-1 [ ( {parameter-1} . . . ) ] }... 

Syntax Rules for Format 1

  1. Attribute-name can be specified without quotes and can optionally omit the trailing "Attribute" part of the name.
  2. Constructor-params are the standard parameters to the required attribute constructor. For example:

    attribute Marshal-Attribute(3)

  3. The name/value pairs, preceded by the keyword NAME are used to set any required attribute properties. Property-name can be specified without quotes. For example:

    attribute WebService(NAME Description="My service")

Syntax Rules for Format 2 (for Backward Compatibility)

  1. This list of parameters must match a constructor defined for class-name-1. Each parameter-1 must be one of the following:
    • An ordinary parameter that is the argument to the constructor for that attribute. For example:

      custom-attribute is Marshal-Attribute(3)

    • A named parameter that corresponds to a property defined on the custom attribute class. For example:

      custom-attribute is webservice("Description"="My service")

General Rules

  1. The custom attribute specified becomes part of the metadata describing the subject of the entry and is visible to a reflector.
  2. Languages for JVM support annotations, which are similar broadly to attributes in COBOL.