title: How do I store a list/array of classes in a Groovy variable?
body: <p>I want to store a list/array of Java exception classes (e.g. NullPointerException, some custom exception classes, etc.) into a Groovy list/array, but I keep running into either casting problems or MissingPropertyException:</p>
  
  <pre><code>class Foo {
    Exception[] foo
    List bar
  
    def setFoo(Exception[] values) {
      this.foo = values
    }
  
    def setBar(List values) {
      this.bar = values
    }
  }
  
  f = Foo()
  f.setFoo([NullPointerException.class])
  f.setBar(Arrays.asList(NullPointerException.class))
  </code></pre>
  
  <p>But I can't seem to get it right. Any pointer is much appreciated. Thanks!</p>