File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCastException

 
Rahul Saple
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok here's the scene ........ i've gotta function which i need to call whose signature goes like this


and is inside a class named AdvertisementFactory.

now ive got a class called CodatAdv which has got a public static Inner class named Instantiator which implements the original AdvertisementFactory.Instantiator and has all the methods of that particular interface(AdvertisementFactory.Instantiator)

But when i call the above static method with the following parameters



i get a classcastexception at runtime....... can someone out here tell me where i'm going wrong coz as far as i know a super-interface can always point to a sub-interface of the same class.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had some trouble following you, but as far as I can tell, you're describing something like this (with a few names shortened)...

This compiles and runs fine for me.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that really a beginner's question?

Whenever you get an Exception you need to look at its stack trace, and find out where it occurred. That should give you a hint what to do to sort it out.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic