swingler at apple.com
Wed Jan 13 09:22:40 PST 2010
On Jan 13, 2010, at 8:49 AM, Ray Kiddy wrote:
> On Jan 13, 2010, at 1:16 AM, Juha Korhonen wrote:
>> Hi, I managed to compile and install OpenJDK7 to my OSX but the
>> DYLD_LIBRARY_PATH env variable is causing me problems. If I add the
>> env variable in console the new install works, but when I use other
>> applications like Eclipse, it does not work. There must be a way to
>> pass environment variables to graphical applications and so on, but
>> is this the way the java should work? What changes are needed in
>> OpenJDK to make it work without any modifications to the system?
OpenJDK right now uses DYLD_LIBRARY_PATH as a way to tell the Mac OS X dynamic linker (dyld) where to find it's libraries by first name only, and not by the full "install_path" in their Mach-o headers. To avoid using DYLD_LIBRARY_PATH, the libraries need to be linked with an install_path that starts with @rpath, and the primary entry points into the libraries need to add LC_RPATH directives that push @loader_path relative locations onto the @rpath search stack. Once this has been accomplished, the built JDK will be able to launch and find it's own linked libraries without having to rely on the DYLD_LIBRARY_PATH environment variable.
> If you were on this list, look back to the 17th of December. There was
> a post from Mike Swingler, one of the engineers working on the java
> runtime at Apple. He posted about setting up the streuctures inside
> the "JavaVM.framework" directories that provide application support
> from java to Cocoa applications. My understanding is that this is
> still a work in progress.
> I see a post from him about possible problems from the
> DYLD_LIBRARY_PATH, though I do not know if this is the same problem.
> If you cannot find the e-mails, let me know off-list and I can send
> them to you.
> We need to have more information about using this port on Mac OS X and
> so I would encourage you to check the wiki also. (http://wikis.sun.com/display/OpenJDK/BSDPort
> ) And if you learn anything about how to make things work, there is
> probably somewhere that information could be added to the wiki.
Separately, the Java implementation provided by Apple in Mac OS X has always assumed it would be installed in /System/Library/Frameworks/JavaVM.framework/Versions/..., and so it's libraries always contained a full absolute path in their "install_path" entries. Since we would like to have the flexibility to treat the JDK as a more modular component, we have internally been unwinding many of these absolute paths, and adopting @rpath as well.
Ideally, bundled versions of the OpenJDK can be dropped into your ~/Library/Java/JavaVirtualMachines directory, so they can be discovered by the JavaVM.framework and vended for various tasks like running command line applications, powering bundled applications, applets, Web Start, and used for any app that links against the JavaVM.framework and calls JNI_CreateJavaVM(). As of right now, the current OpenJDK state is sufficient for command-line tasks or possibly launching Eclipse, however more thought needs to be put into how to discriminate between JVMs that contain Cocoa UI support, X11 UI support, or neither (still appropriate for SWT), and how client applications can express those dependancies.
Java Runtime Engineer
More information about the bsd-port-dev