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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 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: 4512

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: 19896

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