Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.7.0
-
None
-
None
-
Any, I guess.
I'm using Sun's Java6 on Linux.
Description
I just discovered the @Immutable annotation and migrated some of my classes to it. Unfortunately, I realized that the behavior of the constructor changes slightly: For ordinary groovy beans, I used to get a MissingPropertyException when specifying a named parameter for a non-existing property. For @Immutable groovy beans, the parameter is silently ignored.
Here an example which shows the error:
@Immutable class ImmutablePerson { String name } class Person { String name } Person p = new Person(name: "uli"); // works fine assert "uli" == p.name; ImmutablePerson ip = new ImmutablePerson(name: "uli"); // works fine, too assert "uli" == ip.name; try { Person p2 = new Person(name: "uli", lastname: "heller"); // throws an exception, fine assert false; } catch (MissingPropertyException mpe) { assert true; } try { ImmutablePerson ip2 = new ImmutablePerson(name: "uli", lastname: "heller"); // does not throw an exception assert false; // ... so it fails within this assertion } catch (MissingPropertyException mpe) { assert true; }