Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,14 @@ fi

AC_SUBST(classlib)

dnl On Darwin, the OpenJDK class library's native libraries (e.g. libjava)
dnl reference libjvm via @rpath/libjvm.dylib. Set our install name to match
dnl so that dyld resolves the dependency.
if test "$classlib" = openjdk -a "$host_os" = darwin; then
LIBJVM_EXTRA_LDFLAGS="-Wl,-install_name,@rpath/libjvm.dylib"
fi
AC_SUBST(LIBJVM_EXTRA_LDFLAGS)

case "$with_java_runtime_library" in
gnuclasspath | openjdk6 )
AC_DEFINE([SHARED_CHAR_BUFFERS],1,
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ libjvm_la_SOURCES =

jamvm_LDADD = libcore.la
libjvm_la_LIBADD = libcore.la
libjvm_la_LDFLAGS = -avoid-version
libjvm_la_LDFLAGS = -avoid-version @LIBJVM_EXTRA_LDFLAGS@
libcore_la_LIBADD = interp/libinterp.la os/@os@/@arch@/libnative.la \
os/@os@/libos.la classlib/@classlib@/libclasslib.la

Expand Down
9 changes: 9 additions & 0 deletions src/classlib/openjdk/dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ int classlibInitialiseDll() {

char *classlibDefaultBootDllPath() {
char *java_home = getJavaHome();

/* On most platforms, native libraries are in lib/<arch>/.
On Darwin, they are directly in lib/. */
#ifdef __APPLE__
char *dll_path = sysMalloc(strlen(java_home) + sizeof("/lib"));

return strcat(strcpy(dll_path, java_home), "/lib");
#else
char *dll_path = sysMalloc(strlen(java_home) + sizeof("/lib/"OS_ARCH));

return strcat(strcpy(dll_path, java_home), "/lib/"OS_ARCH);
#endif
}

void *classlibLookupLoadedDlls(char *name, Object *loader) {
Expand Down
13 changes: 11 additions & 2 deletions src/classlib/openjdk/properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ char *classlibDefaultJavaHome() {
int count = 0;
char *home;

while(pntr > path && count < 4)
/* Derive java.home from the location of libjvm.
Default (most platforms): <java.home>/lib/<arch>/<vmname>/libjvm.so
Darwin (no arch subdir): <java.home>/lib/<vmname>/libjvm.dylib */
#ifdef __APPLE__
int n_sep = 3;
#else
int n_sep = 4;
#endif

while(pntr > path && count < n_sep)
count += *--pntr == '/';

if(count != 4) {
if(count != n_sep) {
printf("Error: JVM path malformed. Aborting VM.\n");
exitVM(1);
}
Expand Down
8 changes: 8 additions & 0 deletions src/properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <unistd.h>
#include <sys/utsname.h>

#ifdef __APPLE__
#include <TargetConditionals.h>
#endif

#include "jam.h"
#include "symbol.h"
#include "hash.h"
Expand Down Expand Up @@ -161,7 +165,11 @@ void setOSProperties(Object *properties) {

uname(&info);
setProperty(properties, "os.arch", OS_ARCH);
#if defined(__APPLE__) && !TARGET_OS_IPHONE
setProperty(properties, "os.name", "Mac OS X");
#else
setProperty(properties, "os.name", info.sysname);
#endif
setProperty(properties, "os.version", info.release);
}

Expand Down