Date: Thu, 24 Mar 2005 12:06:58 -0700
From: Greg Guerin <email@hidden>
Subject: Re: Calendar.MONTH returns 2 its March now
To: email@hidden
Message-ID: <l03130301be68b8e4d1c9@[216.190.249.206]>
Content-Type: text/plain; charset="us-ascii"
All the named Calendar constants, not just months, are defined as:
public final static int <NAME> = <int constant here>;
That means a Java compiler is free to inline them as literal constants
into
any class that references them by name. So if your class Foo has this:
int bar = Calendar.FEBRUARY + 1;
Note that all primitive types, along with Strings, having 'static
final'
qualifiers can be compile-time literals and thus subject to inlining.
And
there's no way to tell the compiler to NOT inline such constants. It
arguably has to, in order for 'case' to work (see JLS on 'case'-value
constraints).