Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mac OS X Java Performance



On Thursday, July 31, 2003, at 07:51 PM, Greg Guerin wrote:
All I'm saying is that it's not only conceivable, it's actually possible,
to call or not call methods on Java objects depending on whether the object
actually implements the method or not.

It's actually fairly easy with Cocoa-Java or WebObjects, because Apple includes an NSSelector class in their Java Foundation implementation that wraps this functionality.

You can create an NSSelector from a name and argument type array, and then ask the selector if a given object or class can handle it. It's a little backwards from Objective-C or Smalltalk (where you can ask an object if it responds to a selector) but still very useful. You can then invoke the selector on an object with a set of arguments, and get a result.

This makes it very easy to support things like Cocoa- and WebObjects-style delegate objects in Java, much easier than using pure Java reflection.

Here's the best part though: It's not actually that difficult to implement your own equivalent to NSSelector. So if you're working in pure Java, write the wrapper once, and use it in every project to get more dynamism and work faster.

-- Chris

--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Mac OS X Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Mac OS X Java Performance (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.