You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Rick Johnston <RR...@symantec.com> on 2002/02/22 16:48:48 UTC

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.

Rick



Re: Invalid static member of inner class

Posted by Daniel Rall <dl...@finemaltcoding.com>.
"Rick Johnston" <RR...@symantec.com> writes:

> 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.

Done.

Re: Invalid static member of inner class

Posted by Daniel Rall <dl...@finemaltcoding.com>.
"Rick Johnston" <RR...@symantec.com> writes:

> 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.

Done.