vendredi 20 janvier 2017

The blank final field INSTANCE may not have been initialized

I follow this post to create a thread safe singleton classs, but there is an compile error in INSTANCE. It said The blank final field INSTANCE may not have been initialized

public  class ServiceConnection {
    private static class SingletonObjectFactoryHolder{
      private static final ServiceSoapBindingStub  INSTANCE;
      static
         {
            try {
                INSTANCE = new ServiceSoapBindingStub();

            } catch (AxisFault e) {
                // TODO Auto-generated catch block
               e.printStackTrace();             
            }
         }  
    }

    public static ServiceSoapBindingStub getInstance() {
        return SingletonObjectFactoryHolder.INSTANCE;
    }   
} 

How to solve this problem

Aucun commentaire:

Enregistrer un commentaire