JavaRelease.st
branchcvs_MAIN
changeset 3360 1a8899091305
parent 3349 1d25e9cecbea
parent 3324 a58245c0e83a
child 3378 cdb00120c2fd
--- a/JavaRelease.st	Fri Feb 14 14:27:26 2014 +0100
+++ b/JavaRelease.st	Wed Jan 28 03:12:08 2015 +0100
@@ -1,9 +1,9 @@
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -21,9 +21,8 @@
 "{ Package: 'stx:libjava' }"
 
 Object subclass:#JavaRelease
-	instanceVariableNames:'javaHome sourcePath classes bootClassPathClasses extDirsClasses
-		bundle bootClassPath'
-	classVariableNames:''
+	instanceVariableNames:'javaHome sourcePath classes bundle bootClassPath'
+	classVariableNames:'System'
 	poolDictionaries:''
 	category:'Languages-Java-Support'
 !
@@ -38,14 +37,28 @@
 JavaRelease subclass:#OpenJDK6
 	instanceVariableNames:''
 	classVariableNames:''
-	poolDictionaries:'JavaVMData'
+	poolDictionaries:''
+	privateIn:JavaRelease
+!
+
+JavaRelease::OpenJDK6 subclass:#AppleJDK6
+	instanceVariableNames:'jdkHome'
+	classVariableNames:''
+	poolDictionaries:''
 	privateIn:JavaRelease
 !
 
 JavaRelease::OpenJDK6 subclass:#OpenJDK7
 	instanceVariableNames:''
 	classVariableNames:''
-	poolDictionaries:'JavaVMData'
+	poolDictionaries:''
+	privateIn:JavaRelease
+!
+
+JavaRelease::OpenJDK7 subclass:#OpenJDK8
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
 	privateIn:JavaRelease
 !
 
@@ -63,10 +76,10 @@
 	privateIn:JavaRelease
 !
 
-JavaRelease subclass:#OsxJDK6
+JavaRelease::OracleJDK7 subclass:#OracleJDK8
 	instanceVariableNames:''
 	classVariableNames:''
-	poolDictionaries:'JavaVMData'
+	poolDictionaries:''
 	privateIn:JavaRelease
 !
 
@@ -81,11 +94,11 @@
 
 copyright
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -129,7 +142,7 @@
 
 !JavaRelease class methodsFor:'initialization'!
 
-flush   
+flush
     Java release: nil.
     instance := nil.
     self subclasses do:[:e|e flush].
@@ -148,12 +161,16 @@
 
     self openJDK6 isAvailable ifTrue:[^ self openJDK6].
     self oracleJDK6 isAvailable ifTrue:[^ self oracleJDK6].
-    self allSubclassesDo:[:rel |
-        (rel isJDK6 and:[ rel isAvailable ]) ifTrue:[^ rel instance ].
+    self allSubclassesDo:[:relCls |
+        | rel |
+
+        rel := relCls instance.
+        (relCls isJDK6 and:[ rel isAvailable ]) ifTrue:[^ rel ].
     ].
     self error:'no JDK6 found'
 
     "Created: / 16-02-2013 / 09:21:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-04-2014 / 13:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 JDK7
@@ -161,9 +178,11 @@
 
     self openJDK7 isAvailable ifTrue:[^ self openJDK7].
     self oracleJDK7 isAvailable ifTrue:[^ self oracleJDK7].
-    self allSubclassesDo:[:rel |
-        (rel isJDK7 and:[ rel isAvailable ]) ifTrue:[^ rel instance ].
-    ].
+    self allSubclassesDo:[:relCls |
+        | rel |
+
+        rel := relCls instance.
+        (relCls isJDK7 and:[ rel isAvailable ]) ifTrue:[^ rel ].                   ].
     self error:'no JDK7 found'
 
     "
@@ -173,6 +192,34 @@
     "
 
     "Created: / 16-02-2013 / 09:21:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-04-2014 / 13:33:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+JDK8
+    "Meta-release - return either OpenJDK or OracleJDK"
+
+    self openJDK8 isAvailable ifTrue:[^ self openJDK7].
+    self oracleJDK8 isAvailable ifTrue:[^ self oracleJDK7].
+    self allSubclassesDo:[:relCls |
+        | rel |
+
+        rel := relCls instance.
+        (relCls isJDK8 and:[ rel isAvailable ]) ifTrue:[^ rel ].                   ].
+    self error:'no JDK8 found'
+
+    "
+        JavaRelease JDK6
+        JavaRelease JDK7
+
+    "
+
+    "Created: / 03-04-2014 / 12:34:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+appleJDK6
+    ^ AppleJDK6 instance
+
+    "Created: / 06-02-2014 / 11:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 openJDK6
@@ -189,6 +236,12 @@
     "Created: / 26-07-2012 / 23:51:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+openJDK8
+    ^ OpenJDK8 instance.
+
+    "Created: / 03-04-2014 / 12:34:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 oracleJDK6
     ^ OracleJDK6 instance
 
@@ -201,12 +254,17 @@
     "Created: / 12-02-2013 / 03:03:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-oracleJRE7
-    ^ OracleJRE7 instance
+oracleJDK8
+    ^ OracleJDK8 instance
+
+    "Created: / 03-04-2014 / 12:34:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 osxJDK6
-    ^ OsxJDK6 instance
+    <resource: #obsolete>
+    ^ self appleJDK6
+
+    "Modified: / 06-02-2014 / 11:01:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 sunJDK122
@@ -233,7 +291,24 @@
     "Created: / 27-07-2012 / 00:10:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+allForCurrentOperatingSystem
+    "Return all releases for current operating system, even those that
+     are not installed / autodetected.
+
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows.
+    "
+
+    ^ self all select:[:each | each isAvailableOnCurrentOperatingSystem ]        
+
+    "
+        JavaRelease allForCurrentOperatingSystem
+    "
+
+    "Created: / 07-12-2014 / 23:45:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 any
+    <resource: #obsolete>
     | releases |
 
     releases := self available.
@@ -253,7 +328,7 @@
 available
     | releases out path |
 
-    releases := self all select: [:rel | rel isAvailable ].
+    releases := self allForCurrentOperatingSystem select: [:rel | rel isAvailable ].
     releases isEmpty ifTrue: [
         "/ none of the releases seems to be installed in a way that it is found
         "/ out of the box. Try a 'java' command...
@@ -262,14 +337,14 @@
             (OperatingSystem executeCommand:'java -version' outputTo:out) ifTrue:[
                 out := out contents.
                 releases := self all select:[:rel | rel validateJavaVersionString:out].
-"/                "/ ('/System/Library/Java' asFilename) exists.  
+"/                "/ ('/System/Library/Java' asFilename) exists.
 "/                releases do:[:each |
 "/                    each javaHome:('/System/Library/Java/Home' asFilename).
 "/                ].
             ].
         ].
-        releases isEmpty ifTrue: [ 
-            self error: 'No Java release found'. ^nil 
+        releases isEmpty ifTrue: [
+            self error: 'No Java release found'. ^nil
         ].
     ].
     ^releases
@@ -279,6 +354,151 @@
     "
 
     "Created: / 26-07-2012 / 23:41:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-12-2014 / 00:03:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+default
+    | releases |
+
+    releases := self available.
+    releases isEmptyOrNil ifTrue:[ ^ nil ].
+    ^ releases first initialize
+
+
+    "
+        JavaRelease any
+    "
+
+    "Created: / 11-11-2013 / 14:07:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+forExecutable: javaExecutable
+    "Returns an instance of JavaRelease for given java executable
+     (java.exe on Windows, java on UNIX). Return nil if javaExecutable
+     does not exits, not executable or version of that Java version is
+     not recognized/suppported."
+
+    javaExecutable notNil ifTrue:[
+        | releases |
+        releases := JavaRelease allSubclasses reject:[:each | each isAbstract ] thenCollect:[:each | each new ].
+        releases sort:[:a :b | a priority > b priority ].
+        releases do:[:release |
+            (release validateJavaExecutable: javaExecutable) ifTrue:[
+                release javaExecutable: javaExecutable.
+                ^ release.
+            ].
+        ]
+    ].
+    ^ nil.
+
+    "Created: / 08-04-2014 / 14:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-04-2014 / 20:03:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+inDirectory:javaHome
+    "Returns an instance of JavaRelease for given javaHome or nil if
+     given javaHome does not point to Java installation directory."
+
+    self available do:[:each | (each javaHome = javaHome) ifTrue:[ ^ each ] ].
+
+    javaHome notNil ifTrue:[
+        | releases |
+        releases := self allSubclasses reject:[:each | each isAbstract ] thenCollect:[:each | each new ].
+        releases sort:[:a :b | a priority > b priority ].
+        releases do:[:release |
+            (release validateJavaHome: javaHome) ifTrue:[
+                release javaHome: javaHome.
+                ^ release.
+            ].
+        ]
+    ].
+    ^ nil.
+
+    "Created: / 11-11-2013 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 09-12-2014 / 13:01:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+system
+    "Return the release for *system* java or nil if no system JDK/JRE
+     installation is available.
+
+     By *system* JDK/JRE we mean JDK/JRE used by `java` command found along the path"
+
+    | javaExecutable |
+
+    System isNil ifTrue:[
+        "/ On Windows, search registry first...
+        OperatingSystem isMSWINDOWSlike ifTrue:[
+            "Search for JDK first..."
+
+            | entry javaVersion javaHome |
+            entry := OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit'.
+            entry notNil ifTrue:[
+                javaVersion := entry valueNamed:'CurrentVersion'.
+                javaVersion notNil ifTrue:[
+                    entry := OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\' , javaVersion.
+                    entry notNil ifTrue:[
+                        javaHome := entry valueNamed:'JavaHome'.
+                    ]
+                ]
+            ].
+            javaHome isNil ifTrue:[
+                "/ JDK not found, look for JRE...
+                entry := OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment'.
+                entry notNil ifTrue:[
+                    javaVersion := entry valueNamed:'CurrentVersion'.
+                    javaVersion notNil ifTrue:[
+                        entry := OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\' , javaVersion.
+                        entry notNil ifTrue:[
+                            javaHome := entry valueNamed:'JavaHome'.
+                        ]
+                    ]
+                ].
+            ].
+            (javaHome notNil and:[javaHome asFilename isDirectory]) ifTrue:[
+                javaVersion = '1.6' ifTrue:[
+                    System := OracleJDK6 new javaHome: javaHome
+                ] ifFalse:[
+                javaVersion = '1.7' ifTrue:[
+                    System := OracleJDK7 new javaHome: javaHome
+                ] ifFalse:[
+                javaVersion = '1.8' ifTrue:[
+                    System := OracleJDK8 new javaHome: javaHome
+                ]]]
+            ].
+        ] ifFalse:[
+            javaExecutable isNil ifTrue:[javaExecutable := OperatingSystem pathOfCommand: 'java'].
+            javaExecutable isNil ifTrue:[ ^ nil ].
+            "/ On some Linux installations, /usr/bin/java -> /etc/alternatives/java -> /usr/lib/jvm/.../jre/java/bin,
+            "/ care for that.
+            javaExecutable := javaExecutable asFilename asAbsoluteFilename.
+            javaExecutable isSymbolicLink ifTrue:[
+                javaExecutable := javaExecutable physicalFilename.
+                javaExecutable isNil ifTrue:[ 
+                    "/ Broken link, ignore...    
+                    ^ nil
+                ].
+                javaExecutable := javaExecutable asAbsoluteFilename.
+            ].
+            System := JavaRelease forExecutable: javaExecutable.
+        ].
+        "/ Use the autodetected release if that's the system one...
+        System notNil ifTrue:[
+            System javaHome = System class instance javaHome ifTrue:[ 
+                System := System class instance
+            ].
+        ].
+    ].
+    ^ System
+
+    "
+        System := nil
+        JavaRelease system
+        JavaRelease system == JavaRelease system class instance
+    "
+
+    "Created: / 11-11-2013 / 14:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 09-12-2014 / 14:03:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease class methodsFor:'instance creation-private'!
@@ -314,6 +534,12 @@
 
 isJDK7
     ^ false
+!
+
+isJDK8
+    ^ false
+
+    "Created: / 03-04-2014 / 12:34:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease methodsFor:'accessing'!
@@ -324,7 +550,7 @@
     bootClassPath isNil ifTrue:[
         | jreHome libs |
 
-        jreHome := self jreHome.    
+        jreHome := self jreHome.
         jreHome notNil ifTrue:[
             libs := jreHome / (self libDirInJreHome).
             bootClassPath := OrderedCollection new.
@@ -361,7 +587,7 @@
 !
 
 bootClassPath:aCollectionOfPathes
-    "Change the bootClassPath"                         
+    "Change the bootClassPath"
 
     bootClassPath := OrderedCollection withAll:aCollectionOfPathes.
 
@@ -370,6 +596,16 @@
     "
 !
 
+javaBinDirOnUNIX
+
+    ^ self jreHome / 'bin'
+!
+
+javaBinDirOnWindows
+
+    ^ self jreHome / 'bin'
+!
+
 javaBundle
     "Returns bundle representing Java code (both core + extections)"
 
@@ -385,6 +621,49 @@
     "Created: / 12-02-2013 / 14:56:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+javaExecutable: aStringOrFilename
+    self javaHome: (self javaHomeForJavaExecutable: aStringOrFilename)
+
+    "Created: / 17-04-2014 / 20:04:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaExecutableForJavaHome: javaHomeArg
+    "For given java home (path to JRE root if JRE, or JDK root if part of full JDK) return
+     path to java executable (java.exe on Windows, java on UNIX). If no executable is found
+     in given root, return nil."
+
+    | javaHomeDirectory javaExecutableName javaExecutable |
+
+    "/ By default, java executable is either in <jdk root>/jre/bin or
+    "/ <jre root>/bin. So far only AppleJDK is different...
+
+    javaHomeArg isNil ifTrue:[ ^ nil ].
+    javaHomeDirectory := javaHomeArg asFilename asAbsoluteFilename.
+    javaHomeDirectory exists ifFalse:[ ^ nil ].
+    javaHomeDirectory isDirectory ifFalse:[ ^ nil ].
+    javaExecutableName := OperatingSystem isMSWINDOWSlike ifTrue:[ 'java.exe' ] ifFalse:[ 'java' ].
+
+    "/ Try JDK...
+    javaExecutable := javaHomeDirectory / 'jre' / 'bin' / javaExecutableName.
+    javaExecutable exists ifTrue:[ ^ javaExecutable ].
+
+    "/ Try JRE...
+    javaExecutable := javaHomeDirectory / 'bin' / javaExecutableName.
+    javaExecutable exists ifTrue:[ ^ javaExecutable ].
+
+    ^ nil
+
+    "
+    JavaRelease basicNew javaExecutableForJavaHome: (OperatingSystem pathOfCommand:'java') asFilename directory directory.
+    JavaRelease basicNew javaExecutableForJavaHome: '/usr/lib/jvm/java-7-openjdk-amd64/jre'
+    JavaRelease basicNew javaExecutableForJavaHome: '/usr/lib/jvm/java-7-openjdk-amd64'
+    JavaRelease basicNew javaExecutableForJavaHome: 'xxxx'
+    JavaRelease basicNew javaExecutableForJavaHome: '/usr/bin'
+    "
+
+    "Created: / 08-04-2014 / 14:44:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 javaExtDirs
 
     "Returns a default value of java.ext.dirs property"
@@ -453,30 +732,85 @@
     "Modified: / 11-02-2013 / 02:58:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-javaHomeOrNil
-
-    "Answer a Java home"
-
-    | home |
-    home := (javaHome
-                ifNotNil:[javaHome]
-                ifNil:[self searchForJavaHome]).
-    ^home
+javaHomeForJavaExecutable: javaExecutable
+    "For given java executable (java.exe on Windows, java on UNIX) return
+     a Java home (path to JRE root (if JRE) or JDK root (if part of full JDK).
+     Upon failure (executable does not seem to be a part of JRE nor JDK), return
+     nil."
+
+    | javaExecutableFilename dir |
+
+    "/ By default, java executable is either in <jdk root>/jre/bin or
+    "/ <jre root>/bin. So far only AppleJDK is different...
+
+    javaExecutable isNil ifTrue:[ ^ nil ].
+    javaExecutableFilename := javaExecutable asFilename asAbsoluteFilename.
+    javaExecutableFilename exists ifFalse:[ ^ nil ].
+    javaExecutableFilename isExecutable ifFalse:[ ^ nil ].
+    dir := javaExecutableFilename directory.
+    dir baseName ~= 'bin' ifTrue:[ ^ nil ].
+    dir := dir directory.
+    ^ dir baseName = 'jre' ifTrue:[ dir directory pathName ] ifFalse:[ dir pathName]
 
     "
-        JavaRelease openJDK6 javaHome
+    JavaRelease basicNew javaHomeForJavaExecutable: (OperatingSystem pathOfCommand:'java')
+    JavaRelease basicNew javaHomeForJavaExecutable: '/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'
+    JavaRelease basicNew javaHomeForJavaExecutable: 'xxxx'
+    JavaRelease basicNew javaHomeForJavaExecutable: '/usr'
     "
 
+    "Created: / 08-04-2014 / 14:21:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-12-2014 / 00:16:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaHomeOnWindowsFromRegistryForRelease: vsn
+    "Return path to java home (either JDK or JRE) based on values in registry.
+     If not on windows or registry key not found, return nil"
+
+    |entry home |
+
+    OperatingSystem isMSWINDOWSlike ifFalse:[ ^ nil ].
+    "Search for JDK first..."
+    entry := (OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\', vsn).
+    entry notNil ifTrue:[
+        home := entry valueNamed:'JavaHome'.
+        (home notNil and:[(home := home asFilename) exists]) ifTrue:[ ^ home ].
+    ].
+    "Search for JRE...."
+    entry := (OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\', vsn).
+    entry notNil ifTrue:[
+        home := entry valueNamed:'JavaHome'.
+        (home notNil and:[(home := home asFilename) exists]) ifTrue:[ ^ home ].
+    ].
+
+    ^nil
+
+    "Created: / 16-02-2013 / 02:52:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-02-2013 / 03:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaHomeOrNil
+    "Answer a Java home"
+    
+    | home |
+
+    home := javaHome isNil ifTrue:[ self searchForJavaHome ] ifFalse:[ javaHome ].
+    ^ home
+
+    "
+        JavaRelease openJDK6 javaHome"
+
     "Created: / 22-11-2010 / 13:17:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2014 / 15:51:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 javaHomes
 
     "Answer a set of possible java homes, those directories are searched"
 
-    OperatingSystem isUNIXlike ifTrue:[ 
+    OperatingSystem isUNIXlike ifTrue:[
         OperatingSystem isOSXlike ifTrue:[ ^ self javaHomesOnOSX ].
-        ^ self javaHomesOnUNIX 
+        ^ self javaHomesOnUNIX
     ].
     OperatingSystem isMSWINDOWSlike ifTrue:[ ^ self javaHomesOnWindows ].
     self error:'Unsupported platform'.
@@ -502,6 +836,28 @@
     ^ self subclassResponsibility
 !
 
+javaLibDir
+    OperatingSystem isMSWINDOWSlike ifTrue:[
+        ^ self javaLibDirOnWindows
+    ].
+    ^ self javaLibDirOnUnix
+!
+
+javaLibDirOnUnix
+
+    ^ self jreHome / self libDirInJreHome
+!
+
+javaLibDirOnWindows
+
+    ^ self jreHome / self libDirInJreHome
+!
+
+javaNativeLibDirOnUnix
+
+    ^ self jreHome / self nativeLibDirInJreHome
+!
+
 javaNativeMethodsImplementation
     "Returns an object that imolements native methods."
 
@@ -529,17 +885,25 @@
     "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';
+     but under max-osx, this is 'Libraries' - sigh"
+
+    ^ 'lib'
+!
+
 jreHome
 
     "Answers the directory where the JRE lives"
 
-    | jreHome |
-
-    self javaHome isNil ifTrue:[ ^ nil ].
-
-    ^(jreHome := self javaHome asFilename / 'jre') exists
+    | javaHome jreHome |
+
+    (javaHome := self javaHome) isNil ifTrue:[ ^ nil ].
+    javaHome := javaHome asFilename.
+    ^(jreHome := javaHome / 'jre') exists
         ifTrue:[jreHome]
-        ifFalse:[javaHome asFilename].
+        ifFalse:[javaHome].
 
     "Created: / 27-10-2010 / 21:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
@@ -569,6 +933,14 @@
     ^ 'rt.jar'
 !
 
+nativeLibDirInJreHome
+    "Returns the relative path to the native lib directory, relative to the jreHome.
+     For all 'normal' systems, this is 'lib';
+     but under max-osx, this is 'Libraries' - sigh"
+
+    ^ 'lib'
+!
+
 priority
 
     ^50
@@ -586,44 +958,64 @@
 !
 
 sourcePath
-
     "Returns a paths where sources are located"
-
-    sourcePath ifNil:[self searchForSourcePath].
-    ^sourcePath
+    
+    sourcePath isNil ifTrue:[
+        self searchForSourcePath
+    ].
+    ^ sourcePath
 
     "
         JavaRelease openJDK6 sourcePath
-    "
+        JavaRelease appleJDK6 sourcePath"
 
     "Created: / 27-10-2010 / 19:20:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 30-11-2010 / 11:55:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-08-2014 / 15:55:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease methodsFor:'comparing'!
+
+= anotherRelease
+    ^ self class == anotherRelease class
+        and:[self javaHome = anotherRelease javaHome]
+
+    "
+        JavaRelease system = JavaRelease JDK7
+        JavaRelease system hash = JavaRelease JDK7 hash
+    "
+
+    "Created: / 11-11-2013 / 15:56:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hash
+    ^ self class hash bitXor:javaHome hash
+
+    "Created: / 11-11-2013 / 15:55:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease methodsFor:'debugging'!
 
 dumpConfigOn: stream
-
     | dumper |
-    dumper := [:name :value :isfile|
-        | values |
-
-        '%-30s : ' printf:{ name } on: stream.
-        value isString
-            ifTrue:[values := { value asString }]
-            ifFalse:[values := value].
-        values do:[:v|
-            stream nextPutAll: v asString.
-            isfile ifTrue:[
-                v asFilename exists ifFalse:[
-                    stream nextPutAll:' (not found!!!!!!)'
-                ].
-            ]
-        ] separatedBy:[stream cr; next: 30 + 3 put: Character space].
-        stream cr.
-    ].
-
-
+
+    dumper :=
+        [:name :value :isfile|
+            | values |
+
+            '%-30s : ' printf:{ name } on: stream.
+            value isString
+                ifTrue:[values := { value asString }]
+                ifFalse:[values := value].
+            values do:[:v|
+                stream nextPutAll: v asString.
+                isfile ifTrue:[
+                    v asFilename exists ifFalse:[
+                        stream nextPutAll:' (not found!!!!!!)'
+                    ].
+                ]
+            ] separatedBy:[stream cr; next: 30 + 3 put: Character space].
+            stream cr.
+        ].
 
     stream nextPutAll: '== Java release config =='; cr.
     dumper value: 'name' value: self name value: false.
@@ -633,7 +1025,6 @@
     dumper value: 'boot class path' value: self bootClassPath value: true.
     dumper value: 'ext dirs' value: self javaExtDirs value: true.
 
-
     "
         Java release dumpConfigOn: Transcript.
     "
@@ -645,70 +1036,31 @@
 !JavaRelease methodsFor:'displaying'!
 
 displayString
-    ^self name
+    | displayString available |
+
+    available := self isAvailable.
+
+    available ifTrue:[ 
+        displayString := '%1 (%2%3)' bindWith: self name
+                                         with: (self jdkHome notNil ifTrue:[ 'JDK' ] ifFalse:[ 'JRE' ])
+                                         with: (self isSystem ifTrue:[ ', system' ] ifFalse:[ '' ]).
+        self isSystem ifTrue:[ 
+            displayString := displayString asText allUnderlined.
+        ].
+    ] ifFalse:[ 
+        displayString := self name.
+    ].
+    available ifTrue: [
+        displayString := displayString , ((' - ', self javaHome asFilename pathName) asText colorizeAllWith: Color gray).
+    ] ifFalse: [ 
+        displayString := displayString , ((self class classResources string: ' - not found') asText colorizeAllWith: Color gray).
+    ].
+
+    ^ displayString
 
     "Created: / 27-07-2012 / 00:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!JavaRelease methodsFor:'initialization'!
-
-initializeBootClassPathIndex
-    bootClassPathClasses := IdentitySet new.
-    self bootClassPath do: [:file |
-        | filename |
-
-        filename := file asFilename.
-
-        self assert: (filename suffix = 'jar').
-        self assert: (filename exists).
-        self selectAllClassNamesIn: file to: bootClassPathClasses.
-    ].
-
-    "Created: / 02-11-2011 / 12:12:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 19-07-2012 / 11:02:41 / jv"
-    "Modified: / 23-01-2013 / 17:24:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-initializeClassIndex
-    | jreHome |
-
-    (jreHome := self jreHome) isNil ifTrue:[ ^ self ].
-    classes := IdentitySet new.
-
-    self jreHome recursiveDirectoryContents do: [
-        :each |
-        (each endsWith: '.class') ifTrue: [
-            classes add: each asSymbol.
-        ].
-        (each endsWith: '.jar') ifTrue: [ self selectAllClassNamesIn: (self jreHome asFilename / each asFilename) to: classes. ]
-    ].
-
-    "Created: / 01-11-2011 / 14:09:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 27-07-2012 / 13:59:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-initializeExtDirsIndex
-    extDirsClasses := IdentitySet new.
-    self javaExtDirs do: [
-        :dir |
-        dir exists ifFalse: [
-            Logger
-                log: dir pathName
-                        , ', included in JavaRelease>>javaExtDirs, does not exist'
-                severity: #info
-                facility: 'JVM'
-        ] ifTrue: [
-            dir recursiveDirectoryContents do: [
-                :filename |
-                (filename endsWith: '.class') ifTrue: [ extDirsClasses add: filename asSymbol ].
-                (filename endsWith: '.jar') ifTrue: [
-                    self selectAllClassNamesIn: dir asFilename / filename asFilename to: extDirsClasses
-                ].
-            ]
-        ].
-    ].
-
-    "Created: / 02-11-2011 / 12:12:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 07-12-2014 / 13:31:42 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+    "Modified: / 09-12-2014 / 14:09:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease methodsFor:'object conversions'!
@@ -743,7 +1095,7 @@
     src := self sourcePath detect:[:e|e endsWith: 'src.zip'] ifNone:[nil].
     b := JavaCodeBundle new name: 'Runtime Library'.
     self bootClassPath do:[:each|
-        b add: (JavaCodeLibrary new 
+        b add: (JavaCodeLibrary new
                 name: (each copyFrom: (each lastIndexOf: Filename separator) + 1);
                 classes: each;
                 sources: src;
@@ -766,7 +1118,7 @@
         ext exists ifTrue:[
             ext directoryContentsAsFilenamesDo:[:each|
                 each suffix = 'jar' ifTrue:[
-                    b add: (JavaCodeLibrary new 
+                    b add: (JavaCodeLibrary new
                             name: each baseName;
                             classes: each pathName;
                             sources: src;
@@ -780,71 +1132,35 @@
     "Created: / 12-02-2013 / 14:57:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-searchInternalIndex: anIdentityCollection for: className
-    | classFileName |
-    classFileName := (className asSlashedJavaClassName) asSymbol.
-    ^ anIdentityCollection includes: classFileName asSymbol.
-
-    "Created: / 02-11-2011 / 12:27:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-selectAllClassNamesIn: jarArchiveName to: anIdentityCollection
-    | jar  classesInJar |
-    jar := ZipArchive readingFrom: jarArchiveName asFilename readStream.
-    classesInJar := jar entries select: [:each | each endsWith: '.class'. ].
-    classesInJar do: [:each |
-        anIdentityCollection add: (each copyFrom: 1 to: each size - 6) asSymbol
+jdkBundle
+    | src b jdk lib|
+
+    (jdk := self jdkHome) isNil ifTrue:[ ^ nil ].
+    src := self sourcePath detect:[:e|e asFilename pathName endsWith: 'src.zip'] ifNone:[nil].
+    b := JavaCodeBundle new name: 'JDK'.
+    lib := jdk asFilename / 'lib'.
+    lib exists ifTrue:[
+        lib directoryContentsAsFilenamesDo:[:each|
+            each suffix = 'jar' ifTrue:[
+                b add: (JavaCodeLibrary new
+                        name: each baseName;
+                        classes: each pathName;
+                        sources: src;
+                        yourself)
+            ]
+        ].
     ].
+    ^b
 
     "
-     JavaRelease any."
-
-    "Created: / 02-11-2011 / 12:17:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified (format): / 02-11-2011 / 23:34:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-updateClassIndexFrom: jarArchiveName
-    | jar  classesInJar |
-    jar := ZipArchive
-                readingFrom: (self jreHome asFilename / jarArchiveName asFilename)
-                        readStream.
-    classesInJar := jar entries select: [:each | each endsWith: '.class'. ].
-    classesInJar do: [:each | classes add: each asSymbol].
-
+        Java release jdkBundle
     "
-     JavaRelease any."
-
-    "Created: / 01-11-2011 / 14:18:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+
+    "Created: / 11-11-2013 / 15:32:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease methodsFor:'queries'!
 
-bootClassPathIncludesClassNamed: className
-    bootClassPathClasses isNil ifTrue:[self initializeBootClassPathIndex].
-    ^ self searchInternalIndex: bootClassPathClasses for: className.
-
-    "Created: / 02-11-2011 / 12:11:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 31-07-2012 / 18:00:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-extDirsIncludesClassNamed: className
-    "Looks like a bug, shouldn't it look to extDirClasses?"
-
-    classes isNil ifTrue:[self initializeClassIndex].
-    ^self searchInternalIndex: classes for: className.
-
-    "Created: / 02-11-2011 / 12:11:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified (comment): / 31-07-2012 / 18:00:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-includesClassNamed: className
-    classes isNil ifTrue:[self initializeClassIndex].
-    ^self searchInternalIndex: classes for: className.
-
-    "Created: / 01-11-2011 / 14:50:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 31-07-2012 / 17:58:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 isAvailable
 
     ^self javaHomeOrNil notNil
@@ -864,6 +1180,16 @@
     "Modified (comment): / 12-02-2013 / 03:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+isAvailableOnCurrentOperatingSystem
+    "Return if at all available for current operating system.
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows.
+    "
+
+    ^self subclassResponsibility
+
+    "Created: / 07-12-2014 / 23:55:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 isCustom
     ^false
 
@@ -889,7 +1215,7 @@
         (self validateJavaHome: h) ifTrue:[ javaHome := h. ^ javaHome ].
     ].
 
-    self javaHomes do: [:home| 
+    self javaHomes do: [:home|
         | homeAsFilename |
 
         homeAsFilename := home asFilename.
@@ -932,17 +1258,54 @@
     "Modified: / 12-01-2013 / 15:55:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaRelease methodsFor:'testing'!
+
+isJava6
+    ^ false
+
+    "Created: / 04-10-2013 / 11:10:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isJava7
+    ^ false
+
+    "Created: / 04-10-2013 / 11:11:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isJava8
+    ^ false
+
+    "Created: / 03-04-2014 / 12:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isSystem
+    ^ self == self class system
+
+    "Created: / 15-04-2014 / 18:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-12-2014 / 00:21:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaRelease methodsFor:'validating'!
 
+validateJavaExecutable: javaExecutable
+    "Validates given java executable (java.exe on Windows, java on UNIX).
+     Return true, if given executable represents same version as receiver,
+     false otherwise."
+
+    ^ self validateJavaHome: (self javaHomeForJavaExecutable: javaExecutable)
+
+    "Created: / 08-04-2014 / 14:13:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 validateJavaHome1: home
 
     home isNil ifTrue:[ ^ false ].
 
     "Just JRE"
-    ( home  asFilename / (self libDirInJreHome) / (self nameOf_rt_dot_jar) ) exists ifTrue:[^true].
+    ( home  asFilename / 'lib' / self nameOf_rt_dot_jar ) exists ifTrue:[^true].
 
     "Full JDK"
-    ( home asFilename / 'jre' / (self libDirInJreHome) / (self nameOf_rt_dot_jar) ) exists ifTrue:[^true].
+    ( home asFilename / 'jre' / 'lib' / self nameOf_rt_dot_jar ) exists ifTrue:[^true].
 
     ^ false
 
@@ -961,8 +1324,22 @@
 !
 
 validateJavaHome: home
-
-    ^(self validateJavaHome1: home) and:[self  validateJavaHome2: home]
+    | javaBinary javaVersionStream javaVersionString |
+
+    (self validateJavaHome1: home) ifFalse:[ ^ false ].
+
+    javaBinary := self javaExecutableForJavaHome: home.
+    javaBinary isExecutable ifFalse:[ ^ false ].
+    javaVersionStream := String new writeStream.
+    OperatingSystem executeCommand: '"' , javaBinary pathName , '" -version' outputTo: javaVersionStream.
+    javaVersionString := javaVersionStream contents.
+
+    (self validateJavaVersionString: javaVersionString) ifFalse:[ ^ false ].
+
+    ^ true.
+
+
+
 
 
     "
@@ -971,7 +1348,7 @@
     "
 
     "Created: / 27-10-2010 / 19:14:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-02-2013 / 02:51:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-04-2014 / 14:50:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 validateJavaVersionString:aVersionString
@@ -985,11 +1362,11 @@
 
 copyright
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -1008,7 +1385,7 @@
 !
 
 version_SVN
-    ^ '$Id: JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ 'Id::                                                                                                                        '
 ! !
 
 !JavaRelease::OpenJDK6 class methodsFor:'queries'!
@@ -1022,7 +1399,7 @@
 javaExtDirsOnUNIX
 
     ^{
-        self jreHome asFilename / 'lib' / 'ext' .
+        self jreHome asFilename / self libDirInJreHome / 'ext' .
         '/usr/java/packages/lib/ext' asFilename
     }
 
@@ -1033,7 +1410,7 @@
 javaExtDirsOnWindows
 
     ^{
-        self jreHome asFilename / 'lib' / 'ext' .
+        self jreHome asFilename / self libDirInJreHome / 'ext' .
     }
 
     "Created: / 31-08-2011 / 20:02:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1045,6 +1422,7 @@
 
     arch := OperatingSystem getSystemInfo at:#machine.
     arch = 'x86_64' ifTrue:[arch := 'amd64'].
+    arch = 'i686' ifTrue:[arch := 'i386'].
 
     ^ {
         '/usr/lib/jvm/java-6-openjdk-',arch.        "/ JDK - newer linuxes
@@ -1077,15 +1455,6 @@
     "Modified: / 16-01-2013 / 19:59:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-jreHome
-    "Answers the directory where the JRE lives"
-
-    OperatingSystem isOSXlike ifTrue:[
-        ^ '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk' asFilename.
-    ].
-    ^ super jreHome
-!
-
 name
     "superclass JavaRelease says that I am responsible to implement this method"
 
@@ -1178,6 +1547,18 @@
     "Modified: / 08-02-2013 / 00:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaRelease::OpenJDK6 methodsFor:'queries'!
+
+isAvailableOnCurrentOperatingSystem
+    "Return if at all available for current operating system.
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows."
+
+    "/ Q: Is OpenJDK available on OS/X?
+    ^ OperatingSystem isUNIXlike and:[ OperatingSystem isOSXlike not ]
+
+    "Created: / 07-12-2014 / 23:56:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaRelease::OpenJDK6 methodsFor:'searching'!
 
 searchForSourcePath
@@ -1196,9 +1577,9 @@
     "
         JavaRelease openJDK7 searchForSourcePath; sourcePath
         JavaRelease sunJDK6 searchForSourcePath; sourcePath
-        JavaRelease openJDK6 searchForSourcePath; sourcePath  
-        JavaRelease openJDK6 jdkHome  
-        JavaRelease openJDK6 jreHome  
+        JavaRelease openJDK6 searchForSourcePath; sourcePath
+        JavaRelease openJDK6 jdkHome
+        JavaRelease openJDK6 jreHome
     "
 
     "Created: / 03-09-2012 / 18:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1206,11 +1587,19 @@
     "Modified (comment): / 06-02-2013 / 12:55:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaRelease::OpenJDK6 methodsFor:'testing'!
+
+isJava6
+    ^ true
+
+    "Created: / 04-10-2013 / 11:11:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaRelease::OpenJDK6 methodsFor:'validating'!
 
 validateJavaHome2: home
     "Bit of a hack, but..."
-    ^OperatingSystem isUNIXlike 
+    ^OperatingSystem isUNIXlike
         and: [(home asString includesString: 'oracle') not
         and: [(home asString includesString: 'sun') not]]
 
@@ -1222,18 +1611,324 @@
     "Return true if aVersionString (which is what 'java -version' returns)
      matches what I expect."
 
-    ^ aVersionString matches: 'java version "1.6.*'
+    ^ aVersionString matches: 'java version "1.6.*OpenJDK Runtime Environment*'
+
+    "Modified: / 03-04-2014 / 12:50:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::AppleJDK6 class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 2014 by Claus Gittinger
+"
+!
+
+documentation
+"
+    JDK6 as installed on a mac, running osx
+"
+! !
+
+!JavaRelease::AppleJDK6 class methodsFor:'queries'!
+
+isJDK6
+    ^ true
+! !
+
+!JavaRelease::AppleJDK6 methodsFor:'accessing'!
+
+javaExtDirsOnUNIX
+
+    ^{
+        self jreHome asFilename / 'Extensions' .
+    }
+!
+
+javaExtDirsOnWindows
+    "/ never exists on windows
+    ^ #()
+!
+
+javaHomesOnOSX
+    ^ {
+        '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents' .
+        '/System/Library/Java'
+      }
+
+    "
+    JavaRelease::OsxJDK6 new javaHomesOnUNIX
+    "
+!
+
+javaHomesOnWindows
+    "/ never exists on windows
+    ^ #()
+!
+
+javaNativeMethodsImplementation
+    "Returns an object that imolements native methods."
+
+    ^ 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';
+     but under max-osx, this is 'Classes' - sigh"
+
+    ^ 'Libraries'
+!
+
+jreHome
+    "Answers the directory where the JRE lives"
+
+    OperatingSystem isOSXlike ifTrue:[
+        ^ '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents' asFilename.
+    ].
+    ^ super jreHome
+!
+
+libDirInJreHome
+    "Returns the relative path to the lib directory, relative to the jreHome.
+     For all 'normal' systems, this is 'lib';
+     but under max-osx, this is 'Classes' - sigh"
+
+    ^ 'Classes'
+!
+
+name
+    "superclass JavaRelease says that I am responsible to implement this method"
+
+    ^ 'Apple Java 6'
+
+    "Modified: / 15-04-2014 / 18:50:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-12-2014 / 13:09:34 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+nameOf_rt_dot_jar
+    "Returns the name of the class library.
+     For all 'normal' systems, this is 'rt.jar';
+     but under max-osx, this is 'classes.jar' - sigh"
+
+    ^ 'classes.jar'
+!
+
+nativeLibDirInJreHome
+    "Returns the relative path to the lib directory, relative to the jreHome.
+     For all 'normal' systems, this is 'lib';
+     but under max-osx, this is 'Classes' - sigh"
+
+    ^ 'Libraries'
+!
+
+priority
+    OperatingSystem isOSXlike ifTrue:[^ 100].
+    ^80
+    "/^70
+
+    "Created: / 22-11-2010 / 13:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-02-2011 / 06:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+selector
+    "Returns instance-creation selector to get the receiver.
+     See JavaRelease class, protocol instance creation"
+
+    ^#osxJDK6
+! !
+
+!JavaRelease::AppleJDK6 methodsFor:'queries'!
+
+isAvailableOnCurrentOperatingSystem
+    "Return if at all available for current operating system.
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows."
+
+    ^ OperatingSystem isOSXlike
+
+    "Created: / 07-12-2014 / 23:57:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::AppleJDK6 methodsFor:'searching'!
+
+javaExecutableForJavaHome: javaHomeArg
+    "For given java home (path to JRE root if JRE, or JDK root if part of full JDK) return
+     path to java executable (java.exe on Windows, java on UNIX). If no executable is found
+     in given root, return nil."
+
+    | javaHomeDirectory javaExecutableName javaExecutable |
+
+    "/ By default, java executable is either in <jdk root>/jre/bin or
+    "/ <jre root>/bin. So far only AppleJDK is different...
+
+    javaHomeArg isNil ifTrue:[ ^ nil ].
+    javaHomeDirectory := javaHomeArg asFilename asAbsoluteFilename.
+    javaHomeDirectory exists ifFalse:[ ^ nil ].
+    javaHomeDirectory isDirectory ifFalse:[ ^ nil ].
+    javaExecutableName := OperatingSystem isMSWINDOWSlike ifTrue:[ 'java.exe' ] ifFalse:[ 'java' ].
+
+    javaExecutable := javaHomeDirectory / 'Commands' / javaExecutableName.
+    javaExecutable exists ifTrue:[ ^ javaExecutable ].
+
+    ^ nil
+
+    "
+    JavaRelease basicNew javaExecutableForJavaHome: (OperatingSystem pathOfCommand:'java') asFilename directory directory.
+    JavaRelease basicNew javaExecutableForJavaHome: '/usr/lib/jvm/java-7-openjdk-amd64/jre'
+    JavaRelease basicNew javaExecutableForJavaHome: '/usr/lib/jvm/java-7-openjdk-amd64'
+    JavaRelease basicNew javaExecutableForJavaHome: 'xxxx'
+    JavaRelease basicNew javaExecutableForJavaHome: '/usr/bin'
+    "
+
+    "Created: / 08-04-2014 / 14:44:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaHomeForJavaExecutable: javaExecutable
+    "For given java executable (java.exe on Windows, java on UNIX) return
+     a Java home (path to JRE root (if JRE) or JDK root (if part of full JDK).
+     Upon failure (executable does not seem to be a part of JRE nor JDK), return
+     nil."
+
+    | javaExecutableFilename jdk|
+
+    "/ By default, java executable is either in <jdk root>/jre/bin or
+    "/ <jre root>/bin. So far only AppleJDK is different...
+
+    javaExecutable isNil ifTrue:[ ^ nil ].
+    javaExecutableFilename := javaExecutable asFilename asAbsoluteFilename.
+    javaExecutableFilename exists ifFalse:[ ^ nil ].
+    javaExecutableFilename isExecutable ifFalse:[ ^ nil ].
+
+    jdk := '/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK' asFilename.
+    jdk exists ifFalse:[^ nil].
+
+    (jdk construct:'Classes') exists ifFalse:[^ nil].
+    (jdk construct:'Classes/classes.jar') exists ifFalse:[^ nil].
+    ^ jdk pathName
+
+    "
+    JavaRelease basicNew javaHomeForJavaExecutable: (OperatingSystem pathOfCommand:'java')
+    JavaRelease basicNew javaHomeForJavaExecutable: '/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'
+    JavaRelease basicNew javaHomeForJavaExecutable: 'xxxx'
+    JavaRelease basicNew javaHomeForJavaExecutable: '/usr'
+    "
+
+    "Created: / 08-04-2014 / 14:21:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-12-2014 / 00:17:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+searchForSourcePath
+    | 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.
+            path add:src_jar pathName.
+        ].
+    ].
+    super searchForSourcePath.
+    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>"
+    "Modified: / 23-01-2013 / 12:22:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 06-02-2013 / 12:55:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+validateJavaHome1: home
+
+    home isNil ifTrue:[ ^ false ].
+
+    ( home  asFilename / 'Classes' / self nameOf_rt_dot_jar ) exists ifTrue:[^true].
+
+    ^ false
+
+    "
+        JavaRelease basicNew validateJavaHome: '/usr/lib/jvm/java-6-openjdk'
+        JavaRelease basicNew validateJavaHome: '/tmp'
+    "
+
+    "Created: / 12-02-2013 / 02:50:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::AppleJDK6 methodsFor:'validating'!
+
+validateJavaHome2: home
+    ^ true
+!
+
+validateJavaVersionString:aVersionString
+    "Return true if aVersionString (which is what 'java -version' returns)
+     matches what I expect."
+
+    ^ aVersionString matches: '*java version "1.6.*'
 ! !
 
 !JavaRelease::OpenJDK7 class methodsFor:'documentation'!
 
 copyright
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -1252,11 +1947,15 @@
 !
 
 version_SVN
-    ^ '$Id: JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ 'Id::                                                                                                                        '
 ! !
 
 !JavaRelease::OpenJDK7 class methodsFor:'queries'!
 
+isJDK6
+    ^ false
+!
+
 isJDK7
     ^ true
 ! !
@@ -1310,12 +2009,10 @@
 !
 
 priority
-
-    ^ super priority - 10
-    "/^70
-
-    "Modified: / 04-02-2011 / 06:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ super priority + 10
+
     "Created: / 11-02-2012 / 17:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-11-2013 / 14:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 selector
@@ -1367,24 +2064,152 @@
     "Modified: / 13-06-2013 / 09:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaRelease::OpenJDK7 methodsFor:'searching'!
+
+searchForSourcePath
+
+    | jdkHome jdkHomeAlt src_zip |
+
+    super searchForSourcePath.
+
+    "/ Kludge for Debian packages. On Debian boxes
+    "/ package openjdk-7-source installs src.zip into
+    "/ `/usr/lib/jvm/java-7-openjdk-i386` instead of
+    "/ into
+    "/ `/usr/lib/jvm/java-7-openjdk-common`
+
+    jdkHome := self jdkHome asString.
+    (jdkHome endsWith: 'amd64') ifTrue:[
+        jdkHomeAlt := ((jdkHome copyTo: jdkHome size - 5) , 'i386').
+        src_zip := jdkHomeAlt asFilename / 'src.zip'.
+        src_zip exists ifTrue:[
+            sourcePath add: src_zip pathName.
+        ].
+    ].
+
+
+    "
+        JavaRelease openJDK7 searchForSourcePath; sourcePath
+        JavaRelease sunJDK6 searchForSourcePath; sourcePath
+        JavaRelease openJDK6 searchForSourcePath; sourcePath
+        JavaRelease openJDK6 jdkHome
+        JavaRelease openJDK6 jreHome
+    "
+
+    "Created: / 12-02-2014 / 10:15:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OpenJDK7 methodsFor:'testing'!
+
+isJava6
+    ^ false
+
+    "Created: / 04-10-2013 / 11:11:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isJava7
+    ^ true
+
+    "Created: / 04-10-2013 / 11:11:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaRelease::OpenJDK7 methodsFor:'validating'!
 
 validateJavaVersionString:aVersionString
     "Return true if aVersionString (which is what 'java -version' returns)
      matches what I expect."
 
-    ^ aVersionString matches: 'java version "1.7.*' 
+    ^ aVersionString matches: '*java version "1.7.*OpenJDK Runtime Environment*'
+
+    "Modified: / 03-04-2014 / 12:52:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OpenJDK8 class methodsFor:'queries'!
+
+isJDK7
+    ^ false
+
+    "Created: / 03-04-2014 / 12:35:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isJDK8
+    ^ true
+
+    "Created: / 03-04-2014 / 12:35:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OpenJDK8 methodsFor:'accessing'!
+
+javaHomesOnUNIX
+    | arch |
+
+    arch := OperatingSystem getSystemInfo at:#machine.
+    arch = 'x86_64' ifTrue:[arch := 'amd64'].
+    arch = 'i686' ifTrue:[arch := 'i386'].
+
+    ^ {
+        '/usr/lib/jvm/java-8-openjdk-',arch.        "/ JDK - newer linuxes
+        '/usr/lib/jvm/java-8-openjdk'  .            "/ JDK - older linuxes
+
+        '/usr/lib/jvm/java-8-openjdk-',arch, '/jre'."/ JRE - newer linuxes
+        '/usr/lib/jvm/java-8-openjdk/jre'  .        "/ JRE - older linuxes
+    }
+
+    "
+    JavaRelease::OpenJDK7 new javaHomesOnUNIX
+    "
+
+    "Created: / 03-04-2014 / 12:30:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+javaNativeMethodsImplementation
+    "Returns an object that imolements native methods."
+
+    ^ JavaNativeMethodImpl_OpenJDK8
+
+    "Created: / 03-04-2014 / 12:19:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+name
+    ^ 'Open JDK 8'
+
+    "Created: / 03-04-2014 / 12:14:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OpenJDK8 methodsFor:'testing'!
+
+isJava7
+    ^ false
+
+    "Created: / 03-04-2014 / 12:14:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isJava8
+    ^ true
+
+    "Created: / 03-04-2014 / 12:14:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OpenJDK8 methodsFor:'validating'!
+
+validateJavaVersionString:aVersionString
+    "Return true if aVersionString (which is what 'java -version' returns)
+     matches what I expect."
+
+    ^ aVersionString matches: '*java version "1.8.*OpenJDK Runtime Environment*'
+
+    "Created: / 03-04-2014 / 12:32:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease::OracleJDK6 class methodsFor:'documentation'!
 
 copyright
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -1403,39 +2228,11 @@
 !
 
 version_SVN
-    ^ '$Id: JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ 'Id::                                                                                                                        '
 ! !
 
 !JavaRelease::OracleJDK6 methodsFor:'accessing'!
 
-javaHomeOnWindowsFromRegistry
-    "Return path to java home (either JDK or JRE) based on values in registry.
-     If not on windows or registry key not found, return nil"
-
-    |entry vsn home |
-
-    OperatingSystem isMSWINDOWSlike ifFalse:[ ^ nil ].
-    vsn := '1.6'.
-
-    "Search for JDK first..."
-    entry := (OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\', vsn).
-    entry notNil ifTrue:[
-        home := entry valueNamed:'JavaHome'.
-        (home notNil and:[(home := home asFilename) exists]) ifTrue:[ ^ home ].
-    ].
-    "Search for JRE...."
-    entry := (OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\', vsn).
-    entry notNil ifTrue:[
-        home := entry valueNamed:'JavaHome'.
-        (home notNil and:[(home := home asFilename) exists]) ifTrue:[ ^ home ].
-    ].
-
-    ^nil
-
-    "Created: / 16-02-2013 / 02:52:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-02-2013 / 03:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 javaHomesOnUNIX
 
     ^ #( '/usr/lib/jvm/java-6-sun' )
@@ -1446,7 +2243,7 @@
 javaHomesOnWindows
     |home paths |
 
-    home := self javaHomeOnWindowsFromRegistry.
+    home := self javaHomeOnWindowsFromRegistryForRelease: '1.6'.       
     home notNil ifTrue:[ ^ Array with: home ].
 
     paths := OrderedCollection new.
@@ -1501,10 +2298,10 @@
 
 name
 
-    ^ 'Oracle JDK 6'
+    ^ 'Oracle Java 6'
 
     "Created: / 22-11-2010 / 13:31:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-02-2013 / 03:03:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-04-2014 / 18:49:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 priority
@@ -1543,13 +2340,25 @@
     "Created: / 21-02-2013 / 03:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaRelease::OracleJDK6 methodsFor:'queries'!
+
+isAvailableOnCurrentOperatingSystem
+    "Return if at all available for current operating system.
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows."
+
+    "/ Q: Is OpenJDK available on OS/X?
+    ^ true
+
+    "Created: / 07-12-2014 / 23:57:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaRelease::OracleJDK6 methodsFor:'searching'!
 
 searchForJavaHome
     | h |
 
     "Try registry first..."
-    h := self javaHomeOnWindowsFromRegistry.
+    h := self javaHomeOnWindowsFromRegistryForRelease: '1.6'.
     h notNil ifTrue:[ javaHome := h. ^ javaHome ].
     ^super searchForJavaHome
 
@@ -1568,28 +2377,28 @@
 validateJavaHome2: home
     | homeFromRegistry f |
 
-    homeFromRegistry := self javaHomeOnWindowsFromRegistry.
+    homeFromRegistry := self javaHomeOnWindowsFromRegistryForRelease: '1.6'.
     homeFromRegistry = home ifTrue:[ ^ true ].
 
     "JDK..."
-    (f := home / 'LICENSE') exists ifTrue:[
+    (f := home asFilename / 'LICENSE') exists ifTrue:[
         f readingFileDo:[:s|
             ((s nextLine = 'Please refer to http://java.com/license')
-                and:[(home / 'release') exists not
-                    and:[(home / 'THIRDPARTYLICENSEREADME-JAVAFX.txt') exists not]]) ifTrue:[ ^ true ]
+                and:[(home asFilename / 'release') exists not
+                    and:[(home asFilename / 'THIRDPARTYLICENSEREADME-JAVAFX.txt') exists not]]) ifTrue:[ ^ true ]
         ].
     ].
     "JRE..."
-    (f := home / 'COPYRIGHT') exists ifTrue:[
+    (f := home asFilename / 'COPYRIGHT') exists ifTrue:[
         f readingFileDo:[:s|
             (s nextLine includesString: 'Oracle') ifTrue:[
-                ^(home / 'LICENSE.txt') exists
+                ^(home asFilename / 'LICENSE.txt') exists
             ]
         ].
     ].
     ^false
 
-    
+
 
     "
         JavaRelease::OracleJDK6 new validateJavaHome: 'c:\Program Files\Java\jdk1.7.0_13' asFilename
@@ -1600,25 +2409,27 @@
     "
 
     "Created: / 12-02-2013 / 02:52:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 16-02-2013 / 02:54:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-11-2013 / 14:30:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 validateJavaVersionString:aVersionString
     "Return true if aVersionString (which is what 'java -version' returns)
      matches what I expect."
 
-    ^ aVersionString matches: 'java version "1.6.*' 
+    ^ aVersionString matches: '*java version "1.6.*Java(TM) SE Runtime Environment*'
+
+    "Modified: / 03-04-2014 / 16:49:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease::OracleJDK7 class methodsFor:'documentation'!
 
 copyright
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -1638,40 +2449,6 @@
 
 !JavaRelease::OracleJDK7 methodsFor:'accessing'!
 
-javaHomeOnWindowsFromRegistry
-    "Return path to java home (either JDK or JRE) based on values in registry.
-     If not on windows or registry key not found, return nil"
-
-    |entry vsn home prg|
-
-    OperatingSystem isMSWINDOWSlike ifFalse:[ ^ nil ].
-    vsn := '1.7'.
-
-    "Search for JDK first..."
-    entry := (OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\', vsn).
-    entry notNil ifTrue:[
-        home := entry valueNamed:'JavaHome'.
-        (home notNil and:[(home := home asFilename) exists]) ifTrue:[ ^ home ].
-    ].
-    "Search for JRE...."
-    entry := (OperatingSystem registryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\', vsn).
-    entry notNil ifTrue:[
-        home := entry valueNamed:'JavaHome'.
-        (home notNil and:[(home := home asFilename) exists]) ifTrue:[ ^ home ].
-    ].
-
-    (prg := OperatingSystem getEnvironment:'ProgramFiles(x86)') notEmptyOrNil ifTrue:[
-        (home := prg asFilename / 'Java' / 'jre7') exists ifTrue:[ ^ home ].
-    ].
-    (prg := OperatingSystem getEnvironment:'ProgramFiles') notEmptyOrNil ifTrue:[
-        (home := prg asFilename / 'Java' / 'jre7') exists ifTrue:[ ^ home ].
-    ].
-    ^nil
-
-    "Created: / 16-02-2013 / 02:52:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-02-2013 / 03:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 javaHomesOnUNIX
 
     ^ #( '/usr/lib/jvm/java-7-sun' )
@@ -1683,7 +2460,7 @@
 javaHomesOnWindows
     |home paths |
 
-    home := self javaHomeOnWindowsFromRegistry.
+    home := self javaHomeOnWindowsFromRegistryForRelease: '1.7'.
     home notNil ifTrue:[ ^ Array with: home ].
 
     paths := OrderedCollection new.
@@ -1731,31 +2508,31 @@
 javaNativeMethodsImplementation
     "Returns an object that imolements native methods."
 
-    ^ JavaNativeMethodImpl_SunJDK7
+    ^ JavaNativeMethodImpl_OracleJDK7
 
     "Created: / 06-02-2013 / 08:39:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 11-02-2013 / 02:50:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-04-2014 / 12:18:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 name
 
-    ^ 'Oracle JDK 7'
+    ^ 'Oracle Java 7'
 
     "Created: / 22-11-2010 / 13:31:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 12-02-2013 / 03:03:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-04-2014 / 18:50:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 priority
 
     "/There is no OpenJDK 6 for Windows yet...
     OperatingSystem isMSWINDOWSlike ifTrue:[
-        ^89
+        super priority
     ].
     ^65
 
     "Created: / 22-11-2010 / 13:35:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 19-07-2012 / 10:57:55 / jv"
-    "Modified: / 16-02-2013 / 09:19:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-11-2013 / 14:11:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 selector
@@ -1778,9 +2555,21 @@
 !
 
 javaHomeOnWindowsJREDirectoryPrefix
-    ^'jdk7'
+    ^'jre7'
 
     "Created: / 21-02-2013 / 03:19:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-04-2014 / 12:31:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OracleJDK7 methodsFor:'queries'!
+
+isAvailableOnCurrentOperatingSystem
+    "Return if at all available for current operating system.
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows."
+
+    ^ true
+
+    "Created: / 07-12-2014 / 23:57:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease::OracleJDK7 methodsFor:'searching'!
@@ -1789,7 +2578,7 @@
     | h |
 
     "Try registry first..."
-    h := self javaHomeOnWindowsFromRegistry.
+    h := self javaHomeOnWindowsFromRegistryForRelease: '1.7'.
     h notNil ifTrue:[ javaHome := h. ^ javaHome ].
     ^super searchForJavaHome
 
@@ -1806,28 +2595,29 @@
 !JavaRelease::OracleJDK7 methodsFor:'validating'!
 
 validateJavaHome2: home
-    | homeFromRegistry f |
-
-    homeFromRegistry := self javaHomeOnWindowsFromRegistry.
+    | homeFromRegistry f homeDir |
+
+    homeFromRegistry := self javaHomeOnWindowsFromRegistryForRelease: '1.7'.
     homeFromRegistry = home ifTrue:[ ^ true ].
+    homeDir :=  home asFilename.
 
     "JDK..."
-    (f := home / 'release') exists ifTrue:[
+    (f := homeDir / 'release') exists ifTrue:[
         f readingFileDo:[:s|
             s nextLine = 'JAVA_VERSION="1.7.0"' ifTrue:[ ^ true ]
         ].
     ].
     "JRE..."
-    (f := home / 'COPYRIGHT') exists ifTrue:[
+    (f := homeDir / 'COPYRIGHT') exists ifTrue:[
         f readingFileDo:[:s|
             (s nextLine includesString: 'Oracle') ifTrue:[
-                ^(home / 'THIRDPARTYLICENSEREADME-JAVAFX.txt') exists
+                ^(homeDir / 'THIRDPARTYLICENSEREADME-JAVAFX.txt') exists
             ]
         ].
     ].
     ^false
 
-    
+
 
     "
         JavaRelease::OracleJDK7 new validateJavaHome: 'c:\Program Files\Java\jdk1.7.0_13' asFilename
@@ -1838,240 +2628,142 @@
     "
 
     "Created: / 12-02-2013 / 02:52:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 16-02-2013 / 02:54:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-12-2013 / 15:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 25-01-2014 / 21:32:54 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
 !
 
 validateJavaVersionString:aVersionString
     "Return true if aVersionString (which is what 'java -version' returns)
      matches what I expect."
 
-    ^ aVersionString matches: 'java version "1.7.*' 
-! !
-
-!JavaRelease::OsxJDK6 class methodsFor:'documentation'!
-
-copyright
-"
- COPYRIGHT (c) 2014 by Claus Gittinger
-"
-!
-
-documentation
-"
-    JDK6 as installed on a mac, running osx
-"
-! !
-
-!JavaRelease::OsxJDK6 class methodsFor:'queries'!
-
-isJDK6
-    ^ true
+    ^ aVersionString matches: '*java version "1.7.*Java(TM) SE Runtime Environment*'
+
+    "Modified: / 03-04-2014 / 14:09:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-!JavaRelease::OsxJDK6 methodsFor:'accessing'!
-
-javaExtDirsOnUNIX
-
-    ^{
-        self jreHome asFilename / 'Extensions' .
-    }
-!
-
-javaExtDirsOnWindows
-    "/ never exists on windows
-    ^ #()
+!JavaRelease::OracleJDK8 class methodsFor:'queries'!
+
+isJDK7
+    ^ false
+
+    "Created: / 03-04-2014 / 12:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-javaHomesOnOSX
-    ^ {
-        '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents' .
-        '/System/Library/Java'
-      }
-
-    "
-    JavaRelease::OsxJDK6 new javaHomesOnUNIX
-    "
-!
-
-javaHomesOnWindows
-    "/ never exists on windows
-    ^ #()
+isJDK8
+    ^ true
+
+    "Created: / 03-04-2014 / 12:35:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OracleJDK8 methodsFor:'accessing'!
+
+javaHomesOnUNIX
+
+    ^ #( '/usr/lib/jvm/java-8-sun' )
+
+    "Created: / 03-04-2014 / 12:30:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 javaNativeMethodsImplementation
     "Returns an object that imolements native methods."
 
-    ^ JavaNativeMethodImpl_OpenJDK6
-
-    "Modified: / 16-01-2013 / 19:59:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-jreHome
-    "Answers the directory where the JRE lives"
-
-    OperatingSystem isOSXlike ifTrue:[
-        ^ '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents' asFilename.
-    ].
-    ^ super jreHome
-!
-
-libDirInJreHome
-    "Returns the relative path to the lib directory, relative to the jreHome.
-     For all 'normal' systems, this is 'lib';
-     but under max-osx, this is 'Classes' - sigh"
-
-    ^ 'Classes'
+    ^ JavaNativeMethodImpl_OracleJDK8
+
+    "Created: / 03-04-2014 / 12:19:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 name
-    "superclass JavaRelease says that I am responsible to implement this method"
-
-    ^ 'OSX JDK 6'
-
-    "Modified: / 27-10-2010 / 19:16:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-nameOf_rt_dot_jar
-    "Returns the name of the class library.
-     For all 'normal' systems, this is 'rt.jar';
-     but under max-osx, this is 'classes.jar' - sigh"
-
-    ^ 'classes.jar'
+    ^ 'Oracle Java 8'
+
+    "Created: / 03-04-2014 / 12:33:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-04-2014 / 18:50:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OracleJDK8 methodsFor:'private'!
+
+javaHomeOnWindowsJDKDirectoryPrefix
+    ^'jdk1.8'
+
+    "Created: / 03-04-2014 / 12:31:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-priority
-
-    ^80
-    "/^70
-
-    "Created: / 22-11-2010 / 13:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 04-02-2011 / 06:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-selector
-    "Returns instance-creation selector to get the receiver.
-     See JavaRelease class, protocol instance creation"
-
-    ^#osxJDK6
+javaHomeOnWindowsJREDirectoryPrefix
+    ^'jre8'
+
+    "Created: / 03-04-2014 / 12:31:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-!JavaRelease::OsxJDK6 methodsFor:'object conversions'!
-
-as_ST_String: aJavaString
-    "Given a java.lang.String instance, returns a coresponfing
-     Smalltalk String"
-
-    | str  count  offs  start  stop |
-
-    aJavaString isNil ifTrue: [ ^ nil ].
-self halt:'check if the stuf below is ok'.
-    "/ count := aJavaString instVarNamed:'count'.
-
-    count := aJavaString instVarAt: 3+1"lockWord".
-
-    "/ str := aJavaString instVarNamed:'value'
-
-    str := aJavaString instVarAt: 1+1"lockWord".
-    str size == count
-        ifTrue:
-            [ "cos I don't see any reason to do this"
-            "/ ^ str asOneByteString.
-            ^ str ].
-
-    "/ offs := (aJavaString instVarNamed:'offset').
-
-    offs := aJavaString instVarAt: 2+1"lockWord".
-
-    "/ start := offs + 1.
-
-    start := offs + 1.
-
-    "/ stop := start + (aJavaString instVarNamed:'count') - 1.
-
-    stop := start + count - 1.
-
-    "/ ^ ((aJavaString instVarNamed:'value') copyFrom:start to:stop) asString
-
-    ^ (str copyFrom: start to: stop) asOneByteString
-
-    "Created: / 08-08-1997 / 12:02:55 / cg"
-    "Modified: / 04-01-1999 / 23:55:08 / cg"
-    "Modified: / 22-03-2011 / 17:21:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 08-02-2013 / 00:56:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!JavaRelease::OracleJDK8 methodsFor:'testing'!
+
+isJava7
+    ^ false
+
+    "Created: / 03-04-2014 / 12:16:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-as_String:aString
-    "Given a Smalltalk string, returns corresponsing instance of
-     java.lang.String"
-
-    "hard-coding internas of java.lang.String here is bad ..."
-
-    |s|
-
-self halt:'check if the stuf below is ok'.
-    s := Java java_lang_String basicNew.
-    s instVarAt:1+1"_lockWord_"  put: aString.
-    s instVarAt:3+1"_lockWord_"  put: aString size.
-    ^ s
+isJava8
+    ^ true
+
+    "Created: / 03-04-2014 / 12:15:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaRelease::OracleJDK8 methodsFor:'validating'!
+
+validateJavaHome2: home
+    | homeFromRegistry f homeDir |
+
+    homeFromRegistry := self javaHomeOnWindowsFromRegistryForRelease: '1.8'.
+    homeFromRegistry = home ifTrue:[ ^ true ].
+    homeDir :=  home asFilename.
+
+    "JDK..."
+    (f := homeDir / 'release') exists ifTrue:[
+        f readingFileDo:[:s|
+            s nextLine = 'JAVA_VERSION="1.8.0"' ifTrue:[ ^ true ]
+        ].
+    ].
+    "JRE..."
+    (f := homeDir / 'COPYRIGHT') exists ifTrue:[
+        f readingFileDo:[:s|
+            (s nextLine includesString: 'Oracle') ifTrue:[
+                ^(homeDir / 'THIRDPARTYLICENSEREADME-JAVAFX.txt') exists
+            ]
+        ].
+    ].
+    ^false
+
+
 
     "
-     Java as_String:'hello world'
-    "
-
-    "Created: / 07-08-1997 / 21:15:49 / cg"
-    "Modified: / 08-02-2013 / 00:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!JavaRelease::OsxJDK6 methodsFor:'searching'!
-
-searchForSourcePath
-
-    | jdkHome src_zip |
-
-    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].
-    ].
+        JavaRelease::OracleJDK7 new validateJavaHome: 'c:\Program Files\Java\jdk1.7.0_13' asFilename
+        JavaRelease::OracleJDK7 new validateJavaHome: 'c:\Program Files\Java\jdk1.7.0_13\jre' asFilename
+        JavaRelease::OracleJDK7 new validateJavaHome: 'c:\Program Files\Java\jdk1.6.0_34' asFilename
+        JavaRelease::OracleJDK7 new validateJavaHome: 'c:\Program Files\Java\jdk1.6.0_34\jre' asFilename
 
     "
-        JavaRelease openJDK7 searchForSourcePath; sourcePath
-        JavaRelease sunJDK6 searchForSourcePath; sourcePath
-        JavaRelease openJDK6 searchForSourcePath; sourcePath  
-        JavaRelease openJDK6 jdkHome  
-        JavaRelease openJDK6 jreHome  
-    "
-
-    "Created: / 03-09-2012 / 18:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 23-01-2013 / 12:22:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (comment): / 06-02-2013 / 12:55:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!JavaRelease::OsxJDK6 methodsFor:'validating'!
-
-validateJavaHome2: home
-    ^ true
+
+    "Created: / 03-04-2014 / 12:32:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 validateJavaVersionString:aVersionString
     "Return true if aVersionString (which is what 'java -version' returns)
      matches what I expect."
 
-    ^ aVersionString matches: 'java version "1.6.*'
+    ^ aVersionString matches: '*java version "1.8.*Java(TM) SE Runtime Environment*'
+
+    "Created: / 03-04-2014 / 12:32:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-04-2014 / 14:09:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease::SunJDK122 class methodsFor:'documentation'!
 
 copyright
 "
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
 
  New code and modifications done at SWING Research Group [1]:
 
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
                             SWING Research Group, Czech Technical University in Prague
 
  This software is furnished under a license and may be used
@@ -2090,7 +2782,7 @@
 !
 
 version_SVN
-    ^ '$Id: JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ 'Id::                                                                                                                        '
 ! !
 
 !JavaRelease::SunJDK122 methodsFor:'accessing'!
@@ -2114,9 +2806,9 @@
 name
     "superclass JavaRelease says that I am responsible to implement this method"
 
-    ^ 'Sun JDK 1.2.2'
-
-    "Modified: / 27-07-2012 / 00:14:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ 'Sun Java 1.2.2'
+
+    "Modified: / 15-04-2014 / 18:50:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 priority
@@ -2156,10 +2848,26 @@
     ^false
 
     "Created: / 27-07-2012 / 00:04:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isAvailableOnCurrentOperatingSystem
+    "Return if at all available for current operating system.
+     For example, there's no AppleJDK for Linux or OpenJDK for Windows.
+    "
+
+    ^ false "/ Not supported any longer
+
+    "Created: / 07-12-2014 / 23:57:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRelease::SunJDK122 methodsFor:'validating'!
 
+validateJavaHome2:home
+    ^ false
+
+    "Created: / 02-04-2014 / 16:16:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 validateJavaVersionString:aVersionString
     "Return true if aVersionString (which is what 'java -version' returns)
      matches what I expect."
@@ -2170,14 +2878,14 @@
 !JavaRelease class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libjava/JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libjava/JavaRelease.st,v 1.16 2015-01-28 02:10:50 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libjava/JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libjava/JavaRelease.st,v 1.16 2015-01-28 02:10:50 vrany Exp $'
 !
 
 version_SVN
-    ^ '$Id: JavaRelease.st,v 1.15 2014-01-22 16:12:56 cg Exp $'
+    ^ 'Id::                                                                                                                        '
 ! !