--- a/JavaRelease.st Fri Jan 25 17:57:06 2013 +0000
+++ b/JavaRelease.st Wed Jan 30 13:27:16 2013 +0000
@@ -21,8 +21,8 @@
"{ Package: 'stx:libjava' }"
Object subclass:#JavaRelease
- instanceVariableNames:'javaHome classPath sourcePath classes bootClassPathClasses
- extDirsClasses bundle'
+ instanceVariableNames:'javaHome sourcePath classes bootClassPathClasses extDirsClasses
+ bundle bootClassPath'
classVariableNames:''
poolDictionaries:''
category:'Languages-Java-Support'
@@ -96,6 +96,7 @@
"
! !
+
!JavaRelease class methodsFor:'instance creation'!
custom
@@ -134,6 +135,7 @@
"Modified: / 27-07-2012 / 00:22:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease class methodsFor:'accessing'!
all
@@ -181,6 +183,7 @@
"Created: / 26-07-2012 / 23:41:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease class methodsFor:'instance creation-private'!
instance
@@ -192,6 +195,7 @@
"Created: / 27-07-2012 / 00:22:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease class methodsFor:'others'!
version_HG
@@ -199,6 +203,7 @@
^ '$Changeset: <not expanded> $'
! !
+
!JavaRelease class methodsFor:'queries'!
isAbstract
@@ -208,80 +213,46 @@
"Created: / 22-11-2010 / 13:33:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease methodsFor:'accessing'!
bootClassPath
"Returns a default value of sun.boot.class.path"
- OperatingSystem isUNIXlike ifTrue: [ ^ self bootClassPathOnUNIX ].
- OperatingSystem isMSWINDOWSlike ifTrue: [ ^ self bootClassPathOnWindows ].
- self error: 'Unsupported platform'.
- ^ #().
+
+ bootClassPath isNil ifTrue:[
+ | libs |
+
+ libs := self jreHome / 'lib'.
+ bootClassPath := OrderedCollection new.
+ libs directoryContentsAsFilenames do:[:each|
+ (each pathName endsWith:'.jar') ifTrue:[
+ (each pathName endsWith: 'rt.jar') ifTrue:[
+ bootClassPath addFirst: each pathName
+ ] ifFalse:[
+ bootClassPath addLast: each pathName
+ ]
+ ].
+ ].
+ ].
+ ^bootClassPath.
+
+ "
+ Java release bootClassPath
+ "
"Created: / 02-11-2011 / 12:19:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified (format): / 31-07-2012 / 10:16:25 / jv"
-!
-
-bootClassPathOnUNIX
- "Not known..."
- ^#()
-
- "Created: / 02-11-2011 / 12:33:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 27-07-2012 / 00:23:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-bootClassPathOnWindows
- "Should be same as on UNIX (computed relative to classPath)"
-
- ^self bootClassPathOnUNIX
-
- "Created: / 02-11-2011 / 12:33:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 31-07-2012 / 10:16:14 / jv"
+ "Modified: / 23-01-2013 / 15:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-classPath
- "Returns a default class path"
-
- classPath isNil ifTrue:[self searchForClassPath].
- ^classPath
- "
- JavaRelease openJDK6 classPath
- "
- "Created: / 27-10-2010 / 19:20:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-01-2013 / 12:20:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-codeBundle
- "Return a code bundle representing this Java release
- (JDK)"
-
- | src_zip |
- bundle isNil ifTrue:[
- | b |
- b := JavaCodeBundle new.
- b name: self name.
- src_zip := self sourcePath detect:[:p|p endsWith: 'src.zip'].
- self classPath do:[:p|
- | lib |
- lib := JavaCodeLibrary new.
- lib name: p asFilename baseName.
- lib classes: p.
- lib sources: src_zip.
- b add: lib.
- ].
- bundle := b.
- ].
- ^bundle
- "Created: / 12-01-2013 / 15:50:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 15-01-2013 / 16:44:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
javaExtDirs
@@ -316,8 +287,14 @@
!
javaHome
+ "Answer a Java home. This is either path to JRE (no JDK is found) or to
+ full JDK (if JDK is installed)
- "Answer a Java home"
+ If you want path to either JRE or JDK, use
+ #jreHome
+ #jdkHome
+
+ "
javaHome isNil ifTrue:[
javaHome := self searchForJavaHome.
@@ -330,6 +307,7 @@
"Created: / 27-10-2010 / 18:59:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 27-07-2012 / 00:24:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 23-01-2013 / 12:19:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
javaHomeOrNil
@@ -382,6 +360,25 @@
"Created: / 16-01-2013 / 19:58:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+jdkHome
+
+ "Answers the directory where the JDK lives or nil, if no JDK is found"
+
+ | jdkHome |
+
+ self javaHome isNil ifTrue:[ ^ nil ].
+
+ ^((jdkHome := self javaHome) asFilename / 'jre') exists
+ ifTrue:[jdkHome]
+ ifFalse:[nil].
+
+ "
+ Java release searchForJavaHome; jdkHome
+ "
+
+ "Created: / 23-01-2013 / 12:20:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
jreHome
"Answers the directory where the JRE lives"
@@ -437,6 +434,7 @@
"Modified: / 30-11-2010 / 11:55:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease methodsFor:'debugging'!
dumpConfigOn: stream
@@ -464,9 +462,9 @@
stream nextPutAll: '== Java release config =='; cr.
dumper value: 'name' value: self name value: false.
- dumper value: 'java home' value: self javaHome value: true.
- dumper value: 'jre home' value: self jreHome asString value: true.
- dumper value: 'class path' value: self classPath value: true.
+ dumper value: 'JAVA home' value: self javaHome value: true.
+ dumper value: 'JRE home' value: self jreHome asString value: true.
+ dumper value: 'JDK home' value: self jdkHome asString value: true.
dumper value: 'boot class path' value: self bootClassPath value: true.
dumper value: 'ext dirs' value: self javaExtDirs value: true.
@@ -476,8 +474,10 @@
"
"Created: / 10-12-2011 / 12:55:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 23-01-2013 / 15:24:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease methodsFor:'displaying'!
displayString
@@ -486,6 +486,7 @@
"Created: / 27-07-2012 / 00:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease methodsFor:'initialization'!
initializeBootClassPathIndex
@@ -493,16 +494,16 @@
self bootClassPath do: [:file |
| filename |
- filename := file pathName.
+ filename := file asFilename.
- self assert: (file suffix = 'jar').
- self assert: (file exists).
- self selectAllClassNamesIn: filename to: bootClassPathClasses.
+ 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: / 02-11-2011 / 23:46:39 / Jan Vrany <jan.vrany@fit.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
@@ -547,6 +548,7 @@
"Created: / 02-11-2011 / 12:12:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+
!JavaRelease methodsFor:'private'!
searchInternalIndex: anIdentityCollection for: className
@@ -586,6 +588,7 @@
"Created: / 01-11-2011 / 14:18:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+
!JavaRelease methodsFor:'queries'!
bootClassPathIncludesClassNamed: className
@@ -633,52 +636,12 @@
"Created: / 27-07-2012 / 00:08:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease methodsFor:'searching'!
-searchForClassPath
- | jreHome jdkHome |
- bundle := nil.
- classPath := OrderedCollection new.
- jreHome := self jreHome asFilename.
- jdkHome := self javaHome asFilename.
- jreHome isNil ifTrue:[ ^ #() ].
- "Ensure, that rt.jar is first"
- classPath add: (jreHome / 'lib' / 'rt.jar') pathName.
-
- self searchForClassPathIn: jreHome / 'lib' .
- self searchForClassPathIn: jreHome / 'lib' / 'modules'.
-
- "Search for JDK tools (javac & co)"
- (jdkHome ~= javaHome and:[(jdkHome / 'lib') exists]) ifTrue:[
- self searchForClassPathIn: jdkHome / 'lib'
- ].
- ^self classPath
- "
- Java release searchForClassPath.
- Java release classPath.
-
- "
- "Created: / 27-10-2010 / 21:15:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 12-01-2013 / 15:55:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-searchForClassPathIn: dir
- dir exists ifFalse: [ ^ self ].
- dir directoryContentsAsFilenames do: [
- :file |
- " this is to make sure that rt.jar is always first --v "
- (file suffix = 'jar' and: [ file baseName ~= 'rt.jar' ]) ifTrue: [
- classPath add: file pathName.
- ]
- ]
-
- "Created: / 27-10-2010 / 21:38:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 02-11-2011 / 17:49:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 12-01-2013 / 15:55:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
searchForJavaHome
@@ -686,15 +649,12 @@
h := (OperatingSystem getEnvironment:'JAVA_HOME').
h notNil ifTrue:[
- javaHome := h asFilename.
+ javaHome := h asFilename.
"/Do not trust JAVA_HOME, it might be wrong (on Windows machine due
"/to a registry mess
- javaHome exists ifTrue:[
- (javaHome / 'jre') exists ifTrue:[
- javaHome := javaHome / 'jre'.
- ].
- ^javaHome
- ]
+ ((javaHome / 'lib' / 'rt.jar') exists
+ or:[(javaHome / 'jre' / 'lib' / 'rt.jar') exists])
+ ifTrue:[ ^ javaHome ].
].
self javaHomes do:
@@ -713,11 +673,10 @@
"
"Created: / 27-10-2010 / 19:03:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 22-11-2010 / 13:18:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-03-2011 / 13:29:14 / Jan Kurs <kursjan@fit.cvut.cz>"
"Modified: / 15-03-2011 / 13:47:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 19-07-2012 / 11:08:04 / jv"
- "Modified (comment): / 15-12-2012 / 01:04:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 23-01-2013 / 12:16:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
searchForSourcePath
@@ -740,6 +699,7 @@
"Modified: / 12-01-2013 / 15:55:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease methodsFor:'validating'!
validateJavaHome: home
@@ -763,6 +723,7 @@
"Modified: / 10-08-2012 / 16:28:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::Custom class methodsFor:'documentation'!
copyright
@@ -793,21 +754,10 @@
^ '§Id:: §'
! !
+
!JavaRelease::Custom methodsFor:'accessing'!
-bootClassPathOnUNIX
- | jre bcp jar |
- jre := self jreHome.
- bcp := OrderedCollection new.
- bcp add: jre / 'lib' / 'rt.jar'.
- (jar := jre / 'lib' / 'resources.jar') exists ifTrue:[ bcp add: jar ].
- (jar := jre / 'lib' / 'jsse.jar') exists ifTrue:[ bcp add: jar ].
- (jar := jre / 'lib' / 'jce.jar') exists ifTrue:[ bcp add: jar ].
- (jar := jre / 'lib' / 'charsets.jar') exists ifTrue:[ bcp add: jar ].
- ^bcp.
- "Modified: / 31-07-2012 / 10:18:42 / jv"
-!
javaHome
@@ -875,6 +825,7 @@
"Created: / 27-07-2012 / 10:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::Custom methodsFor:'initialization'!
initialize
@@ -883,6 +834,7 @@
"Created: / 26-07-2012 / 23:40:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::Custom methodsFor:'queries'!
isAvailable
@@ -897,6 +849,7 @@
"Created: / 27-07-2012 / 00:08:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::Custom methodsFor:'searching'!
searchForJavaHome
@@ -905,6 +858,7 @@
"Created: / 26-07-2012 / 23:34:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::OpenJDK6 class methodsFor:'documentation'!
copyright
@@ -935,28 +889,10 @@
^ '§Id:: §'
! !
+
!JavaRelease::OpenJDK6 methodsFor:'accessing'!
-bootClassPathOnUNIX
- | jre |
- jre := self jreHome.
-
- ^ {
- jre / 'lib' / 'resources.jar' .
- jre / 'lib' / 'rt.jar' .
- jre / 'lib' / 'jsse.jar' .
- jre / 'lib' / 'jce.jar' .
- jre / 'lib' / 'charsets.jar' .
- }
-
- "
- JavaRelease openJDK6 bootClassPathOnUNIX
- "
-
- "Created: / 02-11-2011 / 12:36:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified (comment): / 02-11-2011 / 23:39:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
javaExtDirsOnUNIX
@@ -985,14 +921,20 @@
arch := OperatingSystem getSystemInfo at:#machine.
arch = 'x86_64' ifTrue:[arch := 'amd64'].
- ^ { '/usr/lib/jvm/java-6-openjdk/jre' .
- '/usr/lib/jvm/java-6-openjdk-',arch,'/jre' }
+ ^ {
+ '/usr/lib/jvm/java-6-openjdk' . "/ JDK - older linuxes
+ '/usr/lib/jvm/java-6-openjdk-',arch. "/ JDK - newer linuxes
+
+ '/usr/lib/jvm/java-6-openjdk/jre' . "/ JRE - older linuxes
+ '/usr/lib/jvm/java-6-openjdk-',arch, '/jre' "/ JRE - newer linuxes
+
+ }
"
JavaRelease::OpenJDK6 new javaHomesOnUNIX
"
- "Modified (comment): / 08-01-2013 / 12:22:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 23-01-2013 / 12:19:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
javaNativeMethodsImplementation
@@ -1029,6 +971,7 @@
"Created: / 27-07-2012 / 10:05:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::OpenJDK6 methodsFor:'private'!
javaHomeOnWindowsJDKDirectoryPrefix
@@ -1037,22 +980,19 @@
"Created: / 19-07-2012 / 11:04:34 / jv"
! !
+
!JavaRelease::OpenJDK6 methodsFor:'searching'!
searchForSourcePath
- | java_homes src_zip |
+ | jdkHome src_zip |
super searchForSourcePath.
sourcePath := OrderedCollection new.
- java_homes := OrderedCollection new.
- self javaHome notNil ifTrue:[
- java_homes add: self javaHome
- ].
-
- java_homes do:[ :java_home |
- src_zip := java_home asFilename directory / 'src.zip'.
+ jdkHome := self jdkHome.
+ jdkHome notNil ifTrue:[
+ src_zip := jdkHome asFilename / 'src.zip'.
src_zip exists ifTrue:[sourcePath add: src_zip pathName].
].
@@ -1061,9 +1001,10 @@
"
"Created: / 03-09-2012 / 18:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 12-01-2013 / 15:56:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 23-01-2013 / 12:22:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::OpenJDK7 class methodsFor:'documentation'!
copyright
@@ -1094,6 +1035,7 @@
^ '§Id:: §'
! !
+
!JavaRelease::OpenJDK7 methodsFor:'accessing'!
javaHomesOnUNIX
@@ -1136,6 +1078,7 @@
"Created: / 27-07-2012 / 10:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::OpenJDK7 methodsFor:'private'!
javaHomeOnWindowsJDKDirectoryPrefix
@@ -1144,6 +1087,7 @@
"Created: / 19-07-2012 / 11:05:02 / jv"
! !
+
!JavaRelease::SunJDK122 class methodsFor:'documentation'!
copyright
@@ -1174,20 +1118,10 @@
^ '§Id:: §'
! !
+
!JavaRelease::SunJDK122 methodsFor:'accessing'!
-bootClassPathOnUNIX
- | jre |
- jre := self javaHome.
- ^jre notNil ifTrue:[
- Array with: (jre / 'lib' / 'rt.jar')
- ] ifFalse:[
- #()
- ]
-
- "Created: / 31-07-2012 / 10:20:24 / jv"
-!
javaHomesOnUNIX
"superclass JavaRelease says that I am responsible to implement this method"
@@ -1229,6 +1163,7 @@
"Created: / 27-07-2012 / 10:06:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::SunJDK122 methodsFor:'displaying'!
displayString
@@ -1242,6 +1177,7 @@
"Created: / 27-07-2012 / 00:13:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::SunJDK122 methodsFor:'queries'!
isAvailable
@@ -1252,6 +1188,7 @@
"Created: / 27-07-2012 / 00:04:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease::SunJDK6 class methodsFor:'documentation'!
copyright
@@ -1282,6 +1219,7 @@
^ '§Id:: §'
! !
+
!JavaRelease::SunJDK6 methodsFor:'accessing'!
javaHomesOnUNIX
@@ -1365,8 +1303,10 @@
"Created: / 27-07-2012 / 10:05:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!JavaRelease class methodsFor:'documentation'!
version_SVN
^ '§Id:: §'
! !
+