The Artima Developer Community
Sponsored Link

Java Answers Forum
Dynamic Casting || Dynamic Invocation of a method of a default class

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Saisantosh Polavarapu

Posts: 2
Nickname: sai
Registered: Jul, 2002

Dynamic Casting || Dynamic Invocation of a method of a default class Posted: Jul 17, 2002 12:47 PM
Reply to this message Reply
Advertisement
Hi:

I am trying to invoke a method dynamically and here is the Error I am stuck with:
"object is not an instance of declaring class" at IllegalArgumentException block

Here is the detail information:

I need to create the instance and reference of component and invoke a method on that

Interface and helper class names would be getting dynamically.

Say I have,
public interface:ABC_Interface
public abstract class: ABC_HelperClass

In actual scenario if I would have the known classes then my code will look like

ABC_Interface abcInfer =ABC_HelperClass.invokeMethod();
abcInfer.actuallMethodCall();

The method in abstract class ABC_HelperClass that is invokeMethod() returns the object of default class(say xyzClass which implements ABC_Interface)

I need to dynamically fetch the class name (here it is ABC_HelperClass) and invoke a method on it (which I could able to do it using Java reflection): this returns the object of a default class say (xyzClass which is not public and implements ABC_Interface) so that now I get the reference of ABC_Interface object and now I have to call a method on this object.

Since I am using java reflection I am getting errors like IllegalArgumentException and "object is not an instance of declaring class"

Look to your response

Topic: Servlet to ActiveX communication Previous Topic   Next Topic Topic: How to handle Microsoft Access data type: CURRENCY ,  DATE/TIME in java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use