• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: KVC and static methods (was Hairy Java related question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC and static methods (was Hairy Java related question)


  • Subject: Re: KVC and static methods (was Hairy Java related question)
  • From: petite_abeille <email@hidden>
  • Date: Sat, 25 Oct 2003 11:57:12 +0200

On Oct 25, 2003, at 04:11, Ray Ackland wrote:

Don't know too much about reflection

check java.lang.Class and java.lang.reflect.*

, but wouldn't that just tell you whether a class could do something?

Yes.

It wouldn't solve the problem of the compiler error?

Yes. You will not need to cast anything. For example:

aClass = Class.forName( aClassName );
aMethod = aClass.getDeclaredMethod( "aMethodName", new Class[] {} );
aValue = aMethod.invoke( aClass, new Object[] {} );

The suggestion of KVC is one that could be the ideal answer, and it would never have occurred to me. Thanks for that suggestion. Now the question is whether it works with static methods.

It should. If not, file a bug report.

I have given it a try without success. Does anyone have the answer. In the meantime I have just resorted to using multiple if statements to match the class string to the method call.

Argh! Fainted.

Yeah, from what I had been reading it looked like I would have needed to instantiate a dummy object just to get the info.

To get the info about what? The interface? You can use reflection for that too:


aClass.getInterfaces();

Not the end of the world though. Looks like Obj-C would have been an easier path :)

Indeed. Objective-C provides proper class methods. Sigh.

Cheers,

PA.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: KVC and static methods (was Hairy Java related question) (From: Ray Ackland <email@hidden>)

  • Prev by Date: Re: KVC and static methods (was Hairy Java related question)
  • Next by Date: What's New in WO5.2.2.
  • Previous by thread: Re: KVC and static methods (was Hairy Java related question)
  • Next by thread: Re: KVC and static methods (was Hairy Java related question)
  • Index(es):
    • Date
    • Thread