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

    Better Component.getInstance()

    Stephen Friedrich Novice

      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?