[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
redundant field initializers
From: |
Jeroen Frijters |
Subject: |
redundant field initializers |
Date: |
Mon, 20 Sep 2004 11:43:08 +0200 |
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:
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;
private EventQueue queue;
EventDispatchThread(EventQueue queue)
{
super();
- setName("AWT-EventQueue-" + dispatchThreadNum++);
+ setName("AWT-EventQueue-" + ++dispatchThreadNum);
this.queue = queue;
setPriority(NORM_PRIORITY + 1);
start();
Regards,
Jeroen
- redundant field initializers,
Jeroen Frijters <=