incubator-yoko-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mosur Ravi, Balaji" <>
Subject RE: Static fields and intialization
Date Mon, 23 Oct 2006 12:46:40 GMT

The checkstyle check should allow for these kinds of checks but since
our core module had so many files, we didn't have time to go through
them & fix them. Can you log a jira item for this & we can take care of
it smaller chunks...

- Balaji

-----Original Message-----
From: Dain Sundstrom [] 
Sent: Friday, October 20, 2006 7:21 PM
Subject: Static fields and intialization

I just committed a fix to a bug caused by static field initialization  
(YOKO-196).  The bug was cause by a static initalizer calling a  
static method which accessed a static field.  I was getting a  
NullPointerException because the static field was null because the  
static field was declared after the initializer.  For example:

public class Test {
     static {

     private static final Object bar = new Object();

     private static void foo() {

     public static void main(String[] args) throws Exception {

This problem type of problem is very difficult to find and is easily  
avoided by putting all field declarations at the top of the file  
followed by any static initializers.

What do you think of changing the coding standards to have all fields  
at the top of the file?


View raw message