First-class methods (FCM) is a compelling proposal to enhance the Java language so that methods, fields and constructors can have full type-safety.
In today's Java, we write this:
Method getter = Action.class.getDeclaredMethod("isEnabled", new Class[] { });
Method setter = Action.class.getDeclaredMethod("setEnabled", new Class[] { boolean.class });
boolean fooEnabled = getter.invoke(fooAction, new Object[] { });
setter.invoke(barAction, new Object[] { false });`</pre>This code is unnecessarily verbose. The caller needs to catch a `NoSuchMethodException` because the String method names are not compile-time checked.
FCM fixes these problems! The above code becomes this:
<pre>`Method getter = Action#isEnabled()
Method setter = Action#setEnabled(boolean)
boolean fooEnabled = getter.invoke(fooAction, new Object[] { });
setter.invoke(barAction, new Object[] { false });`</pre>The method instances themselves can even be expressed safely, which adds even more type-safety:
<pre>`#(boolean(Action)) getter = Action#isEnabled();
#(void(Action,boolean)) setter = Action#setEnabled(boolean);
boolean fooEnabled = getter.invoke(fooAction);
setter.invoke(barAction, false);`</pre>Naturally this is very powerful! The syntax is unfamiliar but adjusted to generics and we could adjust to FCM.
**Applications to Properties**
FCM makes a very concise and typesafe syntax for [Properties](http://publicobject.com/2007/06/modelling-properties-in-java.html) possible - just specify the getters and setters:
<pre>`Property<Action,Boolean> property = new MethodsProperty(
Action#isEnabled(), Action#setEnabled(boolean))
boolean fooEnabled = property.get(fooAction);
property.set(barAction, false);
By implementing JSR-295 beans binding with a Property interface, we're making it possible for the project to leverage future Java language enhancements.