jump to navigation

Reflective parameter names in Java 6 May 8, 2006

Posted by James Webster in : java , trackback

Update: Paul has summarized the conversation about this issue but disappointingly it looks like the Java 6 team may be dropping this feature. It is a great shame that Java is becoming less and less willing to evolve, especially when the opposite is needed to compete against C#/.Net, Python, Ruby et al. Aside from an arguably broken implementation of generics, what did Java 1.5 bring to the table that C# 1.0’s syntax didn’t already have? (Yes, there is more to the platform choice than language syntax but that’s another conversation) Don Box is acutely aware of Ruby’s growing mind share and the reality that it has already started to take market share from the incumbents. Hopefully the Java 6 team will reconsider their decision.

My colleague Paul Hammant is asking about how we would like reflective access to parameter names to work (if it is indeed implemented) in Mustang.

He asks whether this should be enabled via an annotation or via a javac compiler flag. Via annotations feels like the right way to me (compiler flags are SOOOOO ’90s) but preferably with a way to enable parameter name access for a whole class/package/package hierarchy with the placement of a single annotation in an appropriate location. I am presuming Java 5 annotations have a similar mechanism to C# AssemblyInfo.cs and its behaviour with .Net attributes.

In addition to the possible uses that Paul defines; IDE clues, interface definitions for remoting/web services and AOP frameworks; I wonder whether this feature, inconjunction with an AOP framework, might allow a way to introduce keyword arguments with defaults, in a similar fashion to Python and Ruby?

In what other ways might this feature be potentially useful?

Comments»

no comments yet - be the first?