Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Implementing Platform Specific Interfaces
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing Platform Specific Interfaces



Christopher Hickman wrote :
> > I would like to implement the interface to handle the "About Application" menu
> > item in the Application menu, but I want my code to still work on other platforms.
> > Anyone know how Java handles non-existent interfaces?

You had this answer :
> link your code with MRJToolkitStubs.zip, which you can find in the MRJ SDK...

An extra precaution is to use full qualified names : i.e., instead < MRJApplicationUtils >,
write < com.apple.mrj.MRJApplicationUtils >. This avoid to have an "import" instruction,
which cannot be "tryed / catched".

This shouldn't make any difference as there is no "import" instruction in a compiled class. The class names are qualified by the compile at compile time.

With these precautions, the app can run on other platforms whithout problems,
and run as expected on Mac.

But, to compile on other platforms, it is always necessary to add <MRJToolkitStubs.zip>
to the compilation classpath. If you want to avoid this necessity, design your code
that the foreign programmer can easy find an "comment" the lines telling MRJ things.
The code compiled so will always run on Mac, but whithout the MRJ special functions.

If you merge MRJToolkitStubs.zip into your final application as well as linking with it, things aren't so restrictive as the classes you are calling (MRJApplicationUtils etc.) will always be present and there's no need to catch any exceptions (things can go bad with custom classloaders sometimes though). The classes in MRJToolkitStubs will load the native code needed to do their stuff if you're running on the Mac, and they'll do nothing on other platforms.

Hope this helps,

Jerry
--
Jerry Huxtable
http://www.jhlabs.com


References: 
 >Re: Implementing Platform Specific Interfaces (From: Steve Roy <email@hidden>)
 >Re: Implementing Platform Specific Interfaces (From: "Christopher Hickman" <email@hidden>)
 >Re: Implementing Platform Specific Interfaces (From: "Patrick Lacour" <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.