class: Smalltalk
changed: #loadPackage:fromDirectory:asAutoloaded:
catch error in initialization of an autoloaded package definition
class and retry after the whole package has been loaded.
Will remove this, when postLoad actions are correctly called
in package definitions
--- a/Smalltalk.st Mon Sep 02 17:06:20 2013 +0200
+++ b/Smalltalk.st Mon Sep 02 17:18:35 2013 +0200
@@ -2374,7 +2374,7 @@
|packageDir shLibName
binaryClassLibraryFilename projectDefinitionFilename projectDefinitionClass projectDefinitionClassName silent somethingHasBeenLoaded
- loadOK loadErrorOccurred exePath|
+ loadOK exePath errorInInitialize|
packageDirOrStringOrNil notNil ifTrue:[
packageDir := packageDirOrStringOrNil asFilename.
@@ -2480,6 +2480,9 @@
].
binaryClassLibraryFilename exists ifTrue:[
+ |loadErrorOccurred|
+
+ loadErrorOccurred := false.
ObjectFileLoader::ObjectFileLoadErrorNotification handle:[:ex |
loadErrorOccurred := true.
ex proceedWith:true.
@@ -2528,9 +2531,26 @@
projectDefinitionFilename exists ifTrue:[
Class withoutUpdatingChangesDo:[
Smalltalk silentlyLoadingDo:[
- projectDefinitionFilename fileIn.
+ Error handle:[:ex |
+ "/ catch error during initialization;
+ ex suspendedContext withAllSendersDo:[:sender |
+ sender selector == #initialize ifTrue:[
+ sender receiver isBehavior ifTrue:[
+ sender receiver name = projectDefinitionClassName ifTrue:[
+ errorInInitialize := true
+ ]
+ ]
+ ]
+ ].
+ errorInInitialize ifFalse:[ ex reject ].
+ ] do:[
+ projectDefinitionFilename fileIn.
+ ].
].
].
+ errorInInitialize ifTrue:[
+ Transcript showCR:'Smalltalk [info]: an error happened in #initialize - retry after loading package.'.
+ ].
projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString.
"/ done below
"/ projectDefinitionClass notNil ifTrue:[
@@ -2543,6 +2563,10 @@
projectDefinitionClass autoload.
projectDefinitionClass loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded.
somethingHasBeenLoaded := projectDefinitionClass loadAsAutoloaded:doLoadAsAutoloaded.
+ errorInInitialize ifTrue:[
+ Transcript showCR:('Smalltalk [info]: retrying #initialize').
+ projectDefinitionClass initialize.
+ ].
(silent not and:[somethingHasBeenLoaded]) ifTrue:[
Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageString , ' from project definition').
].
@@ -7950,11 +7974,11 @@
!Smalltalk class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1035 2013-08-21 14:08:19 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1036 2013-09-02 15:18:35 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1035 2013-08-21 14:08:19 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.1036 2013-09-02 15:18:35 cg Exp $'
!
version_SVN