Linking to JavaRuntimeSupport framework

David Smith-Uchida dave at igeekinc.com
Thu Jul 21 06:43:03 PDT 2011


I haven't tried building and running it yet, but the problem was triggered by the call to JRSCopyOSVersion in
jdk/src/solaris/native/java/lang/java_props_md.c

Looking at the new code, it's now linking JavaRuntimeSupport dynamically to call it.  Do you have that update?

I'm not sure if that's going to fix it because when I traced down into the code with gdb it was JRSCopyOSVersion calling into some java init that triggered the check for the runtimes, not the static links.

Here's the patch I made:

--- a/src/solaris/native/java/lang/java_props_md.c	Thu Jun 23 11:23:55 2011 -0700
+++ b/src/solaris/native/java/lang/java_props_md.c	Thu Jul 21 22:40:32 2011 +0900
@@ -42,10 +42,6 @@
 #include <time.h>
 #include <errno.h>
 
-#ifdef MACOSX
-#import <JavaRuntimeSupport/JRSProperties.h>
-#endif
-
 #if defined(_ALLBSD_SOURCE)
 #if !defined(P_tmpdir)
 #include <paths.h>
@@ -73,6 +69,47 @@
 #include <sys/stat.h>
 #endif
 
+#ifdef MACOSX
+#import <CoreServices/CoreServices.h>
+void getSystemVersionMajor(unsigned * major, unsigned * minor, unsigned * point)
+{
+    OSErr err;
+    SInt32 systemVersion, versionMajor, versionMinor, versionPoint;
+    if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
+    if (systemVersion < 0x1040)
+    {
+        if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
+            ((systemVersion & 0x0F00) >> 8);
+        if (minor) *minor = (systemVersion & 0x00F0) >> 4;
+        if (point) *point = (systemVersion & 0x000F);
+    }
+    else
+    {
+        if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
+        if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
+        if ((err = Gestalt(gestaltSystemVersionBugFix, &versionPoint)) != noErr) goto fail;
+        if (major) *major = versionMajor;
+        if (minor) *minor = versionMinor;
+        if (point) *point = versionPoint;
+    }
+    
+    return;
+    
+fail:
+    if (major) *major = 10;
+	if (minor) *minor = 0;
+	if (point) *point = 0;
+}
+
+char * JRSCopyOSVersion()
+{
+	char * returnString = malloc(16);
+	unsigned major, minor, point;
+	getSystemVersionMajor(&major, &minor, &point);
+	sprintf(returnString, "%d.%d.%d", major, minor, point);
+	return returnString;
+}
+#endif
 /* Take an array of string pairs (map of key->value) and a string (key).
  * Examine each pair in the map to see if the first string (key) matches the
  * string.  If so, store the second string of the pair (value) in the value and
@@ -430,7 +467,7 @@
         sprops.os_arch = ARCHPROPNAME;
 
 #ifdef MACOSX
-        sprops.os_name = JRSCopyOSName();
+        sprops.os_name = "Mac OS X";
         sprops.os_version = JRSCopyOSVersion();
 #ifdef __x86_64__
         sprops.os_arch = "x86_64";

----

And then, I commented out the -framework JavaRuntimeSupport in jdk/make/java/java/Makefile

--- a/make/java/java/Makefile	Thu Jun 23 11:23:55 2011 -0700
+++ b/make/java/java/Makefile	Thu Jul 21 22:42:13 2011 +0900
@@ -221,7 +221,9 @@
 OTHER_LDLIBS += \
 	-framework CoreFoundation \
 	-framework SystemConfiguration \
-	-framework JavaRuntimeSupport
+	-framework CoreServices \
+	#-framework JavaRuntimeSupport
+
 endif
 endif


Cheers,
Dave Smith

On Jul 21, 2011, at 9:30 PM, David Kocher wrote:

> On 26.01.2011, at 21:33, Mike Swingler wrote:
> 
>> On Jan 26, 2011, at 11:39 AM, David Kocher wrote:
>> 
>>> On 26.01.2011, at 17:17, Mike Swingler wrote:
>>> 
>>> Thanks for the clarification. I was mixing things up. JavaRuntimeSupport.framework is indeed part of the public JavaVM.framework. Can you assure that this framework will be in the default install of subsequent major OS X releases (10.7 and onward)?
>> 
>> I cannot comment specifically about Mac OS X 10.7, however it is our intention for the additions made to the /System/Library/Frameworks folder by Java updates to be standard API on Mac OS X.
>> 
>>> The Java deprecation notice never made it clear to me, what parts will be optional installs. I would assume that only  /System/Library/Java/JavaVirtualMachines/* falls into this category then.
>> 
>> This is not a bad assumption to make. Hopefully I can discuss more at a later time.
>> 
>> My best,
>> Mike Swingler
>> Java Engineering
>> Apple Inc.
> 
> I just tried the latest snapshot build with changeset [1] included but I still get the optional installation alert triggered despite having no Java element in the Info.plist dictionary. otool -L shows no dependency on any of the JavaVM embedded frameworks. Any clue?
> 
> 
> -
> David
> 
> 
> [1] http://hg.openjdk.java.net/macosx-port/macosx-port/jdk/rev/1b591a1e6881



More information about the macosx-port-dev mailing list