jjnair / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

Add support for obtaining Class object #278

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Request for enhancement in fest-reflect.

I'd like a way to obtain the Class object from a class name. The main
reason is to avoid the checked exception. For example, something like:

Class<? extends T> cls = Reflection.findClass(className, asType);

Original issue reported on code.google.com by jodastep...@gmail.com on 8 Jan 2009 at 11:15

GoogleCodeExporter commented 8 years ago
Stephen,

Thanks for submitting this request. Quick question, what is the purpose (and 
type) of
"asType"?

Thanks,
-Alex

Original comment by Alex.Rui...@gmail.com on 8 Jan 2009 at 2:23

GoogleCodeExporter commented 8 years ago
You need 'asType' to keep generics happy. The implementation is something like:

return getClass().getClassLoader().loadClass(className).asSubclass(asType);

Original comment by jodastep...@gmail.com on 8 Jan 2009 at 2:27

GoogleCodeExporter commented 8 years ago
Thanks Stephen, sorry I missed that :D

-Alex

Original comment by Alex.Rui...@gmail.com on 8 Jan 2009 at 3:15

GoogleCodeExporter commented 8 years ago

Original comment by Alex.Rui...@gmail.com on 24 Jan 2009 at 7:09

GoogleCodeExporter commented 8 years ago
Stephen, you can find the changes related to this task in r2242 (
http://code.google.com/p/fest/source/detail?r=2242 ).

Please feel free to review them. Feedback is always welcome! :)

Many thanks for suggesting this useful feature.

Cheers,
-Alex

Original comment by Alex.Rui...@gmail.com on 25 Jan 2009 at 2:25

GoogleCodeExporter commented 8 years ago
Thanks for implementing this. You may want to provide a way to specify the class
loader as part of the API. This causes lots of headaches in app servers, such 
that
you may not be able to find a suitable default to use.

Original comment by jodastep...@gmail.com on 28 Jan 2009 at 1:40

GoogleCodeExporter commented 8 years ago
True, I'll add that!

Thanks!
-Alex

Original comment by Alex.Rui...@gmail.com on 28 Jan 2009 at 1:42

GoogleCodeExporter commented 8 years ago
Thanks Stephen for the advice...the API is a lot better now. You can find the 
changes
made at http://code.google.com/p/fest/source/detail?r=2255 (r2255.) Please 
ignore the
StaticInnerClass* stuff, that was accidentally checked-in.

Thanks,
-Alex

Original comment by Alex.Rui...@gmail.com on 29 Jan 2009 at 6:50