The language definition
(
http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.1)
says:
DecimalNumeral:
0
NonZeroDigit Digits(opt)
That is, "0" by itself falls under DecimalNumeral.
Of course, javac is still implementing the semantics required by the JLS,
since 0 octal equals 0 decimal. The compiler writer took a bit of a short
cut, is all.
Or as Mike indicated, perhaps the grammar writer took a bit of a long cut.
Perhaps he thought people would be confused if a bare 0 was an octal
constant? I'd have thought the target audience of the JLS wouldn't be.
Then again, over the years I've seen quite a lot of code with "long cuts"
or other strangenesses whose only plausible explanation was that the
programmer was drunk or otherwise under some sort of influence. Mild
inebriation could explain this grammer peculiarity, or just
unimaginitiveness. But if I had to place a bet, I'd put my money on sleep
deprivation. Programmers and technical writers are no strangers to pulling
all-nighters, and it is known that sufficiently severe sleep deprivation
has some of the same effects as intoxication.
This, if it is an instance of such, is a very mild one though. Some of the
bogosities I've seen have been horrendous. I've seen code that will turn
you white, make your hair fall out, and give *you* sleep deprivation for a
month! Worse, I've had to make changes to such code.
(I've also had to code to specs that had me tearing out my hair,
specs that made my co-workers of less sturdy constitution actually break
down and cry, and of course with a "we need this done yesterday!" deadline
accompanying. Usually web apps for a site whose ribbon-cutting date was
already announced with great fanfare to half the world. Half the time the
desired functionality required solving lots of general AI. At least those
can be cleverly solved by making the server outsource the hard bits to
humans, by presenting pending items to comment-posters and
guestbook-signers as captchas! This works until the spammers realize that
the captchas accept any response, and then the site has 2 problems. Most
spambots turn tail and run when they see a captcha form though, and the
rest are kept out by simpler means, like rejecting GET instead of POST
submissions, referrer checks, seeing if a captcha image was even
requested, requiring Javascript, requiring hidden form fields contain the
right values like a hash matching other page content, requiring things
like a 1x1 field named "subject" not be filled in, and such. There are
many, many ways to trip up a bot besides captchas.)
(If you ask me, nobody should be allowed to write specs, or be a
programmer's boss or manager, unless they have ten years experience
writing and maintaining and fixing and tweaking code themselves. What
happened to the days when programmers could get paid for being hackers?
Now we mostly take marching orders from MBAs that have never written so
much as a "Hello, World" themselves. Well, except for the lucky few that
get hired by Google, maybe.)
(Sorry about the OT digression. A couple of things have been bugging me
lately. No, don't ask. P.S. anyone ever seen pan hang with 100% cpu
utilization while composing a news post? 0.14.0 on very recent Fedora
Core, if it matters. Everything else in X11/Gnome is working fine, TTBOMK,
except gvim dumps core if I do some sufficiently obscure things. Perhaps a
library needs updating to a newer version somewhere? Console stuff, of
course, works flawlessly, though I hate text-mode vi/m (I miss my X
clipboard) and absolutely refuse to touch emacs or nano, the former in
or out of X and each for entirely separate reasons. So, it's probably an X
lib, GTK, or Gnome.)