JavaRelease.st
changeset 3090 9d79b824c1ad
parent 3083 ccde6af7278c
child 3096 158c061202f3
--- a/JavaRelease.st	Wed Apr 16 21:17:13 2014 +0200
+++ b/JavaRelease.st	Thu Apr 17 10:13:03 2014 +0200
@@ -42,7 +42,7 @@
 !
 
 JavaRelease::OpenJDK6 subclass:#AppleJDK6
-	instanceVariableNames:''
+	instanceVariableNames:'jdkHome'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:JavaRelease
@@ -861,6 +861,7 @@
 
     "
         JavaRelease openJDK6 sourcePath
+        JavaRelease appleJDK6 sourcePath
     "
 
     "Created: / 27-10-2010 / 19:20:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1518,6 +1519,48 @@
     ^ JavaNativeMethodImpl_AppleJDK6
 !
 
+jdkHome
+
+    "Answers the directory where the JDK lives or nil, if no JDK is found"
+
+    | dir vsn|
+
+    jdkHome notNil ifTrue:[^ jdkHome].
+
+    (dir := self javaHome) isNil ifTrue:[ ^ nil ].
+    dir := dir asFilename.
+    dir baseName = 'Contents' ifTrue:[
+        dir := dir directory.
+    ].
+    vsn := dir baseName.
+    (vsn startsWith:'1.6.0') ifTrue:[
+        vsn := '1.6.0'
+    ] ifFalse:[
+        vsn := vsn copyTo:5
+    ].
+    '/Library/Java/JavaVirtualMachines' asFilename directoryContentsAsFilenamesDo:[:f |
+        (f baseName startsWith:vsn) ifTrue:[
+            (f / 'Contents') exists ifTrue:[
+                (f / 'Contents' / 'Home') exists ifTrue:[
+                    (f / 'Contents' / 'Home' / 'src.jar') exists ifTrue:[
+                        jdkHome := f pathName.
+                        ^ jdkHome
+                    ].
+                ].
+            ].
+        ].
+    ].
+    ^ super jdkHome
+
+    "
+     Java release jreHome 
+     Java release javaHome 
+     Java release jdkHome  
+    "
+
+    "Created: / 23-01-2013 / 12:20:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 jniLibDirInJreHome
     "Returns the relative path to the native lib directory, relative to the jreHome.
      For all 'normal' systems, this is 'lib';
@@ -1651,24 +1694,29 @@
 !
 
 searchForSourcePath
-
-    | jdkHome src_zip |
-
+    | jdkHome src_jar path|
+
+    path := OrderedCollection new.
+
+    jdkHome := self jdkHome.
+    jdkHome notNil ifTrue:[ 
+        jdkHome := jdkHome asFilename.
+        (src_jar := jdkHome / 'Contents' / 'Home' / 'src.jar') exists ifTrue:[
+            path add:src_jar.
+        ].
+    ].
     super searchForSourcePath.
-
-    sourcePath := OrderedCollection new.
-    jdkHome := self jdkHome.
-    jdkHome notNil ifTrue:[
-        src_zip := jdkHome asFilename / 'src.zip'.
-        src_zip exists ifTrue:[sourcePath add: src_zip pathName].
-    ].
+    sourcePath addAllFirst:path.
 
     "
         JavaRelease openJDK7 searchForSourcePath; sourcePath
         JavaRelease sunJDK6 searchForSourcePath; sourcePath
         JavaRelease openJDK6 searchForSourcePath; sourcePath
+        JavaRelease appleJDK6 searchForSourcePath; sourcePath
         JavaRelease openJDK6 jdkHome
         JavaRelease openJDK6 jreHome
+        JavaRelease appleJDK6 jdkHome 
+        JavaRelease appleJDK6 jreHome
     "
 
     "Created: / 03-09-2012 / 18:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"