Hiding a factory or static method
A factory method defined in a subclass is said to hide an inherited COBOL or Java™ method that would otherwise be accessible in the subclass if the two methods have the same signature.
About this task
To hide a superclass factory method f1
in
a COBOL subclass, define a factory method f1
in the
subclass that has the same name and whose PROCEDURE DIVISION
USING
phrase (if any) has the same number and type of formal
parameters as the superclass method has. (If the superclass method
is implemented in Java, you
must code formal parameters that are interoperable with the data types
of the corresponding Java parameters.)
When a client invokes f1
using the subclass name,
the subclass method rather than the superclass method is invoked.
The presence or absence
of a method return value and the data type of the return value used
in the PROCEDURE DIVISION RETURNING
phrase (if any)
must be identical in the subclass factory method and the hidden superclass
method.
A factory method must not hide an instance method in a Java or COBOL superclass.
Example: defining a factory (with methods)
Coding interoperable data types in COBOL and Java
Overriding an instance method
Invoking methods (INVOKE)
The Java Language Specification (Inheritance, overriding, and hiding)
The procedure division header (Enterprise COBOL for z/OS® Language Reference)