title: Add a missing property in a groovy @Canonical bean constructor call?
body: <p>I am new to groovy and just started exploring its metaprogramming capabilities. I got stuck with adding missing properties on a bean constructor call.</p>
  
  <p>In a class to be used with FactoryBuilderSupport, I want to dynamically add those properties that are not yet defined and provided during the constructor call. Here is stripped-down version:</p>
  
  <pre><code>@Canonical
  class MyClass {
      def startDate
      def additionalProperties = [:]
  
      def void propertyMissing(String name, value) {
          additionalProperties[name] = value
      }
  }
  </code></pre>
  
  <p>However, If I construct the class with unknown properties, the proprty is not added but I get a <code>MissingPropertyException</code> instead:</p>
  
  <pre><code>def thing = new MyClass(startDate: DateTime.now(), duration: 1234)
  </code></pre>
  
  <p>The property duration does not exist, and I expected it to be handled via <code>propertyMissing</code>. As far as I understand groovy, calling the tuple-constructor results in a no-argument constructor call followed by calls to the groovy-generated setters. So why do I get a <code>MissingPropertyException</code>?</p>
  
  <p>As I am new to groovy, I am probably missing some basic AST or MOP rules. I would highly appreciate your help.</p>