In his blog Stephen Colebourne notes that no one has mentioned using a keyword for Java Bean support. He goes on to propose a new keywords, 'bean' and 'property'. He then uses a few examples to demonstrate just how this new keyword could be used. In proposing 'bean' and ‘property’ Stephen demonstrates how to incorporate new key words using existing ideas.
The 'bean' keyword acts like the 'enum' keyword. It causes the generated class to implement a JDK interface - Bean.
Since bean and property would be contextual keywords, they could be incorporated without fear of breaking existing code. The compiler, upon finding ‘bean’, would construct a new class where the properties would be publicly accessible. These new keywords are based on the Java Bean 1.0 specification. Stephen goes on in his blog to suggest a better syntax that would break (or require and update) to this specification. He suggests that maybe it would be better if the generated code looked like;
public class Person implements Bean { // public final properties public final Property forename = ... public final Property surname = ...
To access a property one would have to use something like aPerson.forname.get();. In the conclusion to this blog entry, Stephan remarks that this type of change is unlikely. However, the blog entry does bring up an interesting question, can we effectively change property support in Java without touching the Java Bean specification?