JavaRelease.st
branchrefactoring-classpath
changeset 1989 131b7459fdab
parent 1988 0fcf5a5dcb66
child 1995 b129fd0a81e4
--- a/JavaRelease.st	Wed Jan 23 12:31:33 2013 +0000
+++ b/JavaRelease.st	Wed Jan 23 16:22:00 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'
@@ -213,79 +213,31 @@
 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"
-!
-
-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'] ifNone:[nil].
-
-        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
-
-    "
-        Java release codeBundle
-    "
-
-    "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>"
-    "Modified (comment): / 23-01-2013 / 12:25:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 23-01-2013 / 15:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 javaExtDirs
@@ -487,9 +439,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.
 
@@ -499,6 +451,7 @@
     "
 
     "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'!
@@ -658,51 +611,6 @@
 
 !JavaRelease methodsFor:'searching'!
 
-searchForClassPath
-
-    | jreHome jdkHome |
-    bundle := nil.
-    classPath := OrderedCollection new.
-    jreHome := self jreHome asFilename.
-    jdkHome := self jdkHome 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 notNil 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: / 23-01-2013 / 12:26:07 / 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
 
     | h |
@@ -814,20 +722,6 @@
 
 !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
 
     "Answer a Java home"
@@ -956,27 +850,6 @@
 
 !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
 
     ^{
@@ -1189,19 +1062,6 @@
 
 !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"