[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] small patch to clean up 'inner' classes
From: |
Tom Tromey |
Subject: |
Re: [cp-patches] small patch to clean up 'inner' classes |
Date: |
03 Feb 2005 17:22:00 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
>>>>> "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.
I think Eclipse can warn about this situation. gcjx can as well... so
eventually I think we'll be detecting it automatically during the
builds.
Tom