classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] small patch to clean up 'inner' classes


From: Dalibor Topic
Subject: Re: [cp-patches] small patch to clean up 'inner' classes
Date: Fri, 11 Feb 2005 11:17:17 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5

Tom Tromey wrote:
"Dalibor" == Dalibor Topic <address@hidden> writes:


Dalibor> the attached patch cleans up the inner classes a bit, turning them
Dalibor> into real, private, static final inner classes where possible. That
Dalibor> causes less weird classes to hang around in our 'exported' APIs, and
Dalibor> makes creating profiles for Classpath's libraries simpler.

Sorry I didn't speak up on this sooner.  I agree this is generally a
good thing to do.  There is just one nit to watch out for...

Dalibor> -class IntPair implements Serializable {
Dalibor> -  public int first, second;
Dalibor> -}
[ ... ]
Dalibor> +  private static final class IntPair implements Serializable {
Dalibor> +    public int first, second;
Dalibor> +  }

The default constructor for a class will have the same permissions as
the class itself, in this case 'private IntPair()'.  But this means
that any attempt to instantiate -- 'new IntPair()' -- will then cause
an accessor constructor with default access to be created.

So, it is slightly better to either make the class package-private, or
to add an explicit no-argument package-private constructor.

Thanks, Which Eclipse version warns about this? I'd like to give it a go on Kaffe and refactor things a bit.

cheers,
dalibor topic




reply via email to

[Prev in Thread] Current Thread [Next in Thread]