1 Reply Latest reply on Mar 20, 2008 11:19 AM by alesj

    Generics again

      Ales, I still don't think you've groked generics.

      Like I said before, generics is not a way to avoid having to write a cast.
      Its for telling the compiler what you are doing.

      I just upgraded to your latest test code in jboss-reflect which uses generics
      yet there are 60 errors due to "unsafe type usage".

      Something is very wrong.

      Try using eclipse (with all the generics warnings turned on)
      if you can't get IDEA to run -XLint from the JDK compiler.

      That way you'll learn how to correctly use generics.

      For now I've just added
      @SuppressWarnings("unchecked")
      which should really only be used when the generics are a good idea
      but you can't actually use them, e.g. because reflection/serialization looses the type.

        • 1. Re: Generics again
          alesj

           

          "adrian@jboss.org" wrote:

          Like I said before, generics is not a way to avoid having to write a cast.
          Its for telling the compiler what you are doing.

          I just upgraded to your latest test code in jboss-reflect which uses generics
          yet there are 60 errors due to "unsafe type usage".

          You mean BeanInfoUtilTestCase and the SetGetHook hack?
          Yup, almost the same mistake as FromContext. :-(

          It's the 'middle' nested beans that are the root of the problem, since I've hacked them to work with sub's.
          I think the original idea was generic OK. :-)

          "adrian@jboss.org" wrote:

          Try using eclipse (with all the generics warnings turned on)
          if you can't get IDEA to run -XLint from the JDK compiler.

          That way you'll learn how to correctly use generics.

          Hmm, I think it's not that horrible, since apart from FromContext I don't remember any other generic hack that I've introduced in the main code.
          Perhaps a few tests might also be questionable ...

          But yeah, why not, I'll turn this on.
          In IDEA, definitely not in Eclipse. ;-)