Learned musings on possible enhancements to Java took a silly turn today when Charles Miller made several interesting and unique suggestions in the area of programmability. He goes on to give these suggestions the working title of JSR-666.
I was intrigued. A few moments more thought provided plenty of additional fodder for the proposed specification request, and it was dawned on me that this was an Idea Whose Time Has Come.
Here, I collect Charles' initial ruminations together with a few of my own ideas. I will be scouring the web for further, similar notions and certainly welcome reader contributions.
Top Three Components of JSR-666:
Previously this might have meant import-on-demand from the default package, but I don't think anybody ever wrote it. I boldly assert that no code that anybody wants to keep will be affected by this change. No JVM changes will be required.
throwsClause. Keeping track of exceptions can be another huge pain in the Java programmer's neck. We propose modifying the default behaviour of the Java compiler in the event that the
throwsclause is not specified on a method declaration.
JSR-666 proposes that an omitted throws clause be treated as though
throws Exception had been specified. That is, if no checked exceptions are specified, then the superclass of all checked exceptions is implicitly specified.
This change will have no effect on existing code. No modifications to the JVM are required.
NullPointerExceptionExceptions. A bugbear of novice Java programmers,
NullPointerExceptions will be elimated by JSR-666.
The proposed approach is to remove
null from the Java language and to specify that all variables hold a reference to a valid object, of the correct type, at all times.
Several restrictions concerning the creation of arrays will also need to be tightened. For instance, it would no longer be possible to allocate an array of an abstract class, or an array of class without a no-args constructor.
Unrecoverable errors may also occour if variables are accessed before initialisation, as may happen at instance creation and class initialization time.
Some existing Java source code may require minor modification before compilation with a JSR-666 compliant compiler. Most existing Java source code will require major modification in order to function correctly after compilation with a JSR-666 compliant compiler.
TO DO: put together notes on dynamic typing in Java, research making semi-colons optional and explore the possible use of 'begin' and 'end' as synonyms for curly braces.