Posted by tferguson
on March 7, 2007 at 1:05 PM PST
Sun has graciously opened the door to hacking on the entire Java stack to hordes of GPL-preferring developers. Is it time to start talking about some changes to javac and VM that would allow people trade off better performance in exchange for backward compatibility or an airtight security model (that is things that Sun holds dear, but some of the rest of us are willing to bend on)? Specifically I'm thinking of two things, but I think there are probably more.
First, array index checking. With this simple statement "All array accesses are checked at run time; an attempt to use an index that is less than zero or greater than or equal to the length of the array causes an ArrayIndexOutOfBoundsException to be thrown." (section 10.4 of JLS) Sun singlehandedly fueled one of the biggest issue in the Java vs. C/C++ religious wars. Why not let the user decide? Why not allow some other "pretty good" options like guard pages around arrays?
Second, when I first read about Generics, I was excited about not having to type all those annoying casts when dealing with the standard libraries. However what wasn't immediately obvious was that really the typing is the ONLY thing you save, because it inserts all the casts back in after the initial type-checking stage of the compilation. There's no good reason not to allow the user to tell the compiler to generate type-specific versions of the genericized class, and then to avoid the many casts. In order to make this work, you would need access to the source of the genericized classes at compile time, but in any case it could fall back on the old behavior.
Since these changes break assumptions in the JLS and other well-established standards, I think they would never be accepted into the normal JSR process. That doesn't mean they're not needed.
What do you think?