Re: Generics and ClassLoaders
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Fri, 29 Apr 2005 16:04:15 -0600
Josef Garvi <josef.REMOVE@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Yep, returning Class<?> makes perfect sense, but warning me when I cast it
> to Class<LinkHandler> less so - after all I am explicitly casting.
In the particular instance of casting to Class<LinkHandler>, you
probably shouldn't be doing this anyway. If you can refer to the class
lexically from the code, then you should just use a class literal
expression instead of ClassLoader.loadClass to obtain the reference.
However, you might wish to cast the reference to something else, for
example, Class<? extends LinkHandler>, and the problem would still
apply.
> I'd really like to get rid of the compiler warnings when
> I'm doing things right - otherwise i'll either start ignoring them, or turn
> them off - neither of which is likely to improve my code's type safety! :-)
It's unfortunately not really possible to develop with generics and
warnings for unchecked casts enabled, without just ignoring certain
compiler warnings.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
.
- Follow-Ups:
- Re: Generics and ClassLoaders
- From: Josef Garvi
- Re: Generics and ClassLoaders
- References:
- Generics and ClassLoaders
- From: Josef Garvi
- Re: Generics and ClassLoaders
- From: John C. Bollinger
- Re: Generics and ClassLoaders
- From: Josef Garvi
- Generics and ClassLoaders
- Prev by Date: Re: Generics and ClassLoaders
- Next by Date: the right way to kill a java thread on Windows?
- Previous by thread: Re: Generics and ClassLoaders
- Next by thread: Re: Generics and ClassLoaders
- Index(es):