On Monday 20 September 2004 11:43, Jeroen Frijters wrote: > Hi, > > Do we have a coding style guideline about redundant field > initializers? I have a patch that removes a couple of these for > static fields that needlessly result in a static initializer > method. > > For example in javax.naming.spi.NamingManager: > > - private static InitialContextFactoryBuilder icfb = null; > + private static InitialContextFactoryBuilder icfb; > > // Package private so DirectoryManager can access it. > - static ObjectFactoryBuilder ofb = null; > + static ObjectFactoryBuilder ofb; > > Making this change removes the need for the compiler to create a > static initializer. > > Does everyone agree that this is a good idea? If so, how far should > we take this? How about this change:
I agree with you. We should remove redundant initializations . This does not only cover static field initializations but also initialization of instance variables with default values. My personal checkstyle checks for this. > Index: java/awt/EventDispatchThread.java > =================================================================== > RCS file: > /cvsroot/classpath/classpath/java/awt/EventDispatchThread.java,v > retrieving revision 1.4 > diff -u -r1.4 EventDispatchThread.java > --- java/awt/EventDispatchThread.java 31 May 2004 21:11:46 -0000 > 1.4 > +++ java/awt/EventDispatchThread.java 19 Sep 2004 09:52:47 -0000 > @@ -42,14 +42,14 @@ > > class EventDispatchThread extends Thread > { > - private static int dispatchThreadNum = 1; > + private static int dispatchThreadNum; You should a comment that the dispatchThreads start with 1 and explain it a bit. > private EventQueue queue; > > EventDispatchThread(EventQueue queue) > { > super(); > - setName("AWT-EventQueue-" + dispatchThreadNum++); > + setName("AWT-EventQueue-" + ++dispatchThreadNum); > this.queue = queue; > setPriority(NORM_PRIORITY + 1); > start(); OK, Thanks. Michael _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/classpath