Class loading refactoring (part 2)
Killed monster if-absent block in JavaVM>>#classForName:definedBy:.
--- a/JavaVM.st Tue Dec 10 22:33:43 2013 +0000
+++ b/JavaVM.st Tue Dec 10 23:04:44 2013 +0000
@@ -2583,55 +2583,10 @@
ifAbsentPut: [
| class classLoaderEnsured |
self assert: (binaryName includes: $.) not.
- self booted ifFalse: [
- "class loaders allowed after vm boot, until then, only primordial"
- class := self loadClassNamed: binaryName usingClassLoader: nil.
- self assert:(class notNil)
- message:'Couldnt load class ' , binaryName , ' while booting Java VM'.
+ class := self loadClassNamed: binaryName usingClassLoader: classLoader.
class.
- ] ifTrue: [
- self assert:(self booted)
- message:'Java VM is not booted and we are not using primordial class loader to load: ' , className.
- (Java release bootClassPathIncludesClassNamed: className) ifTrue: [
- "we will use primordial class loader for classes in rt.jar etc"
- class := self loadClassNamed: binaryName usingClassLoader: nil.
- self assert:(class notNil)
- message:'Class ' , binaryName , ' is supposed to be in boot classpath, but we couldnt load it'.
- class.
- ] ifFalse: [
- (Java release extDirsIncludesClassNamed: binaryName) ifTrue: [
- | ext |
-
- ext := self extClassLoader.
- self assert: ext notNil message: 'Have to use ext class loader but does not exists'.
- class := self loadClassNamed: binaryName usingClassLoader: ext.
- self assert:(class notNil)
- message:'Class ' , binaryName , ' is supposed to be in java.ext,dirs, but we couldnt load it'.
- class.
- ] ifFalse: [
-"/ "at this point, nil classLoader means use system class loader,
-"/ in other words, at this point, we shouldnt use primordial cl at all"
-"/ classLoader isNil ifTrue: [
-"/ self assert:(self systemClassLoader notNil)
-"/ message:'We needed system class loader, but its not loaded yet'.
-"/ classLoaderEnsured := self systemClassLoader
-"/ ] ifFalse: [
- classLoaderEnsured := classLoader.
-"/ ].
-
- class := self loadClassNamed: binaryName usingClassLoader: classLoaderEnsured.
- class isNil ifTrue: [
- Logger
- log: 'Even ' , classLoader printString , ' was not able to load class '
- , className
- severity: #warn
- facility: 'JVM'.
- nil
- ] ifFalse: [ class ].
- ]
- ]
- ]
].
+
result isNil ifTrue: [
Logger
log: 'Class ' , className , ' couldnt be loaded'
@@ -2642,7 +2597,7 @@
"Created: / 21-10-2011 / 12:01:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 02-11-2011 / 16:49:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 10-12-2013 / 17:59:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-12-2013 / 22:59:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
classForName: className definedBy: classLoader ifAbsentPut: aBlock