File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Doubt in reflection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Doubt in reflection" Watch "Doubt in reflection" New topic

Doubt in reflection

Shridhar Raghavan
Ranch Hand

Joined: May 27, 2010
Posts: 71
This is the signature of a method in a utility class.

Now given below is another hierarchy

Both with 1 & 2 i get an error
// The method (in the util class) select(Class<Object> clazz) is not applicable for the arguments select(<Class<capture#1-of ? extends BaseEntity>)

[Edit - added code tags - MB]
Matthew Brown

Joined: Apr 06, 2010
Posts: 4240

You're not passing in a Class<Object> - the generic part is wrong. Try declaring the method with Class<?> instead.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19542

Or perhaps even better, add a method generic type:
If you provide BaseEntity.class the result will be a List<BaseEntity>, etc.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Doubt in reflection
Similar Threads
Object Run time typecasting
JPA/Hibernate: @GeneratedValue doesnt work
How to keep variable value alive in JSF
Creating a more generic DAO (no hibernate) - A good Riddle