Problem:
Java Objects Leak when being used from COBOL.
When using many Java objects from COBOL it was found that the Java Objects were not garbage collected by the Java runtime.
Resolution:
In order for the Java runtime (JVM) to reclaim objects created from COBOL then COBOL needs to finalize the object reference. For Example:-
class myjava is "$java$myjavaclass"
01 myjava object reference.
invoke myjava "new" returning myjava
invoke myjava "aMethod"
invoke myjava "finalize" returning myjava
The "finalize" call is required to prevent any Java object leaks.