aspose file tools*
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Doubt in reflection" Watch "Doubt in reflection" New topic
Author

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
Bartender

Joined: Apr 06, 2010
Posts: 4387
    
    8

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

Joined: Oct 27, 2005
Posts: 19693
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in reflection