You'd probably have to look at the JVM spec. I'd say the question would be whether any instantiation of an array can be done at compile-time, or is it always a run-time. If only at run-time (which my experimentation shows is what javac seems to believe), then it wouldn't conform to the JLS and wouldn't be legal. Another perspective is whether any array is ever a "constant". I tend to doubt it. Again, the JLS would say that's illegal.
Rick |---------+----------------------------> | | Daniel Rall | | | <dlr@finemaltcodi| | | ng.com> | | | Sent by: | | | dlr@finemaltcodin| | | g.com | | | | | | | | | 02/22/2002 03:48 | | | PM | | | Please respond to| | | rpc-dev | | | | |---------+----------------------------> >----------------------------------------------------------------------------------------------------------------------| | | | To: [EMAIL PROTECTED] | | cc: | | Subject: Re: Invalid static member of inner class | >----------------------------------------------------------------------------------------------------------------------| I'm fairly certain that jikes just turns that into a constant. It's odd that javac does not -- I wonder if there is a way to convince it that it should be constant? "EXT-Raiteri, Ashley L" <[EMAIL PROTECTED]> writes: > Good call! > Oneo of our guys here caught this as well, and I was wondering if anyone > else would come up with it... > ashley raiteri > > -----Original Message----- > From: Rick Johnston [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 22, 2002 7:49 AM > To: [EMAIL PROTECTED] > Subject: Invalid static member of inner class > > > > In compiling the latest version of XmlRpcServer.java with javac (1.3.1), I > got a compiler error because of the static member 'EMPTY_BYTE_ARRAY' in the > inner 'Worker' class. Section 8.1.2 of the Java Language Spec 2nd ed. does > specifically state that "Inner classes may not declare static members, > unless they are compile-time constant fields." Since EMPTY_BYTE_ARRAY is > defined as "= new byte[0]", this is not a compile-time constant and is > therefore invalid. Interestingly, the Jikes compiler does not complain > about this (perhaps because it is also declared as final?). Alternatively, > if the Worker class was a Nested class but not an Inner class (i.e., Worker > is 'static' - which doesn't seem appropriate), this would be legal. > > I plan to move EMPTY_BYTE_ARRAY back to the outer class in my copy. I ask > that someone checks this change into CVS as well.