2 Replies Latest reply on Dec 29, 2008 4:32 PM by stephen

    Better Component.getInstance()

    stephen

      Currently Component.getInstance() is declared as


      public static Object getInstance(Class<?> clazz)



      so I have to use it like this:


      CssManager cssManager = (CssManager) Component.getInstance(CssManager.class);





      Wouldn't it be much nicer if Component.getInstance() were


      public static <T, U extends T> U getInstance(Class<T> clazz)


      so that I could simply write


      CssManager cssManager = Component.getInstance(CssManager.class);



      (same for the several overloaded versions)


      IMHO that would even be possible to change with no compatibility issues.


      Or am I missing some subtle point where a different type could be returned?