Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Labels:None
-
Number of attachments :
Description
Generated Closures access the factory method argument either directly by referencing the factory argument, or by referencing an instance variable. Therefore the generated Closure class has two instance variables referring to the same object.
E.g. in the StormTrooper example for attackCommand, execute() references base, the factory method argument, and equals() references $base, the instance variable. The Closure class has a synthetic member, val$base, for references to the factory method argument, and the declared member, $base. This is not a bug at runtime because the two members are final.
Also, because the class is declared within a method, it keeps a reference to the surrounding factory instance in a synthetic member. This seems to be superfluous; it prevents garbage collection of a factory instance not referenced by the StaticClosureFactory.
So the generated classes are larger than necessary.