File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 4344
    
    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: 19655
    
  18

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
 
Similar Threads
Creating a more generic DAO (no hibernate) - A good Riddle
Object Run time typecasting
jdk1.6
JPA/Hibernate: @GeneratedValue doesnt work
How to keep variable value alive in JSF