ALF 1.1 RTF Avatar
  1. OMG Issue

ALF11 — The semantics of destroying part objects without accessible destructor must be specified

  • Key: ALF11-16
  • Legacy Issue Number: 16599
  • Status: closed  
  • Source: IBM ( Mattias Mohlin)
  • Summary:

    In the section "Composition" of 10.5.2 we have the following example:

    class C

    { public a: A = new A(); public b: compose B = new B(); }

    When an instance of class C is destroyed, the object it holds for attribute b will also be automatically destroyed, but the object it holds for attribute a will not.

    However, assume now that the class B has no accessible destructor. For example, it may have an explicit destructor with parameters and/or non-public visibility so that the default destructor is no longer available (see 10.5.3.2). What will then happen when the C instance is destroyed?
    We think there should be a constraint that types of composite attributes must have a public constructor with no parameters. If this is missing, it is a static semantic error.

  • Reported: ALF 1.0b1 — Fri, 14 Oct 2011 04:00 GMT
  • Disposition: Closed; No Change — ALF 1.1
  • Disposition Summary:

    Close

    If a class is defined using Alf, as is the example class in the description of this issue, then it will always have at least one destructor, and its instances can only be destroyed using Alf by calling a destructor. Even c.destroy() will call the default destructor, if no explicit destructor has been specified.

    Since C::a is not composite, the default destructor will not call the A destructor on a – this is basic to the semantics of composite attributes in Alf, and may be exactly what is desired. If it is desired that the object in a be destroyed, then it is the responsibility of the modeler to provide an explicit destructor that does this. There does not seem any reason to make this mandatory.

    On the other hand, if an instance of c is destroyed using a destroy-object action, outside of Alf, then the semantics for that will, presumably, be as given by fUML. In that case, there is even an option on the action to not destroy objects referenced via composite attributes and links. No rules in Alf can prevent possible problems from using such low-level actions.

  • Updated: Thu, 22 Jun 2017 16:40 GMT